I feel your pain. It's not well-documented IMO.
Sending Action goal with simpler goal definition is documented in the tutorial (docs.ros.org/humble):
ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "{theta: 1.57}"
For complexed interface definition, you just have to construct a dictionary for the goal definition you want to send. In my case I referred to ros2cli#59, which shows an example of ros2 topic
instead of ros2 action
, but I think (/hope) the syntax both CLI commands use is the same.
ros2 topic pub /chatter test_msgs/DynamicArrayNested "{primitive_values: [{string_value: 'foo', int8_value: 42}]}"
Update: In response to
doesn't auto-complete help here?
I do find it helpful, for simpler structure Interface. E.g. in this topic pub
verb case, it shows not just the value syntax but also shows options in addition.
# ros2 topic pub /linear_rail_controller/follow_joint_trajectory geometry_msgs/msg/Point <%double-tab here%>
--keep-alive --print --qos-history --rate -n -t
--node-name --qos-depth --qos-profile --times -p x:\ 0.0\^Jy:\ 0.0\^Jz:\ 0.0\
--once --qos-durability --qos-reliability -1 -r
For a complexed definition, however, I found it way too difficult IMO. E.g. control_msgs/action/FollowJointTrajectory (3.0.0), double-tabbing on CLI output looks like this, which is waaay too convoluted to comprehend IMO (though this may not be the best example as it entails Header
, which might typically be supposed to be auto-filled):
# ros2 action send_goal /node_nodonodo/follow_joint_trajectory control_msgs/action/FollowJointTrajectory
--feedback
-f
trajectory:\^J\ \ header:\^J\ \ \ \ stamp:\^J\ \ \ \ \ \ sec:\ 0\^J\ \ \ \ \ \ nanosec:\ 0\^J\ \ \ \ frame_id:\ \'\'\^J\ \ joint_names:\ []\^J\ \ points:\ []\^Jmulti_dof_trajectory:\^J\ \ header:\^J\ \ \ \ stamp:\^J\ \ \ \ \ \ sec:\ 0\^J\ \ \ \ \ \ nanosec:\ 0\^J\ \ \ \ frame_id:\ \'\'\^J\ \ joint_names:\ []\^J\ \ points:\ []\^Jpath_tolerance:\ []\^Jcomponent_path_tolerance:\ []\^Jgoal_tolerance:\ []\^Jcomponent_goal_tolerance:\ []\^Jgoal_time_tolerance:\^J\ \ sec:\ 0\^J\ \ nanosec:\ 0\
When working with ROS and sending messages or action goals through the command line, it's essential to have a clear understanding of the message structure and its fields. To find the description of a message's structure, you can refer to the message definition files in the ROS package that contains the message type you're working with.
In your case, you are working with the
/FollowWaypoints
action from thenav2_msgs
package. To find the structure and fields of this action message, you can use theros2 interface show
command followed by the message type:$ ros2 interface show nav2_msgs/action/FollowWaypoints
This command will display the details of the
FollowWaypoints
action message, including its fields and their data types. You can look for the specific fields you need to populate in the goal message.For example, if the
FollowWaypoints
action message has a field calledwaypoints
of typenav2_msgs ...
(more)Is this ChatGPT?