ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Print message from launch file

asked 2017-11-17 04:44:24 -0600

ravijoshi gravatar image

I am wondering if there is any way to print message from launch file. For example, I am calling a node from launch file and I do not want the user to terminate this process. Hence I simply want to print following:

Please keep this running in a separate tab.

Any workaround to achieve it? Thank you very much. Please note that I am using Python 2.7 in ROS Indigo on Ubuntu 14.04 LTS PC.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-11-17 11:17:23 -0600

lucasw gravatar image

updated 2017-11-17 11:19:26 -0600

rostopic echo:

<?xml version="1.0"?>
  <arg name="msg" default="Please keep this running in a separate tab." />
  <node name="pub_text" pkg="rostopic" type="rostopic"
     args="pub /msg std_msgs/String '$(arg msg)'"
     output="screen" />
  <node name="print_text" pkg="rostopic" type="rostopic"
     args="echo /msg" output="screen" />


data: Please keep this running in a separate tab.

Though maybe the data: is undesirable

Adding a -p to the echo yields:

1510939080429253101,Please keep this running in a separate tab.
edit flag offensive delete link more

answered 2017-11-17 07:26:44 -0600

updated 2017-11-17 09:22:12 -0600

I don't think it's possible to print text directly form the roslaunch xml (w/o passing it into a node as a param / arg).

Best solution would be to put

print("Please keep this running in a separate tab.")

in your node script.

In your *.launch script, if you set the node's output attribute to "screen", the message will be printed to the terminal window.

<node name="PrintToScreenNode_1" pkg="my_package" type="" output="screen"/>

Note: You can also start your nodes in their own separate terminal windows using the launch-prefix attribute.

<node name="PrintToScreenNode_2" pkg="my_package" type="" output="screen" launch-prefix="xterm -e"/>


Here's an example script that just prints to the terminal:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Name:
# Author: Joseph Coombe

# Uncomment lines 10, 13, 15 if you're running this node in its own separate
# terminal window. Otherwise the script will immediately exit and its terminal window will close.
#import rospy

def main():
    #rospy.init_node('print_to_screen', anonymous=True)
    print("Please keep this running in a separate tab.")

if __name__ == '__main__':

You'll want to un-comment the rospy lines if you're launching this script in its own terminal (by using the launch-prefix attribute in your *.launch file). Otherwise, it'll immediately exit and close its terminal window (and as a result nobody will see the message).

edit flag offensive delete link more


Thank you very much. I want to know, if it is possible to create with only following content and nothing else print("Please keep this running in a separate tab.")

ravijoshi gravatar image ravijoshi  ( 2017-11-17 08:57:50 -0600 )edit

@Ravi Joshi Yes. I've edited my answer with a simple example.

josephcoombe gravatar image josephcoombe  ( 2017-11-17 09:19:15 -0600 )edit

What about printing a value from inside the launch file, say an arg or param value? How can the python script access them and print?

hbaqueiro gravatar image hbaqueiro  ( 2018-11-08 09:29:07 -0600 )edit

Question Tools



Asked: 2017-11-17 04:44:24 -0600

Seen: 9,396 times

Last updated: Nov 17 '17