suurjaak / rosros

Simple unified interface to ROS1 / ROS2 Python API
Other
17 stars 0 forks source link

init_node failing under ros2 #2

Open mark-goodall opened 3 hours ago

mark-goodall commented 3 hours ago

I get the following error, and the same error if I have rosros imported but try to do the same thing with rclpy afterwards in the same python session, but it works perfectly if I just do the equivalent commands with rclpy in a fresh session.

>>> import rosros
>>> n = rosros.init_node("foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.12/dist-packages/rosros/core.py", line 53, in init_node
    return (ros1.init_node if ros1 else ros2.init_node)(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/rosros/ros2.py", line 612, in init_node
    NODE = rclpy.create_node(name, namespace=namespace, enable_rosout=enable_rosout,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/__init__.py", line 180, in create_node
    return Node(
           ^^^^^
  File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/node.py", line 245, in __init__
    self._type_description_service = TypeDescriptionService(self)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/type_description_service.py", line 74, in __init__
    self._start_service()
  File "/opt/ros/jazzy/lib/python3.12/site-packages/rclpy/type_description_service.py", line 88, in _start_service
    service = Service(
              ^^^^^^^^
TypeError: Service__init() got an unexpected keyword argument 'service_impl'
suurjaak commented 3 hours ago

Getting the error afterwards with rclpy in the same Python session is expected, as rosros monkey-patches rclpy's API.

rosros has not been tested under ROS 2 Jazzy; seems there have incompatible changes. I will look into this.