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

Changing Terminal Autocomplete for Custom Messages with Arrays

asked 2019-05-02 12:25:30 -0500

jbu gravatar image

updated 2019-05-02 12:26:31 -0500

I have a custom message with the following form that I would like to publish from the command line:

string type
float64[] trajectory
float64[] formation

When I publish other messages from the command line using rostopic pub, I can usually hit Tab after typing in the topic name, and the terminal will autocomplete the message type and give me a blank template message I can fill in. For example, when publishing a geometry_msgs/Twist command on the topic example_topic, I hit tab and this text is given to me by autocomplete:

$ rostopic pub -l /example_topic geometry_msgs/Twist "linear:
 x: 0.0
 y: 0.0
 z: 0.0
angular:
 x: 0.0
 y: 0.0
 z: 0.0"

I can then go back and change the "0.0" values to what I want.

However, when I try this autocomplete message with my custom message above, autocomplete gives me this:

$ rostopic pub -l /example_custom_topic my_package/custom_message "type: ''
trajectory:
- 0
formation:
- 0"

To me, this is an ambiguous layout for the array fields. When I try to fill in the type field with 'circular' and the "0" fields with arrays such as [1.0, 2.0, ...], I get the error [WARN] [1556817030.775878]: Inbound TCP/IP connection failed: <class 'struct.error'>: 'required argument is not a float' when writing 'circular'.

How can I change the autocomplete output for my custom message to a different format that is clearer and works? For example, the format in this answer worked perfectly fine for me and is less ambiguous. It would be very nice to have autocomplete give me this different format.

edit retag flag offensive close merge delete

Comments

Can you show us an exact command line you're trying to use?

You remove the - when you try to use the short-hand/one-line notation for the lists, correct?

gvdhoorn gravatar image gvdhoorn  ( 2019-05-02 15:34:02 -0500 )edit

No, I didn't remove the - characters at first. Just tried that now. Here's a more exact example which ended up working for me:

$ rostopic pub -r 10 /example_topic my_package/custom_message "type: 'some_string'
   trajectory: [1.0, 2.0, 3.0]
   formation: [1.0, 2.0, 3.0]"

This works just fine. However, when I try this instead,

$ rostopic pub -r 10 /leader_cmd rcomv_r1/MSRPA "type: 'circle'
   trajectory: 
   [1.0, 2.0, 3.0]
   formation: 
   [1.0, 2.0, 3.0]"

it throws an argument error. I can post the error if you'd like--I just don't want to clutter the comments. Ideally I would prefer the autocomplete being more like the first example so that minimal editing is required.

jbu gravatar image jbu  ( 2019-05-02 16:31:41 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2019-05-03 02:10:45 -0500

gvdhoorn gravatar image

updated 2019-05-08 04:11:38 -0500

Your first line (the one that works) is valid yaml. The second one isn't (I believe you can't put the value for a key on a different line).

Unfortunately I don't believe you can influence this. There is a way to configure PyYaml such that it uses the condensed version for lists, but I'm not sure that is being used in rostopic / the script that generates the auto-complete suggestions.


Edit: note also that geometry_msgs/Twist contains dictionaries, not plain arrays or lists. That is why you see the key-value pairs in the auto-complete suggestion.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-05-02 12:25:30 -0500

Seen: 609 times

Last updated: May 02 '19