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 { 
  MyLowerFilter(const double&val ) : value( val ) {} 
  inline virtual boolisEnabled() { return value < 0.; } 
  double value; 
  }; 
 
MyLowerFilterfilter_lower(val ); 
 
ROS_INFO_STREAM_FILTER(&filter_lower, 
  "My filter INFO stream message; val (" <<val<< ") < 0" 
); 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.124.194