Ask Your Question

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

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



Very Thanks, I use timer and solve my problem.

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



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

Seen: 80 times

Last updated: Dec 26 '20