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

Autocompletion for ros2 topic pub and ros2 service call does not work

asked 2021-01-21 01:15:25 -0600

updated 2021-02-17 02:16:27 -0600

gvdhoorn gravatar image

Autocompletion for ros2 topic pub and ros2 service call (and presumably ros2 action send_goal also) does not work properly.

$ ros2 topic pub /turtle1/cmd_vel [tab] -> linear:\^J\ \ x:\ 0.0\^J\ \ y:\ 0.0\^J\ \ z:\ 0.0\^Jangular:\^J\ \ x:\ 0.0\^J\ \ y:\ 0.0\^J\ \ z:\ 0.0\

$ ros2 service call /turtle1/set_pen turtlesim/srv/SetPen [tab] -> r:\ 0\^Jg:\ 0\^Jb:\ 0\^Jwidth:\ 0\^J\'off\':\ 0\
edit retag flag offensive close merge delete

Comments

Ah, yes. I too am quite annoyed by this. If you're wanting to know how to type this, it would be like this: ros2 topic pub /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}"

As for why this doesn't happen when you tab complete, however, that's likely quite a bit more involved.

allenh1 gravatar image allenh1  ( 2021-01-21 18:19:18 -0600 )edit

Is this fixed? Because I'm currently struggling with this problem. Pretty annoying to manually try to perform the call with correct syntax.

ahopsu gravatar image ahopsu  ( 2021-08-19 10:05:11 -0600 )edit

It seems to work when you have typed the first quation mark " and at least the first letter of the first field. Instead of doing this as in the original problem:

ros2 topic pub /turtle1/cmd_vel [tab]

Do this:

ros2 topic pub /turtle1/cmd_vel "l [tab]

It should now show the message in this format:

"linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}"

Notice, that there is not starting { and ending } wave brackets, at least it works without those

ahopsu gravatar image ahopsu  ( 2021-08-19 10:21:41 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-07-13 09:03:09 -0600

rajmohan747 gravatar image

updated 2022-07-13 09:03:35 -0600

I have faced a similar issue in the past. The following procedure saved me from those

Install the colcon extensions using the command:

sudo apt install python3-colcon-common-extensions

Now open the .bashrc file and add the following line to it

source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash

Now either source the .bashrc once more or open a new terminal. On typing ro2 <tab>, the autocompletion should happen.

Good luck..!!

edit flag offensive delete link more

Comments

Seems to work even without adding "source ..." to the basrc. It seems to be sourced after installation automatically with the workspace.

moooeeeep gravatar image moooeeeep  ( 2023-02-09 05:08:53 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2021-01-21 01:15:25 -0600

Seen: 2,011 times

Last updated: Jul 13 '22