ROS Logging
Basic Usage
Include console.h
#include <ros/console.h>Set the verbosity level for the node
There are 5 basic logging verbosity levels:
Debug
Info
Warn
Error
Fatal
Below is an initialization of the angle finder node. The log level for this node is set to Info. All Info and Debug-type log messages will be enabled.
int main(int argc, char** argv) {
ros::init(argc, argv, "angle_finder");
if (ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Info))
ros::console::notifyLoggerLevelsChanged();
AngleFinder angle_finder;
angle_finder.spin();
return 0;
}There are other ways to set the log level. See ROS documentation on logging for more information.
TAGs
We use a TAG to identify the node in which the log message came from. This is just the first part of the log message.
For example, this is how we set the TAG for the coord finder node:
std::string TAG = "COORD_FINDER: ";How to Log
Standard Log
ROS_DEBUG("%s Hello %s", TAG, "World");Stream Log
ROS_DEBUG_STREAM(TAG << "Hello " << "World");Where the logs go
You can specify whether the log messages are written to the screen to a log file in the launch file:
output="log|screen"The below example sends the messages to a log.
<node name="coord_finder" pkg="prop_follower" type="coord_finder" output="log" if="$(arg lidar-distance-angle-measurement)" >
<rosparam file="$(find prop_follower)/config/params.yaml" command="load" />
</node>The logs go into ~/.ros/log/ and are named with horrible numbers that are hard to identify. Currently trying to figure out how to set
Last updated