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

Revision history [back]

click to hide/show revision 1
initial version

If theRobotMovement() method takes a long time to run, or it shouldn't be called multiple times concurrently, you may consider re-architecting this a bit in conjunction with a MultiThreaded executor, or a second Thread.

Instead of calling RobotMovement() inside your topic callback, you could put the data into a queue, and read that queue from a dedicated timer or thread. This way you've got the subscriptions getting handled by an executor, and the RobotMovement thread/timer can take as much time as it needs to push the robot through all the data in the queue without blocking the subscriptions.

If you use a timer for the RobotMovement, you'll need to put it in it's own callback group (type doesn't matter), and use a MultiThreaded Executor. In both cases, be sure to use mutexes to ensure that only one thread/callback is modifying the queue at a time.