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

how to publish a data to a rostopic without sleep and without interrupting other messages? ?

asked 2020-12-18 11:13:00 -0500

asif gravatar image

updated 2022-04-30 13:34:18 -0500

lucasw gravatar image

i want to publish a data on a topic with 1 Hz . my script is running on 30hz and all other messages are being published at 30 Hz . while that i want to publish a particular message at 1 hz without interrupting main frequency(30 Hz). as if i use rospy rate / ros sleep than it will cause a stop to script and other messages frequency will be interrupt.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2020-12-23 02:46:00 -0500

rodrigo55 gravatar image

Hi,

You can use the rospy.Timer() function along with a callback function. This will allow you to publish topics at a different rate from a single node. Also, replacing rospy.rate() with rospy.spin() will prevent your program to step on its own toes. If you want additional help, you can check out this video I made addressing this issue:

https://www.youtube.com/watch?v=7RH4W...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-12-18 11:13:00 -0500

Seen: 391 times

Last updated: Dec 23 '20