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

How to publish a nested ROS2 message in a Linux Terminal? [closed]

asked 2019-02-14 12:28:44 -0500

coenig gravatar image

updated 2019-02-15 02:56:11 -0500

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?

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by gvdhoorn
close date 2019-02-15 04:41:11.432684

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-02-15 02:55:02 -0500

coenig gravatar image

Apparently it's not yet possible to publish nested messages via command line: https://answers.ros.org/question/3042...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-02-14 12:28:44 -0500

Seen: 1,453 times

Last updated: Feb 15 '19