ROS日志级别控制

31 篇文章 0 订阅

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博客  进行详细配置。

参考:

ros日志输出_Zhubingge的博客-CSDN博客_ros输出日志

ROS 中的日志 (log) 消息 - 简书

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值