ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
@Weasfas 's answer is correct for setting a particular rate of publishing and subscribing using sleep()
. Accroding to your other questions you might need to use a timer because :
100Hz
but you take 1 sec
to execute the callback, you will end up loosing data or process old data that has been stored in the callback queue. You can use a global variable to store the message data and in another function you can use the global variable and publish what's needed. About the Rate, yes it will affect both subscribers and publisher (if the publisher is within the callback). Spinning at a define rate means that your callbacks are triggered at this rate (but it will be executed as many times as messages have been stored in the queue while waiting)