ros日志输出路径
ros节点日志文件输出到~/.ros/log文件夹。可以通过修改环境变量(ROS_HOME 或者 ROS_LOG_DIR )来修改路径。但与具体工程无关。如果使用roslaunch启动程序,可以通过roslaunch-logs命令指定日志的输出路径。
ros日志显示输出的级别
DEBUG:输出程序正常运行需要的信息
Information that you never need to see if the system is working properly. Examples:
"Received a message on topic X from caller Y"
"Sent 20 bytes on socket 9".
INFO:输出大量用户需要的信息
Small amounts of information that may be useful to a user. Examples:
"Node initialized"
"Advertised on topic X with message type Y"
"New subscriber to topic X: Y"
WARN:输出警告,或许影响程序的应用,但系统仍处于可控的预期状态
Information that the user may find alarming, and may affect the output of the application, but is part of the expected working of the system. Examples:
"Could not load configuration file from <path>. Using defaults."
ERROR:输出严重错误(但错误可恢复)
Something serious (but recoverable) has gone wrong. Examples:
"Haven't received an update on topic X for 10 seconds. Stopping robot until X continues broadcasting."
"Received unexpected NaN value in transform X. Skipping..."
FATAL:输出不可恢复的崩溃式错误
Something unrecoverable has happened. Examples:
"Motors have caught fire!"
ros中改变日志显示输出的级别设置
代码中配置
#include <ros/console.h>
if( ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug) ) {
ros::console::notifyLoggerLevelsChanged();
}
或
#include <log4cxx/logger.h>
log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->setLevel(
ros::console::g_level_lookup[ros::console::levels::Debug]);
ros::console::notifyLoggerLevelsChanged();
rqt界面配置
rosrun rqt_logger_level rqt_logger_level
rosrun rqt_console rqt_console
terminal终端界面配置
rosservice call /node-name/set_logger_level rospackage-name level
- set_logger_level服务由各个节点自动提供;
- node-name 期望设置日志级别的节点名称;
- package-name 拥有这个节点的 package 名称;
- level 是五个级别中的一个。
config文件中配置
可以在launch 文件里指定一个config 文件, 在这个 config 文件里制定哪些pkg 输出什么级别的log
示例rosconsole.config配置如下:
# Set the default ros output to warning and higher
log4j.logger.ros=WARN
# Override my_package to output everything
log4j.logger.ros.move_base=DEBUG # WARN INFO ...
在launch 文件里添加如下配置:
<env name="ROSCONSOLE_CONFIG_FILE"
value="_myfolder_path_/rosconsole.config"/> //_myfolder_path_是rosconsole.config 所在的文件夹路径
可参考:
ROS中log4j的学习记录_gglin的博客-CSDN博客 进行详细配置。