How to get a description of a message
As I learn ROS, I find often myself, for testing purposes, using the command line to send messages, send action goas, etc. The thing I struggle the most is how to find a description of how a message's structure should be.
For example I have the following actions available:
$ ros2 action list -t
/FollowWaypoints [nav2msgs/action/FollowWaypoints]
/backup [nav2_msgs/action/BackUp]
To send a goal to one of those actions I'll have:
$ ros2 action sendgoal /FollowWaypoints nav2msgs/action/FollowWaypoints "{????}"
How am I supposed to know how to populate the ???? and what fields are there?
Asked by guidout on 2023-06-13 21:08:22 UTC
Answers
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\
Asked by 130s on 2023-06-14 06:09:29 UTC
Comments
The output is not as nice as it could be, but doesn't auto-complete help here?
Asked by gvdhoorn on 2023-06-14 06:26:48 UTC
For a complexed definition, however, I found it way too difficult IMO.
as I wrote: the output is not as nice as it could be ..
Asked by gvdhoorn on 2023-06-14 08:53:42 UTC
Comments
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/msg/Path
, and thePath
message has a field calledposes
ofAsked by sonal on 2023-06-14 07:24:40 UTC
Is this ChatGPT?
Asked by gvdhoorn on 2023-06-14 08:53:13 UTC