Message template autocompletion broken
See original GitHub issueWhen publishing a topic via ros2 topic pub
or calling a service via ros2 service call
the tab completion for the fields of the message is broken. The completion for the topic and message type works fine. The issue seems to be different between zsh and bash.
In zsh: The field of the message are all handled are possible cli parameters that can be autocompleted pressing tab iterates through the fields. Each of the fields has its escaped indentation in the beginning and is individually selectable. Creating a valid message is impossible even for small msgs. Example:
🐋 /home/florian/Projekt/bitbots/colcon_ws ros2 topic pub /camera_info sensor_msgs/msg/CameraInfo -\ 0.0\
-\ 0.0\ \ \ do_rectify:\ false\ --keep-alive p:\ --qos-reliability \ \ stamp:\ width:\ 0\
-1 \ \ frame_id:\ \'\'\ -n --print -r -t \ \ x_offset:\ 0\
binning_x:\ 0\ header:\ \ \ \ \ nanosec:\ 0\ --qos-depth r:\ --times \ \ y_offset:\ 0\
binning_y:\ 0\ \ \ height:\ 0\ --node-name --qos-durability --rate -w
d:\ []\ height:\ 0\ --once --qos-history roi:\ --wait-matching-subscriptions
distortion_model:\ \'\'\ k:\ -p --qos-profile \ \ \ \ sec:\ 0\ \ \ width:\ 0\
In bash: Bash looks overall better as the message template is printed as one piece, but contains many escape characters. Example:
[florian@flovat colcon_ws]$ ros2 topic pub /camera_info sensor_msgs/msg/CameraInfo
-1
header:\^J\ \ stamp:\^J\ \ \ \ sec:\ 0\^J\ \ \ \ nanosec:\ 0\^J\ \ frame_id:\ \'\'\^Jheight:\ 0\^Jwidth:\ 0\^Jdistortion_model:\ \'\'\^Jd:\ []\^Jk:\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^Jr:\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^Jp:\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^J-\ 0.0\^Jbinning_x:\ 0\^Jbinning_y:\ 0\^Jroi:\^J\ \ x_offset:\ 0\^J\ \ y_offset:\ 0\^J\ \ height:\ 0\^J\ \ width:\ 0\^J\ \ do_rectify:\ false\
--keep-alive
-n
--node-name
--once
-p
--print
--qos-depth
--qos-durability
--qos-history
--qos-profile
--qos-reliability
-r
--rate
-t
--times
-w
--wait-matching-subscriptions
[florian@flovat colcon_ws]$ ros2 topic pub /camera_info sensor_msgs/msg/CameraInfo
I observed this behavior on all ros2 machines I have used so far, making the cli unusable for publishing topics.
Bug report
Required Info:
- Operating System:
- Ubuntu 22.04 LTS
- Installation type:
- binaries
- Version or commit hash:
- 0.19.0-1jammy.20220711.162709
- DDS implementation:
- Cyclone & FastDDS
Steps to reproduce issue
- source your terminal (zsh or bash)
- type
ros2 topic pub /camera_info sensor_msgs/msg/CameraInfo
and pressTAB
Expected behavior
A nicely formatted and editable string containing the message fields with their defaults should appear.
Actual behavior
Either the message is split and autocompleted in pieces (zsh) or cleaner (like in ros1) (bash)
Implementation considerations
I am not familiar with terminal formatting.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
So this isn’t ideal, but at least in bash if you start with a
"
, and then the first letter of the message, then autocompletion works as expected:It would be fantastic to figure out how to do that by default, so we don’t need those beginning two letters.
True. This even seems to work in Windows.
I’d be for adding a mode like this; I think it would be easier to use. I don’t necessarily think we should make it the default (it is not useful for scripting), but for manual interaction it would be pretty cool.