0
0

More than 1 year has passed since last update.

rospy.loginfo関数を使ってPrint

Last updated at Posted at 2021-10-26

rospy.loginfoを使用するとプリントされる情報に現在時間がつき便利なときがあります.

1,2,3という3つの数値をloginfoで出力するサンプルは以下のようになります.

loginfo.py
import rospy

rospy.init_node('loginfo')

r = rospy.Rate(10)
while not rospy.is_shutdown():

  rospy.loginfo("num: %s, %s, %s",1, 2, 3)

  r.sleep()

実行結果は以下です.

実行結果
[INFO] [1635289935.448486]: num: 1, 2, 3
[INFO] [1635289935.549028]: num: 1, 2, 3
[INFO] [1635289935.648756]: num: 1, 2, 3
[INFO] [1635289935.749015]: num: 1, 2, 3
[INFO] [1635289935.849047]: num: 1, 2, 3
...
  • other log level
rospy.logdebug(msg, *args)
rospy.logwarn(msg, *args)
rospy.loginfo(msg, *args)
rospy.logerr(msg, *args)
rospy.logfatal(msg, *args)

参考
現在時刻をloginfoで出力しているサンプルあり
http://wiki.ros.org/ja/rospy_tutorials/Tutorials/Logging

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0