0
$\begingroup$

I am not able to find out why I receive the ROS2 error ....

[rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'tutorial_interfaces']

This shows up as a run time error. The code compiles fine.

I have ROS2 publisher/subscriber nodes running on another computer. I then took a working publisher to a new computer to only see it fail.

The old computer is running Ubunto 22.04 on a Raspberry Pi.
The new computer is running Ubunto 22.04 (Linux Mint) on Virtual Box/PC.

On the new computer, the identical source code fails with the above error. There is a custom message in its own package that is the root cause of the error. If I do not use the custom message, my code works fine.

I reduced both the custom message and publisher to minimal versions and still have the same problems. I followed a tutorial to create a custom message and use it in a seperate python node.

The below code can be made to fail by changing the word String to Num in the publisher....

import rclpy
from rclpy.node import Node

from std_msgs.msg import String

from tutorial_interfaces.msg import Num


class MinimalPublisher(Node):

    def __init__(self):
        super().__init__('minimal_publisher')
        self.publisher_ = self.create_publisher(String, 'topic', 10)
        timer_period = 0.5  # seconds
        self.timer = self.create_timer(timer_period, self.timer_callback)
        self.i = 0

    def timer_callback(self):
        msg = String()
        msg.data = 'Hello World: %d' % self.i
        self.publisher_.publish(msg)
        self.get_logger().info('Publishing: "%s"' % msg.data)
        self.i += 1


def main(args=None):
    rclpy.init(args=args)

    minimal_publisher = MinimalPublisher()

    rclpy.spin(minimal_publisher)

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    minimal_publisher.destroy_node()
    rclpy.shutdown()


if __name__ == '__main__':
    main()

package.xml

For the message

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>tutorial_interfaces</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="[email protected]">jeffrey</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <buildtool_depend>rosidl_default_generators</buildtool_depend>
  <exec_depend>rosidl_default_runtime</exec_depend>
  <member_of_group>rosidl_interface_packages</member_of_group>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

CMakeLists.txt

cmake_minimum_required(VERSION 3.8)
project(tutorial_interfaces)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  set(ament_cmake_copyright_FOUND TRUE)
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

find_package(geometry_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)

rosidl_generate_interfaces(tutorial_interfaces
  "msg/Num.msg"
)

ament_package()


For my test node

setup.py

from setuptools import find_packages, setup

package_name = 'jemtstnode'

setup(
    name=package_name,
    version='0.0.0',
    packages=find_packages(exclude=['test']),
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='jeffrey',
    maintainer_email='[email protected]',
    description='TODO: Package description',
    license='TODO: License declaration',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
            'jeffTstNode = jemtstnode.jefPub:main',
        ],
    },
)

package.xml

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>jemtstnode</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="[email protected]">jeffrey</maintainer>
  <license>TODO: License declaration</license>

  <depend>tutorial_interfaces</depend>
  <depend>rclpy</depend>
  <depend>std_msgs</depend>
  <depend>tutorial_interfaces</depend>

  <test_depend>ament_copyright</test_depend>
  <test_depend>ament_flake8</test_depend>
  <test_depend>ament_pep257</test_depend>
  <test_depend>python3-pytest</test_depend>

  <export>
    <build_type>ament_python</build_type>
  </export>
</package>


_________________________________
 
 Please advise what might be going on here and how I can best debug.  The tool `ros2 doctor --report` says that ros2 is working correctly. 



$\endgroup$
1

1 Answer 1

1
$\begingroup$

I have found a solution and it exactly as Lucas (above in comment) referred me to. When I deactivated conda, everything worked as expected. I need to spend more time on my own learning about the interactions between conda and my ros2 build. I realize it is probably a python conflict. Of course, being very new doesn't help. Anyways, if you ever have this issue, start looking at conda problems

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.