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

How to get a description of a message

asked 2023-06-13 21:08:22 -0500

guidout gravatar image

updated 2023-06-14 17:54:01 -0500

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 [nav2_msgs/action/FollowWaypoints]
/back_up [nav2_msgs/action/BackUp]

To send a goal to one of those actions I'll have:

$ ros2 action send_goal /FollowWaypoints nav2_msgs/action/FollowWaypoints "{????}"

How am I supposed to know how to populate the ???? and what fields are there?

edit retag flag offensive close merge delete

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 the nav2_msgs package. To find the structure and fields of this action message, you can use the ros2 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 called waypoints of type nav2_msgs ...(more)

sonal gravatar image sonal  ( 2023-06-14 07:24:40 -0500 )edit

Is this ChatGPT?

gvdhoorn gravatar image gvdhoorn  ( 2023-06-14 08:53:13 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-14 06:09:29 -0500

130s gravatar image

updated 2023-06-14 08:37:09 -0500

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\
edit flag offensive delete link more

Comments

The output is not as nice as it could be, but doesn't auto-complete help here?

gvdhoorn gravatar image gvdhoorn  ( 2023-06-14 06:26:48 -0500 )edit

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 ..

gvdhoorn gravatar image gvdhoorn  ( 2023-06-14 08:53:42 -0500 )edit
1

Yeah I know. FYI, I filed rcl#1079 to discuss improvement.

130s gravatar image 130s  ( 2023-06-15 01:14:43 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2023-06-13 21:08:22 -0500

Seen: 1,102 times

Last updated: Jun 14 '23