diamondback:Only showing information from the released package extracted on Unknown. No API documentation available. Please see this page for information on how to submit your repository to our index.
electric:Documentation generated on March 02, 2013 at 01:21 PM
fuerte:Documentation generated on December 28, 2013 at 05:34 PM
groovy:Documentation generated on October 06, 2014 at 06:55 AM
hydro:Documentation generated on August 26, 2015 at 04:00 PM (doc job).
indigo:Documentation generated on June 09, 2019 at 04:32 AM (doc job).
kinetic:Documentation generated on June 10, 2019 at 10:38 PM (doc job).
lunar:Documentation generated on April 05, 2019 at 10:12 AM (doc job).
melodic:Documentation generated on March 01, 2022 at 07:27 AM (doc job).
noetic:Documentation generated on March 02, 2022 at 08:51 AM (doc job).
rosrt is a package that contains realtime-safe tools for interacting with ROS. It is currently experimental and not API stable, so use at your own risk. Used together with a Xenomai Kernel the ROS processes get guaranteed CPU time and are not affected by other processes. rosrt can also slightly improve performance by avoiding memory allocations by preallocating. Those speed-ups should probably be helpful even if not running a real time system if small margins are important.
There is an optional InitOptions argument to rosrt::init().
rosrt::init() starts three threads, one for publishing, one for subscribing and one for garbage collection. The publisher thread uses a lock-free multi-writer single-reader queue with a fixed limit on the # of messages specified by InitOptions::pubmanager_queue_size.
Using the rosrt::Publisher is very similar to the standard ros::Publisher but with some realtime-specific requirements. First, it provides you with a fixed-size buffer of messages (10 in the example below). To be realtime safe you must allocate your messages out of this rosrt::Publisher you're publishing it with. Second, you must initialize each of those messages with a template message when you initialize the rosrt::Publisher. Anything that needs to be preallocated should be preallocated in this template.
Deallocation of the Publisher's pool of memory is done by a separate garbage collection thread, and will not happen until all messages allocated out of the Publisher have been freed (or on program exit).
As with the rosrt::Publisher, you must specify a message pool size. If you are not going to be storing off received messages the optimal size for this is 3 (1 for the ROS-side subscription queue, 1 waiting in the Subscriber, 1 in use by realtime).
poll() will never return the same message twice. This means:
<message received>
sub.poll() <--- returns a message
sub.poll() <--- returns NULL
<message received>
sub.poll() <--- returns a message
...
Deallocation of the Subscriber's pool of memory is done by a separate garbage collection thread, and will not happen until all messages allocated out of the Subscriber have been freed (or on program exit).
Allocation Tracking
rosrt also provides a way of tracking allocations and frees per thread. See the getThreadAllocInfo(), resetThreadAllocInfo(), setThreadBreakOnAllocOrFree() functions in the rosrt namespace, as well as the AllocInfo struct.