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

Start rostopic echo within launch?

asked 2012-04-29 02:37:24 -0500

rascal gravatar image

Hi All!

I want to save data with "rostopic echo -p > filname" like shown here: link text

Is it possible to start echo recording with my launch file and how? Is there any other way to record and import data to matlab in a convenient way? Thx for help!!!


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-04-29 03:53:16 -0500

Thomas gravatar image

updated 2013-04-02 18:26:35 -0500

One solution would be to wrap this call into a python node for instance system.exec and the subprocess module (on This node can then be started by a roslaunch file.

However, I would highly recommend that you use rosbag instead, this is a much more reliable tool that rostopic. For instance you can do:

  <node pkg="rosbag" type="rosbag" name="rosbag_record"
    args="record -o /tmp/slam-map /wide/left/image_raw /wide/left/camera_info /wide/right/image_raw /wide/right/camera_info /rosout"/>

Here you will have in /tmp a rosbag file beginning with slam-map followed by the current date and time.

It is then quite straightforward to convert a file to a csv file which can then be read by matlab or whatever 3rd party tool you use. See the rosbag API to know how to do so. I also have written a converter rosbag to csv, it is not in a public repository but if you are interested I can post it here.

edit flag offensive delete link more


Hello, sir, I am new in ROS, I am wondering how to covert a bag file into csv, could you please give me more hint? please! Thank you!

Holton gravatar image Holton  ( 2013-04-16 16:01:38 -0500 )edit

answered 2013-12-01 04:36:28 -0500

PabloPM gravatar image

updated 2013-12-01 04:39:27 -0500

Thanks Thomas for your post, it helped me too, but there is one more thing i still would like to understand, in the question rascal asked for running a rostopic echo from a launch, you answered that.

But notice in the question example rascal used a filename output specification (for directory and file name), for example i can use:

$rostopic echo /fix>/home/user/directory/filename.txt

and it will write the messages in the specified directory, is there any way I can run the rostopic echo from a launch like the one you gave, but specifing also the output file directory? Personally I would like to output addicional messages with output="screen" and output topic messages in the .txt file specified in the directory but im not able to find the way to output the file in a specified directory

Thank you very much,

Pablo Payno

edit flag offensive delete link more

Question Tools


Asked: 2012-04-29 02:37:24 -0500

Seen: 1,624 times

Last updated: Dec 01 '13