launch file with nested quotes
I want execute the following command:
rosservice call /gazebo/apply_joint_effort "joint_name: 'joint2' effort: 10.0 start_time: secs: 0 nsecs: 0 duration: secs: 10 nsecs: 0"
I can type this in the command line and everything works fine. Now suppose I need to execute this command not from terminal but from a launch file. I think I have to write something like this in my .launch file
<launch>
<node pkg="rosservice" type="rosservice" name="torque" args=
call /gazebo/apply_joint_effort "joint_name: 'joint2'
effort: 10.0
start_time:
secs: 0
nsecs: 0
duration:
secs: 10
nsecs: 0" />
</launch>
Of course in this way I have a mistake, because I should put quotes at the beginning and at the end of args. However I don't know how to do, since neither single quotes nor double quotes are available any more. If I add a couple of single/double quotes at the beginning and end it doesn't work. Any suggestions?
Strings don't need quotes in YAML (which is what the args essentially are) unless they contain spaces and it's unclear/ambiguous for the parser (ie: it cannot determine it from the context) where a string ends or starts.
So your
joint2
does not need quotes.Thanks gvdhoorn, this was helpful, but does not solve my problem completely. If I just remove quotes from 'joint2' I get the following error
Judging from this post I think it is an indentation problem, I tried several solution changing the spacings and the indentations but I always get errors.
As an example I add one of the versions of the launch file with changed indentations which did not work.
As I wrote earlier, it's all yaml. It's likely the parser is confused as in the end it just sees a long string (with a lot of whitespace) and a lot of illegal
key:value
combinations outside of a map. That's most likely the cause of the "mapping values not allowed here".I'd try the following syntax (called a "flow map"):
Note: this is all just a single line. There are no line-breaks nor indenting.
Now it works, thanks a lot!! :)
Note that at least #q265816 is a duplicate of your question.