jsk-ros-pkg / jsk_common

common programs for jsk-ros-pkg
43 stars 81 forks source link

[jsk_topic_tools/HzMeasureNodelet] Added measure_time param and modified to measure hz in the updateDiagnostics function. #1754

Closed iory closed 1 year ago

iory commented 2 years ago

What is this?

Since the hz is now calculated in the callback function, so if topic stops for a while, the hz calculation will not be correct.

With this PR, the hz calculation will be correct even if the topic does not come.

Also, the ~measure_time param was added so that hz can be calculated based on the number of topics that came within a certain time period.

Parameter

iory commented 2 years ago

@tkmtnt7000 Could you review this?

tkmtnt7000 commented 2 years ago

Sorry for late review. I tested this node with following test codes and get the following result. If I make a mistake about how to test this PR, please let me know.

<!-- sample_hz_measure.launch -->
<launch>
  <node name="hz_measure"
        pkg="nodelet" type="nodelet"
        args="load jsk_topic_tools/HzMeasure /manager" >
    <remap from="~input" to="hw_registered/image_rect_raw" />
    <remap from="~output" to="hw_registered/image_rect_raw/measured_hz" />
    <rosparam subst_value="true" >
      warning_hz: 5
    </rosparam>
  </node>
</launch>
$ rostopic pub /hw_registered/image_rect_raw std_msgs/Int16 -r 30 5
$ rostopic echo /diagnostics
...
...
---
header: 
  seq: 1
  stamp: 
    secs: 1661417928
    nsecs: 386849346
  frame_id: ''
status: 
  - 
    level: 2
    name: "manager: /hz_measure"
    message: "/hz_measure is waiting input topic."
    hardware_id: "/hz_measure"
    values: []
---
header: 
  seq: 2
  stamp: 
    secs: 1661417930
    nsecs: 386312250
  frame_id: ''
status: 
  - 
    level: 2
    name: "manager: /hz_measure"
    message: "/hz_measure is waiting input topic."
    hardware_id: "/hz_measure"
    values: []
---
header: 
  seq: 3
  stamp: 
    secs: 1661417932
    nsecs: 386144813
  frame_id: ''
status: 
  - 
    level: 2
    name: "manager: /hz_measure"
    message: "/hz_measure is waiting input topic."
    hardware_id: "/hz_measure"
    values: []
---