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

This question is a bit old, and since I didn't get a response we worked out our own plan in the interim.

Since it has recently got some traction, I'll briefly describe what we did.

We used boost::thread to create our worker threads. ros was set up in the main thread, and publishers/subscribers were created per the normal tutorials.

Data coming in via subscriptions would have the const ptr stored in a lock protected copy. The worker thread would then grab a copy of the latest const pointer at the appropriate cycle. Data processing and calculations would occur in the worker thread.

The worker thread would then use the publisher to send ROS data. Minimal processing between lock/unlock, and only publishing from one thread seemed to work well.

Using the worker thread maintained the responsiveness to handling ros messages that were coming in at 1kHz. Our control loop range around 250-300 hz.

This question is a bit old, and since I didn't get a response we worked out our own plan in the interim.

Since it the question has recently got some traction, I'll briefly describe what we did.

We used boost::thread to create our worker threads. ros was set up in the main thread, and publishers/subscribers were created per the normal tutorials.

Data coming in via subscriptions would have the const ptr stored in a lock protected copy. The worker thread would then grab a copy of the latest const pointer at the appropriate cycle. Data processing and calculations would occur in the worker thread.

The worker thread would then use the publisher to send ROS data. Minimal processing between lock/unlock, and only publishing from one thread seemed to work well.

Using the worker thread maintained the responsiveness to handling ros messages that were coming in at 1kHz. Our control loop range around 250-300 hz.

This question is a bit old, and since I didn't get a response we worked out our own plan in the interim.

Since the question has recently got some traction, I'll briefly describe what we did.

We used boost::thread to create our worker threads. ros was set up in the main thread, and publishers/subscribers were created per the normal tutorials.

Data coming in via subscriptions would have the const ptr stored in a lock protected copy. The worker thread would then grab a copy of the latest const pointer at the appropriate cycle. Data processing and calculations would occur in the worker thread.

The worker thread would then use the publisher to send ROS data. Minimal processing between lock/unlock, and only publishing from one thread seemed to work well.

Using the worker thread maintained the responsiveness to handling ros messages that were coming in at 1kHz. Our control loop range ran around 250-300 hz.