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

Conditional and filtered messages

Conditional messages are printed only when a given condition is satisfied. To use them, we have the ROS_<LEVEL>[_STREAM]_COND[_NAMED] functions; note that they can be named messages as well (see the example2 node for more examples and combinations):

ROS_INFO_STREAM_COND( 
  val< 0., 
    "My conditional INFO stream message; val (" <<val<< ") < 0" 
); 

Filtered messages are similar to conditional messages in essence, but they allow us to specify a user-defined filter that extends ros::console::FilterBase; we must pass a pointer to such a filter in the first argument of a macro with the format ROS_<LEVEL>[_STREAM]_FILTER[_NAMED]. The following example is taken from the example2 node:

structMyLowerFilter : public ros::console::FilterBase ...
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