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