常用日志的宏

总共有二十多个宏,我只列出有价值而且容易用的

1
2
3
4
5
6
7
#define ROS_INFO(...)
#define ROS_INFO_COND(cond, ...)
#define ROS_INFO_ONCE(...)
#define ROS_INFO_STREAM(args)
#define ROS_INFO_NAMED(name, ...)
#define ROS_INFO_THROTTLE(rate, ...)
#define ROS_INFO_FILTER(filter, ...)

ROS_INFO_ONCE

适用于循环内,防止不断产生日志

1
2
for(int i=0; i<3; i++)
ROS_INFO_ONCE("1111111");

结果只有一个1111111

ROS_INFO_COND

ROS_INFO_COND(2>1, "log here");

ROS_INFO_STREAM

其实就是C++风格的ROS_INFO:
ROS_INFO_STREAM("velocity command: " << " linear=" << msg. linear . x << " angular=" << msg. angular . z)