question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autocompletion for message contents broken since foxy

See original GitHub issue

Bug report

Required Info:

  • Operating System:
    • Ubuntu 20.04 / docker
  • Installation type:
    • Apt packages / prebuilt docker image
  • Version or commit hash:
    • ros-foxy-ros2topic: 0.9.7-1focal.20200804.003710
    • For the docker images:
$ docker image ls --no-trunc ros
REPOSITORY          TAG                 IMAGE ID                                                                  CREATED             SIZE
ros                 rolling             sha256:ab3c32fdab44aba3069366d90df5f212c1fb233fcd59bd04a16194f7e86aeef2   37 hours ago        722MB
ros                 foxy                sha256:896c8acbfce8030f2550980f38c11d4a33e1e52500ebe7b4ddc3a6a95f85bc05   37 hours ago        722MB
ros                 eloquent            sha256:e5483efb0d9505e6d4d84466d3a7bb78f48e625661abe2552c77eceddd3f8484   37 hours ago        829MB
  • DDS implementation:
    • Fast-RTPS
  • Client library (if applicable):
    • rclpy (?)

Steps to reproduce issue

Make sure the setup.bash is sources. Then try to publish a message using ros2 topic pub:

$ . /opt/ros/${ROS_DISTRO}/setup.bash
$ ros2 topic pub /cli_demo geometry_msgs/msg/Pose "po<tab>

Expected behavior

A complete template of the contents of the specified message appears:

$ ros2 topic pub /cli_demo geometry_msgs/msg/Pose "position:
  x: 0.0
  y: 0.0
  z: 0.0
orientation:
  x: 0.0
  y: 0.0
  z: 0.0
  w: 1.0"

This is what happens when using eloquent (verified using the mentioned docker image). In foxy this does not happen, neither in docker, nor in a local terminal where the installed apt packages are available. Same applies for the rolling docker image.

Actual behavior

No completion suggestion appear. When done without the double quote, the following happens:

$ ros2 topic pub /cli_demo geometry_msgs/msg/Pose position:\
\ \ x:\ 0.0\
\ \ y:\ 0.0\
\ \ z:\ 0.0\
orientation:\
\ \ x:\ 0.0\
\ \ y:\ 0.0\
\ \ z:\ 0.0\
\ \ w:\ 1.0\ 

Trying to use this format results in a yaml.scanner.ScannerError exception:

Traceback (most recent call last):
  File "/opt/ros/rolling/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.9.5', 'console_scripts', 'ros2')()
  File "/opt/ros/rolling/lib/python3.8/site-packages/ros2cli/cli.py", line 67, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/rolling/lib/python3.8/site-packages/ros2topic/command/topic.py", line 41, in main
    return extension.main(args=args)
  File "/opt/ros/rolling/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 93, in main
    return main(args)
  File "/opt/ros/rolling/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 103, in main
    return publisher(
  File "/opt/ros/rolling/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 126, in publisher
    values_dictionary = yaml.safe_load(values)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 162, in safe_load
    return load(stream, SafeLoader)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/lib/python3/dist-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 428, in parse_block_mapping_key
    if self.check_token(KeyToken):
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 577, in fetch_value
    raise ScannerError(None, None,
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 1, column 13:
    position:  x: 0.0  y: 0.0  z: 0.0orientation ... 

Additional information

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
doisygcommented, Feb 19, 2021

Just tried with quotes ros2 topic pub /cmd_vel geometry_msgs/msg/Twist ":

$ ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "
-1                                                                             --qos-durability
--keep-alive                                                                   --qos-history
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  --qos-profile
-n                                                                             --qos-reliability
--node-name                                                                    -r
--once                                                                         --rate
-p                                                                             -t
--print                                                                        --times
--qos-depth   

But if putting quote + l, it works ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "l:

ros2 topic pub /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"
2reactions
tanacar2002commented, Aug 3, 2022

The bug seems to be fixed for bash but I still face the same problem with zsh. Let’s say I wrote ros2 topic pub /mavros/setpoint_position/local geometry_msgs/msg/PoseStamped "h and hit tab, it would only complete the first field name, so the result would be ros2 topic pub /mavros/setpoint_position/local geometry_msgs/msg/PoseStamped "header: . Hitting tab more wouldn’t do anything more. If I switch to bash, then I get the expected result, which is ros2 topic pub /mavros/setpoint_position/local geometry_msgs/msg/PoseStamped "header: stamp: sec: 0 nanosec: 0 frame_id: '' pose: position: x: 0.0 y: 0.0 z: 0.0 orientation: x: 0.0 y: 0.0 z: 0.0 w: 1.0" My default shell is zsh and switching back to bash is doable but not preferable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Autocompletion for ros2 topic pub and ros2 service call does ...
Autocompletion for ros2 topic pub and ros2 service call (and presumably ros2 action send_goal also) does not work properly.
Read more >
Bug: Auto-complete doesn't work for Java in eclipse 2021-03
Since I use a Mac provided by NASA, I only have Java 1.8. So I fixed the ini file. But autocomplete doesn't work....
Read more >
Why bash disables autocompletion for some commands and ...
It often happens to me that bash disables auto completion for certain commands. This forces me to add random symbol to name of...
Read more >
fnaf 3 title - Ramozzi & Friends
Since I posted the fnaf 2 title screen, I have gotten a lot of requests to. ... Main Phantom Bonnie (Secret) Phantom Freddy...
Read more >
Auto-completion - Notepad++ User Manual
Notepad++ offers automatic completion of various sorts of text after you have entered an initial substring (or prefix), which can save you having...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found