Repository navigation
Closed
Description
Bug report
Required Info:
- Operating System:
- Ubuntu 20.04
- Installation type:
- binaries
- Version or commit hash:
- foxy
- DDS implementation:
- Cyclone DDS
- Client library (if applicable):
- rclpy
Steps to reproduce issue
Run following commands with Cyclone DDS
# clone sample python code with destroying publisher
mkdir -p ~/test_ws/src
cd ~/test_ws/src
git clone --single-branch --branch destroy_publisher https://github.com/mitsudome-r/examples
# build
cd ~/test_ws
colcon build
# run sample node
ros2 run examples_rclpy_minimal_publisher publisher_local_function
Expected behavior
Node runs, and you don't see the /topic in the publisher when you check with ros2 node info /minimal_publisher.
Actual behavior
Node shuts down with the following error
[INFO] [1617372037.108382091] [minimal_publisher]: Publishing: "Hello World: 0"
Traceback (most recent call last):
File "/home/mitsudome-r/test_ws/install/examples_rclpy_minimal_publisher/lib/examples_rclpy_minimal_publisher/publisher_local_function", line 11, in <module>
load_entry_point('examples-rclpy-minimal-publisher==0.9.4', 'console_scripts', 'publisher_local_function')()
File "/home/mitsudome-r/test_ws/install/examples_rclpy_minimal_publisher/lib/python3.8/site-packages/examples_rclpy_minimal_publisher/publisher_local_function.py", line 35, in main
rclpy.spin(node)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/__init__.py", line 191, in spin
executor.spin_once()
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 703, in spin_once
handler, entity, node = self.wait_for_ready_callbacks(timeout_sec=timeout_sec)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 689, in wait_for_ready_callbacks
return next(self._cb_iter)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 583, in _wait_for_ready_callbacks
waitable.add_to_wait_set(wait_set)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/qos_event.py", line 177, in add_to_wait_set
with self._event_handle as event_capsule:
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/handle.py", line 124, in __enter__
return self._get_capsule()
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/handle.py", line 106, in _get_capsule
raise InvalidHandle('Tried to use a handle that has been destroyed.')
rclpy.handle.InvalidHandle: Tried to use a handle that has been destroyed.
Additional information
Relevant code is located here within the forked repo: https://github.com/mitsudome-r/examples/blob/master/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_local_function.py
This does not occur with FastRTPS and only occurs when I switch to Cyclone DDS so I'm doubting it is something to do with rmw_cyclonedds implementation.
Metadata
Metadata
Assignees
Labels
No labels
Activity
eboasson commentedon Apr 2, 2021
Hi @mitsudome-r, the problem is that with Cyclone
rclpyadds a publisher event to set of waitables for the wait set that spin eventually uses, but it doesn't remove it from that set when the publisher is destroyed. With Fast-RTPS it never adds such an event, and so there is nothing to remove and all goes well.If you would like to see this for yourself, I patched
ros2/rclpy/rclpy/rclpy/node.pylike this:and
ros2/rclpy/rclpy/rclpy/qos_event.py:and then the difference between the outputs is:
Cyclone
As you can see, the
publisher.destroy()operation in your reproducer never got executed. So that's where things go awry.FastRTPS
This never adds a waitable in
create_publisher. The reason is that you are getting the default set of event handlers, which is the "incompatible QoS" notification if it is supported by the RMW layer. And where Cyclone implements that one, FastRTPS doesn't.I don't know how to move this to
rclpy, but that's where this problem belongs.sloretz commentedon Apr 7, 2021
@mitsudome-r would you mind checking if #761 fixes this issue? It sounds like it might from @eboasson's investigation.
clalancette commentedon Apr 22, 2021
I'm going to go ahead and assume that #761 fixed this issue, and close it. If that is not the case please feel free to reopen.
suurjaak commentedon Feb 9, 2022
#761 targets Galactic only. Is this going to get fixed in Foxy?