ros2cli icon indicating copy to clipboard operation
ros2cli copied to clipboard

Incorrect service autocompletion

Open audrow opened this issue 4 years ago • 1 comments

It seems that the service autocomplete is not behaving entirely correctly. I have moved this issue from https://github.com/ros/ros_tutorials/issues/136#issue-1040427338, opened by @kurshakuz.

Typing following command and trying autocompletion (tab) produces following output:

ros2 service call /spawn turtlesim/srv/Spawn 
-r
--rate
x:\ 0.0\^Jy:\ 0.0\^Jtheta:\ 0.0\^Jname:\ \'\'\

However, adding an x after above statement, produces different output:

ros2 service call /spawn turtlesim/srv/Spawn x
ros2 service call /spawn turtlesim/srv/Spawn x:\ 0.0\
y:\ 0.0\
theta:\ 0.0\
name:\ \'\'\ 

Executing any of them produces errors:

yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 1, column 8:
    x: 0.0y: 0.0theta: 0.0name: '' 
           ^

The expected and working example should look like the one below.

ros2 service call /spawn turtlesim/srv/Spawn "{x: 0.0, y: 0.0, theta: 0.0, name: ''}"

audrow avatar Dec 20 '21 20:12 audrow

Just to be clear, this:

-r
--rate
x:\ 0.0\^Jy:\ 0.0\^Jtheta:\ 0.0\^Jname:\ \'\'\

Is the same as what gets output on the command-line:

ros2 service call /spawn turtlesim/srv/Spawn x:\ 0.0\
y:\ 0.0\
theta:\ 0.0\
name:\ \'\'\ 

(that is, the ^J is the control character for the newline).

Further, it is actually possible to make this all work if you properly quote things:

ros2 service call /spawn turtlesim/srv/Spawn "x<TAB>

completes properly. I think this is an interaction between the shell and the tab completion. The only thing we could potentially do here is to somehow ensure that the tab-completed output always starts with a ", which would make this better.

clalancette avatar Jan 07 '22 15:01 clalancette