Prepend ROS_INFO output from launch file

asked 2020-03-19 16:53:13 -0600

tdoe321 gravatar image

Hello, I am just getting into writing Launch Files after completing the beginner ROS tutorials. Specifically, I have completed the talker.cpp and listener.cpp tutorialsin ROS Melodic on Ubuntu 18.04.

To test my knowledge and understand more about ROS launch files, I created a simple .launch file that launches the talker and listener nodes:

  <node pkg="beginner_tutorials"  name="MyTalker" type="talker" output="screen"/>
  <node pkg="beginner_tutorials" name="MyListener" type="listener" output="screen"/>

It works just fine as is and outputs what I would expect, something like:

[ INFO] [1584654460.092186066]: hello world 3
[ INFO] [1584654460.092823471]: I heard: [hello world 3]
[ INFO] [1584654460.192495602]: hello world 4
[ INFO] [1584654460.195877263]: I heard: [hello world 4]
[ INFO] [1584654460.292623990]: hello world 5
[ INFO] [1584654460.296107995]: I heard: [hello world 5]

However, I was wondering if there is a way to automatically prepend these messages with the name of the node that output them. I think it would make debugging in the future easier for me if I knew who was publishing out these messages.

Obviously I could manually prepend each output statement inside the node with "Talker/" or "Listener/" or something like that, but I would like to have it be automatic if possible.

Any suggestions are welcome, thanks!

edit retag flag offensive close merge delete


This is a duplicate of #q258929. The answer there will show you how to do what you are asking about, with links to more information. You can customize the logging output in many different ways.

Thomas D gravatar image Thomas D  ( 2020-03-19 21:36:28 -0600 )edit