[ROS2] Could not import 'rosidl_typesupport_c' for package

asked 2021-03-03 19:06:51 -0500

joaquingl gravatar image

I have a set of packages built using ament_python in a workspace and have been trying to create a separate package, built using ament-cmake to contain custom message and service types, as recommended by a couple of different posts I've found.

I'm using ROS2 Foxy on Ubuntu 20.04.

From colcon build --symlink--install, I get no errors and all packages, including the custom interface package I created, build successfully. But when I then ros2 run ot_ctrl tfpub to run a package using a custom interface I get the following error:

rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'qcm_interfaces'

What is happening is that one of the other python-built packages ot_ctrl attempt to reference a custom interface: OTCommand.srv inside my custom cmake-built interface package qcm_interfaces. So I have:

In package.xml:


In the node with the service tf_publisher.py:

from qcm_interfaces.srv import OTCommand
< within __init__ >
    self._move_srv = self.create_service(OTCommand, 'move', self.move_callback)

Here is my folder structure:

folder structure

And the full error output:

   Traceback (most recent call last):

  File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support
    return importlib.import_module(module_name, package=pkg_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'qcm_interfaces.qcm_interfaces_s__rosidl_typesupport_c'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/dev_ws/install/ot_ctrl/lib/ot_ctrl/tfpub", line 11, in <module>
    load_entry_point('ot-ctrl', 'console_scripts', 'tfpub')()
  File "/home/ubuntu/dev_ws/build/ot_ctrl/ot_ctrl/tf_publisher.py", line 215, in main
  File "/home/ubuntu/dev_ws/build/ot_ctrl/ot_ctrl/tf_publisher.py", line 147, in __init__
    self._move_srv = self.create_service(OTCommand, 'move', self.move_callback)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 1295, in create_service
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
  File "/home/ubuntu/dev_ws/install/qcm_interfaces/lib/python3.7/site-packages/qcm_interfaces/srv/_ot_command.py", line 298, in __import_type_support__
    module = import_type_support('qcm_interfaces')
  File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support
    raise UnsupportedTypeSupport(pkg_name)
rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'qcm_interfaces'
edit retag flag offensive close merge delete


+1, I ran into the same exact issue with the exact same output after following the ROS2 documentation tutorial explaining how to create custom messages. I found a post or two elsewhere mentioning dependencies in CMake or Package being at issue, but nothing I did produced any changes. I went as far as mimicking how ROS2's std_msgs package is setup, but the error persisted.

Spectre gravatar image Spectre  ( 2021-04-07 05:24:23 -0500 )edit

I wanted to update this as I've found a workaround since posting. In this issue, I was able to run my scripts in a docker container using the latest foxy image. We never found the difference between the container environment and my local install environment to see what was the source of the issue though. ¯_(ツ)_/¯

joaquingl gravatar image joaquingl  ( 2021-07-14 15:42:56 -0500 )edit