ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
745 stars 911 forks source link

rostopic pub can not parse a nested message format with spaces and indets from roslaunch #2349

Open robograffitti opened 9 months ago

robograffitti commented 9 months ago

When I tried to use rostopic pub from roslaunch, I found that rostopic pub could not parse a nested message format with spaces and indents.

But, it depends on depth of nests in a message.

For example, this one is OK: <node name="header_publisher" pkg="rostopic" type="rostopic" args="pub -s /header std_msgs/Header &quot;{'seq': 0, 'stamp':{'secs': 0, 'nsecs': 0}, 'frame_id':'map'}&quot;" />

However, this one does not work if I put any spaces:

  <node name="initialpose_publisher" pkg="rostopic" type="rostopic" output="screen"
    launch-prefix="bash -c 'sleep $(arg node_start_delay); $0 $@' "
        args="pub -s /initialpose geometry_msgs/PoseWithCovarianceStamped &quot;{'header':{'seq':0,'stamp':{'secs':0,'nsecs':0},'frame_id':'map'},'pose':{'pose':{'position':{'x':0.0,'y':0.0,'z':0.0},'orientation':{'x':0.0,'y':0.0,'z':0.0,'w':1.0}},'covariance':[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]}}&quot;" />

The codes above is the working ver. When I placed some spaces and indents to improve its readability, it caused the error below.

Any work around?

Thanks.

===== Error Log =====

process[initialpose_publisher-5]: started with pid [73296] Usage: rostopic pub /topic type [args...]

rostopic: error: Argument error: while parsing a flow node expected the node content, but found '' in "", line 1, column 2: { ^ [initialpose_publisher-5] process has died [pid 73296, exit code 2, cmd bash -c sleep 1.0; $0 $@ /opt/ros/noetic/lib/rostopic/rostopic pub -s /initialpose geometry_msgs/PoseWithCovarianceStamped { 'header': { 'seq': 0, 'stamp': { 'secs': 0, 'nsecs': 0 }, 'frame_id': 'map' }, 'pose': { 'pose': { 'position': { 'x': 0.0, 'y': 0.0, 'z': 0.0 }, 'orientation': { 'x': 0.0, 'y': 0.0, 'z': 0.0, 'w': 1.0 } }, 'covariance': [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] } } __name:=initialpose_publisher __log:=/home/y-tanaka/.ros/log/78b350fe-5ba2-11ee-b6d5-ef45c49d4694/initialpose_publisher-5.log]. log file: /home/y-tanaka/.ros/log/78b350fe-5ba2-11ee-b6d5-ef45c49d4694/initialpose_publisher-5*.log