ros2 / ros2/ros2cli

ros2 topic echo does not support messages generated directly from IDL

Open
#277 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
262
Forks
228
Avg merge
23h 15m
Merged PRs (30d)
12

Description

Bug report

  • Operating System:
    • MacOS 10.14.5 (Mojave)
  • Installation type:
    • Binaries
  • Version or commit hash:
    • Dashing
  • DDS implementation:
    • Fast-RTPS
Steps to reproduce issue

ROS2 topic echo currently hardcodes '.msg' for importing message python modules. Message packages created directly from idl files as supported in Dashing use a '.idl' name. Running 'ros2 topic echo' on a topic that uses a message generated from idl fails.

An example package that creates a simple string message using idl can be found at: ros2_idl_demo. Building the message (idl_msgs) and sample publisher (idl_pub) packages and then running ros2 run idl_pub idl_pub and ros2 topic echo /chatter results in a crash.

Expected behavior
---
var_string: 'ROS2: Hello'
---
var_string: 'ROS2: Hello'

Actual behavior
davidhodo@Davids-MacBook-Pro:idl_test_ws∫ ros2 topic echo /chatter
Traceback (most recent call last):
  File "/opt/ros/dashing/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.7.0', 'console_scripts', 'ros2')()
  File "/opt/ros/dashing/lib/python3.7/site-packages/ros2cli/cli.py", line 69, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/dashing/lib/python3.7/site-packages/ros2topic/command/topic.py", line 43, in main
    return extension.main(args=args)
  File "/opt/ros/dashing/lib/python3.7/site-packages/ros2topic/verb/echo.py", line 69, in main
    return main(args)
  File "/opt/ros/dashing/lib/python3.7/site-packages/ros2topic/verb/echo.py", line 79, in main
    node.node, args.topic_name, args.message_type, callback)
  File "/opt/ros/dashing/lib/python3.7/site-packages/ros2topic/verb/echo.py", line 106, in subscriber
    msg_module = import_message_type(topic_name, message_type)
  File "/opt/ros/dashing/lib/python3.7/site-packages/ros2topic/api/__init__.py", line 71, in import_message_type
    module = importlib.import_module(package_name + '.' + middle_module)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'idl_msgs.msg'
Additional information

The error comes from the import_message_type method in ros2topic/ros2topic/api/init.py. It currently hardcodes a middle_module name of '.msg'. For message packages created from idl this should be '.idl'.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ros2topic/ros2topic/api/init.py at import_message_type, where the message module name is currently hardcoded. Reproduce the issue with the linked ros2_idl_demo package and ros2 topic echo /chatter, then verify that an IDL-generated message imports successfully and produces the expected message output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.