ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

speed down the subscription rate

asked 2020-12-26 03:24:55 -0500

wangzheqie gravatar image

I have two program A and B. A publish a topic with 100hz, and B want to subscribe the same topic with only 10hz. I search google for a long time and find no result. Any one can provide help?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-12-26 14:55:34 -0500

Could you give us some context into what you are trying to accomplish?

I haven't used ros2. But in ros1, you can hack this behavior using timers as shown here. Ros2 may have something similar.

You could have a subscriber that reads the topic at the original 100Hz and saves the value to some variable (or struct). Each ros timer has a callback and you can execute this callback at the desired 10Hz rate, where you can use this data for your processing. In the code example at the above link, you can have callback1 from the subscriber (at whatever rate program A is publishing) and callback2 from the timer (at the desired 10Hz).

edit flag offensive delete link more

Comments

1

Very Thanks, I use timer and solve my problem.

wangzheqie gravatar image wangzheqie  ( 2020-12-28 00:25:05 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-12-26 03:24:55 -0500

Seen: 629 times

Last updated: Dec 26 '20