jsk-ros-pkg / jsk_common

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

Throttle nodes doesn't support exact publish rate. #1747

Closed sktometometo closed 1 year ago

sktometometo commented 2 years ago

Currently we have 2 types of throttle nodes. They doesn't seems support exact publish rate.

For examples, when I launch a test launch file below in Fetch 1075.

<launch>
    <arg name="input_topic_01" default="/insta360/image_raw" />
    <arg name="input_topic_02" default="/insta360/camera_info" />
    <arg name="target_rate" default="10.0"/>

    <node
        pkg="topic_tools"
        type="throttle"
        name="topic_tools_throttle"
        args="messages $(arg input_topic_01) $(arg target_rate) /outputs/topic_tools_throttle"
        >
        <rosparam subst_value="true">
            lazy: True
        </rosparam>
    </node>

    <node
        pkg="nodelet"
        type="nodelet"
        name="jsk_topic_tools_synchronized_throttle"
        args="standalone jsk_topic_tools/SynchronizedThrottle"
        >
        <remap from="$(arg input_topic_01)/throttled" to="/outputs/jsk_topic_tools_synchronized_throttle" />
        <remap from="$(arg input_topic_02)/throttled" to="/outputs/jsk_topic_tools_synchronized_throttle_info" />
        <rosparam subst_value="true">
            topics:
                - $(arg input_topic_01)
                - $(arg input_topic_02)
            update_rate: $(arg target_rate)
        </rosparam>
    </node>

    <node
        pkg="nodelet"
        type="nodelet"
        name="jsk_topic_tools_lightweight_throttle"
        args="standalone jsk_topic_tools/LightweightThrottle"
        >
        <remap from="~input" to="$(arg input_topic_01)" />
        <remap from="~output" to="/outputs/jsk_topic_tools_lightweight_throttle" />
        <rosparam subst_value="true">
            update_rate: $(arg target_rate)
        </rosparam>
    </node>

</launch>

output rates of each throttle nodes are

fetch@fetch1075:~$ rostopic hz /outputs/topic_tools_throttle
subscribed to [/outputs/topic_tools_throttle]
average rate: 8.612
    min: 0.094s max: 0.135s std dev: 0.01717s window: 7
average rate: 8.422
    min: 0.094s max: 0.135s std dev: 0.01472s window: 15
average rate: 8.471
    min: 0.094s max: 0.136s std dev: 0.01487s window: 23
^Caverage rate: 8.479
    min: 0.094s max: 0.136s std dev: 0.01467s window: 25
fetch@fetch1075:~$ rostopic hz /outputs/jsk_topic_tools_synchronized_throttle
subscribed to [/outputs/jsk_topic_tools_synchronized_throttle]
average rate: 8.575
    min: 0.100s max: 0.133s std dev: 0.01478s window: 7
average rate: 8.619
    min: 0.100s max: 0.138s std dev: 0.01459s window: 16
average rate: 8.631
    min: 0.098s max: 0.138s std dev: 0.01432s window: 24
fetch@fetch1075:~$ rostopic hz /outputs/jsk_topic_tools_lightweight_throttle 
subscribed to [/outputs/jsk_topic_tools_lightweight_throttle]
average rate: 9.170
    min: 0.099s max: 0.131s std dev: 0.01252s window: 7
average rate: 8.388
    min: 0.099s max: 0.136s std dev: 0.01419s window: 15
average rate: 8.444
    min: 0.099s max: 0.136s std dev: 0.01397s window: 24
average rate: 8.535
    min: 0.099s max: 0.136s std dev: 0.01374s window: 32

Input topic rates are

fetch@fetch1075:~$ rostopic hz /insta360/image_raw
subscribed to [/insta360/image_raw]
average rate: 30.048
    min: 0.025s max: 0.047s std dev: 0.00476s window: 28
average rate: 30.091
    min: 0.024s max: 0.047s std dev: 0.00423s window: 58
average rate: 30.056
    min: 0.024s max: 0.047s std dev: 0.00416s window: 89
fetch@fetch1075:~$ rostopic hz /insta360/camera_info
subscribed to [/insta360/camera_info]
average rate: 29.866
    min: 0.027s max: 0.046s std dev: 0.00427s window: 29
average rate: 29.863
    min: 0.024s max: 0.046s std dev: 0.00365s window: 59
average rate: 29.920
    min: 0.024s max: 0.046s std dev: 0.00378s window: 89
iory commented 2 years ago

For examples, when I launch a test launch file below in Fetch 1075.

What happens when you run them in your environment?

sktometometo commented 2 years ago

Same result when playing rosbag in my PC.

iory commented 2 years ago

Could you upload the bag file?

sktometometo commented 2 years ago

I have uploaded rosbag here. https://drive.google.com/drive/folders/1pUS9Z-thYL9mBN2qAcXZKc2EsaCAmLXe?usp=sharing (Only for jsk members)

iory commented 2 years ago

The algorithm to downsampling may be the problem.

https://github.com/ros/ros_comm/issues/560

sktometometo commented 2 years ago

The algorithm to downsampling may be the problem.

ros/ros_comm#560

I agree that.