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

rostopic echo with launch file

asked 2013-07-30 13:55:38 -0600

Maytheewat gravatar image

Hello,

I would like to do something like this

rostopic echo -p /mytopic > outputfile.txt

with the launch file

Hence, I wrote this in the launch file

<node name="output_topic1" pkg="rostopic" type="rostopic" output="screen" args="echo -p /mytopic > outputfile.txt">
</node>

However, it doesn't work and give me an error like this

Usage: rostopic echo [options] /topic

rostopic: error: you may only specify one input topic

[output_topic1-8] process has died [pid 11643, exit code 2, cmd /opt/ros/groovy/lib/rostopic/rostopic echo -p /mytopic > outputfile.txt __name:=output_topic1 __log:=/home/user/.ros/log/edae921e-f970-11e2-be82-14feb5b7467c/output_topic1-8.log].
log file: /home/user/.ros/log/edae921e-f970-11e2-be82-14feb5b7467c/output_topic1-8*.log
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-03-28 18:16:32 -0600

Maytheewat gravatar image

updated 2016-03-28 18:17:14 -0600

Hey guys,

I am very sorry, I haven't check this for a while. I am no longer using ROS. I believe this was working for me three years ago.

<launch>
  <arg name ="file_name" default="your_bag_file.bag"/>
  <arg name ="dest_path" default="path_to_the_destination"/>
  <arg name ="topic1" default="/topic_name_1"/>
  <arg name ="topic2" default="/topic_name_2"/>
  <arg name ="topic3" default="/topic_name_3"/>
  <arg name ="topic4" default="/topic_name_4"/>
  <node name ="recorder" pkg="rosbag" type="record" output="screen" args="-O $(arg dest_path)/$(arg file_name) $(arg topic1) $(arg topic2) $(arg topic3) $(arg topic4)">
  </node>
</launch>

@Druff @atp @Andrew.A

edit flag offensive delete link more

Comments

So....I guess I didn't really manage to get .txt file directly out from the topic(s)

Maytheewat gravatar image Maytheewat  ( 2016-03-28 18:24:49 -0600 )edit
1

answered 2013-07-30 18:21:42 -0600

I haven't used rostopic echo in launch file, but i feel that "type" parameter should have value "echo" and then args should be topic name.

edit flag offensive delete link more

Comments

1

if you start rostopic via rosrun, the command is "rosrun rostopic rostopic echo <mytopic>" so the type is rostopic and the args should be echo, have you tried it without the "> outputfile.txt" ? Does it work then ?

pkohout gravatar image pkohout  ( 2013-07-30 23:32:16 -0600 )edit

I haven't tried it but I feel that ">output.txt" is a very generic command used to store the contents published on terminal into a file. Therefore roslaunch is not accepting it.

ayush_dewan gravatar image ayush_dewan  ( 2013-07-31 01:18:06 -0600 )edit

@ayush_dewan that's mean there's no way I could do this in roslaunch? @coon It works without the "> outputfile.txt", I mean it runs without error but I'm not sure if it print anything out to the terminal

Maytheewat gravatar image Maytheewat  ( 2013-07-31 01:43:59 -0600 )edit

@coon@Maytheewat Sorry I am unable to test this right now, so I am not certain about my claim. Since the objective is to store contents of a topic in file, so instead of using rostopic echo write a simple subscriber file ans then store the contents in a file.

ayush_dewan gravatar image ayush_dewan  ( 2013-07-31 01:53:25 -0600 )edit

@Maytheewat Hi, did you eventually manage to get this working? I'm also looking at a similar way to write contents from a published topic to a file.

Andrew.A gravatar image Andrew.A  ( 2014-05-26 16:53:50 -0600 )edit

I'm interested in this as well.

atp gravatar image atp  ( 2015-10-29 10:31:14 -0600 )edit

I am also very much interested

Borob gravatar image Borob  ( 2016-03-28 15:43:58 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2013-07-30 13:55:38 -0600

Seen: 4,884 times

Last updated: Mar 28 '16