Skip to Content
ROS Programming: Building Powerful Robots
book

ROS Programming: Building Powerful Robots

by Anil Mahtani, Luis Sanchez, Enrique Fernandez, Aaron Martinez, Lentin Joseph
March 2018
Intermediate to advanced content levelIntermediate to advanced
1396 pages
42h 14m
English
Packt Publishing
Content preview from ROS Programming: Building Powerful Robots

Showing messages once, throttling, and other combinations

It is also possible to control how many times a given message is shown. We can print it only once with ROS_<LEVEL>[_STREAM]_ONCE[_NAMED]:

for(int i = 0; i< 10; ++i ) { 
  ROS_INFO_STREAM_ONCE("My once INFO stream message; i = " <<i); 
} 

This code from the example2 node will show the message only once.

However, it is usually better to show the message with a certain frequency. For that, we have throttle messages. They have the same format as the once message, but here ONCE is replaced with THROTTLE. They also include a first argument, which is period in seconds, that is, it is printed only every period seconds:

for(int i = 0; i< 10; ++i ) { ROS_INFO_STREAM_THROTTLE(2, "My throttle INFO ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Robots with ROS

Programming Robots with ROS

Morgan Quigley, Brian Gerkey, William D. Smart
Machine Learning Design Patterns

Machine Learning Design Patterns

Valliappa Lakshmanan, Sara Robinson, Michael Munn

Publisher Resources

ISBN: 9781788627436Supplemental Content