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

Writing the ros pub command inside the launch file

asked 2020-06-20 06:13:18 -0500

hrushi19 gravatar image

updated 2020-06-20 06:21:08 -0500

This is a command line command:

rostopic pub /rec_pose_as/goal path_exam/RecordOdomActionGoal "header:
  seq: 0
  stamp:
    secs: 0
    nsecs: 0
  frame_id: ''
goal_id:
  stamp:
    secs: 0
    nsecs: 0
  id: ''
goal: {}"

I want to use a launch file to run this command, so I do the following:

<node pkg='rostopic' type='rostopic' name='some_arbitary_name' args='pub /rec_pose_as/goal path_exam/RecordOdomActionGoal 
"header:
  seq: 0
  stamp:
    secs: 0
    nsecs: 0
  frame_id: ""
goal_id:
  stamp:
    secs: 0
    nsecs: 0
  id: ""
goal: {}"' />

But I get the error

rostopic: error: Argument error: mapping values are not allowed here
  in "<string>", line 1, column 14:
    header:   seq: 0   stamp:     secs: 0     nse ...

The error appears to come at seq: (the arrow points at colon)

What should be done? Would be grateful to any help

edit retag flag offensive close merge delete

Comments

Actually I found a way to escape this error, I copied the command to a bash script and ran the bash script from the command line, using https://answers.ros.org/question/5147...

hrushi19 gravatar image hrushi19  ( 2020-06-20 06:40:33 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-02-01 11:38:52 -0500

eeppii gravatar image

You need to pass the arguments in yaml format using {} instead of multiple lines:

The code for the arg must all go on one line:

<arg name="my_pose" default="'{header: {seq: 0, stamp: {secs: 0, nsecs: 0}, frame_id: ''}, goal_id: {stamp: {secs: 0.0, nsecs: 0.0}, id: ''}, goal: {}'"/>
<node pkg="rostopic"
  type="rostopic"
  name="some_arbitary_name"
  args="pub /rec_pose_as/goal path_exam/RecordOdomActionGoal $(arg my_pose)"/>
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-06-20 06:13:18 -0500

Seen: 936 times

Last updated: Jun 20 '20