Changing Terminal Autocomplete for Custom Messages with Arrays
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.
Asked by jbu on 2019-05-02 12:25:30 UTC
Answers
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.
Asked by gvdhoorn on 2019-05-03 02:10:45 UTC
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?Asked by gvdhoorn on 2019-05-02 15:34:02 UTC
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:This works just fine. However, when I try this instead,
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.
Asked by jbu on 2019-05-02 16:31:41 UTC