Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ros2 topic echo does not support messages generated directly from IDL #277

Open
davidhodo opened this issue Jun 8, 2019 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@davidhodo
Copy link

davidhodo commented Jun 8, 2019

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'.

@dirk-thomas
Copy link
Member

Thanks for reporting this. #223 described s new command which should be able to handle all kinds including .idl based interfaces.

@dirk-thomas dirk-thomas added the enhancement New feature or request label Jun 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants