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

Revision history [back]

There are no spaces in your data which makes it an invalid YAML. I am quoting from the ROS 2 (Foxy) documentation:

It’s important to note that this argument needs to be input in YAML syntax.

ROS 2

We can use the following command in ROS 2:

ravi@dell:~$ ros2 topic pub --once /topic geometry_msgs/msg/Pose "{position: {x: 0.2, y: 0.1, z: 0.3}, orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0}}"
publisher: beginning loop
publishing #1: geometry_msgs.msg.Pose(position=geometry_msgs.msg.Point(x=0.2, y=0.1, z=0.3), orientation=geometry_msgs.msg.Quaternion(x=0.0, y=0.0, z=0.0, w=1.0))

ROS 1

Although the question uses ROS 2 commands, it is tagged with ROS 1, i.e., noetic. Therefore, below is the equivalent ROS 1 command:

ravi@dell:~$ rostopic pub --once /topic geometry_msgs/Pose "{position: {x: 0.2, y: 0.1, z: 0.3}, orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0}}"
publishing and latching message for 3.0 seconds

Feel free to check the ROS 1 documentation.