How to publish a nested ROS2 message in a Linux Terminal? [closed]
In ROS1, when publishing a message in a terminal (such as in this question) when typing
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist
and hitting TAB, there would come up a suggestion with a template of the message structure into which one can easily fill out the desired data.
As far as I know, this doesn't workt in ROS2 (at least I couldn't figure out how). Furthermore, the syntax used in ROS does not always work for ROS2. Particularly, I couldn't figure out how to create a sequence of items (such as when having a message item of type TrafficSignSet[]
where TrafficSignSet
is another message type).
For example, this worked in ROS:
rostopic pub -l --once /topic my_msgs/TrafficSignSetList "
sign_set_list:
- id: 0
lane_ordered_signs:
- signs:
- {sign_type: 1, numeric_value: 200}
- signs: []
- signs: []
- signs:
- {sign_type: 1, numeric_value: 50}
ego_lane_index: 0
distance: 1000
valid: true"
Here, the nesting of messages of type TrafficSignSet
into a list of type TrafficSignSet[]
is given by indentation (or the dashes - or both?). In this case, sign_set_list
has only one element which is all of the stuff below.
But it yields an error in ROS2 (when called as ros2 topic pub -1 /topic my_msgs/TrafficSignSetList "..."
):
Failed to populate field 'sign_set_list': The 'sign_set_list' field must be a set or sequence and each value of type 'TrafficSignSet'
So how do I have to format sequences in a message when publishing form terminal?