ROS--7 Log信息

rospy.loginfo('GoToPositionRequest Received - j1:%s, j2:%s', req.joint_1, req.joint_2)

By default all logging messages for a node are written to the node's log file which can be found in ~/.ros/log or ROS_ROOT/log .

If roscore is running, you can use roscd to find log file directory by opening a new terminal window and typing:

roscd log

In this directory, you should see directories from runs of your ROS code, along with a latest directory with log files from the most recent run.

 

7.1 Logging levels and outputs

rospy.logdebug(...)
rospy.loginfo(...)
rospy.logwarn(...)
rospy.logerr(...)
rospy.logfatal(...)

All levels of logging messages are recorded in ROS log files, but some message levels may also be sent to Python stdout, Python stderr, or the ROS topic /rosout.

The loginfo messages are written to Python's stdout, while logwarnlogerr, and logfatal are written to Python's stderr by default. Additionally, loginfologwarnlogerr, and logfatal are written to /rosout.

More in http://wiki.ros.org/rospy/Overview/Logging

7.2 Filtering and saving log messages from /rosout

Note that for messages written to /rosout, you can see the messages in real time as your program is running by echoing:

rostopic echo /rosout

一般可以用grep来过滤有用信息

rostopic echo /rosout | grep insert_search_expression_here
rostopic echo /rosout | grep insert_search_expression_here > path_to_output/output.txt

7.3 Modifying message level sent to /rosout

To do this you must set the log_level attribute within the rospy.init_node code.

For example, if you'd like to allow logdebug messages to be written to /rosout, that can be done as follows:

rospy.init_node('my_node', log_level=rospy.DEBUG)

7.4 Modifying display of messages sent to stdout and stderr

It is also possible to change how messages to stdout and stderr are displayed or logged. Within a package's .launch file, the output attribute for a node tag can be set to "screen" or "log". The following table summarizes how the different output options change the display of the node's stdout and stderr messages:

For example, setting output="screen" for the look_away node in robot_spawn.launch will display both stdout and stderr messages in the screen:

 <!-- The look away node -->
  <node name="look_away" type="look_away" pkg="simple_arm" output="screen"/>

If the output attribute is left empty, the default is "log".

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值