-
Notifications
You must be signed in to change notification settings - Fork 3
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
intermittent error generated in wait_for_message #60
Comments
Here is another example from a more minimal script. The call to get_floor_robot_gripper_state() worked a few times after the sim started, then failed as shown here. The top section of this message, enclosed in >>> ... <<< appeared with every call but things progressed normally . However, eventually a call generated the bottom section as well. The class here is included with the bdai ros_utilities call to graph() in the script that instantiates all the nodes.
[simple_bdai.py-1] |
@mhidalgo-bdai any ideas? |
@dan9thsense I would suspect misuse. Errors indicate some ROS 2 state is getting clobbered. Would you mind showing that minimal script? Note to myself: watch all activities on this repo. I was not notified when these issues were opened. |
That was the more minimal script. To get more, you would need to run the whole ARIAC/gazebo ROS2 sim. |
I see it uses |
ros_process.main occurs in a node that instantiates the Gripper class shown above. It is created inside a graph method that is then run, as per the examples. I didn't know that wait_for_message could take a node as a parameter. Is there an example of that I missed? Looking at the source code, I see it can. In the script above, I tried replacing: msg = wait_for_message(VacuumGripperState, topic, timeout_sec=10.0) with: msg = wait_for_message(VacuumGripperState, topic, timeout_sec=10.0, node=self) but it doesn't seem to matter much: [simple_bdai.py-1] |
@dan9thsense it's hard to pinpoint where the issue is from code fragments. Like I said before (above?), the issue is that ROS 2 state is getting clobbered.
FWIW |
That's exactly where ros.process.main is located. There is only one main function and it decorates that. |
I mean destroyed. Hmm, on a closer look, why do you think this is caused by |
It's definitely associated with wait_for_message. It is never there without that. If I take out this one line of code:
the problem never occurs. Also, that same line generates the same problem in other nodes. In what way is the ros2 state being destroyed? Are you referring to this line:
Most of the other lines refer to spin_once, which I'm pretty sure is coming from ros_utilities since I'm not calling it at all in my code. I can give you more of the code if you want, such as the main function. |
@mhidalgo-bdai I took a look at the full code here (I know OP) and A few observations:
|
So, after some digging, I'm 95% sure this is a bug upstream. I couldn't make sense of the backtrace until I rediscovered subscriptions have QoS event handlers. I believe subscription destruction is racing with wait set construction. QoS event handlers are collected as waitables, which prevents destruction, but doesn't prevent destruction from being requested. Then, as soon as you hit If the above is correct, waitable support in We should open a ticket on https://github.com/ros2/rclpy. |
When calling bdai_ros2_wrappers.subscription.wait_for_message I am getting this error chain about 70% of the time. Sometimes the same code completes successfully.
The call is made like this (type and topic are correct, it runs successfully now and then):
from bdai_ros2_wrappers.subscription import wait_for_message
............
msg = wait_for_message(type, topic, timeout_sec=10.0)
[simple_bdai.py-1] Exception in thread Thread-1 (spin):
[simple_bdai.py-1] Traceback (most recent call last):
[simple_bdai.py-1] File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
[simple_bdai.py-1] self.run()
[simple_bdai.py-1] File "/usr/lib/python3.10/threading.py", line 953, in run
[simple_bdai.py-1] self._target(*self._args, **self._kwargs)
[simple_bdai.py-1] File "/opt/ros/iron/lib/python3.10/site-packages/rclpy/executors.py", line 295, in spin
[simple_bdai.py-1] self.spin_once()
[simple_bdai.py-1] File "/home/dbarry/ariac_ws/install/bdai_ros2_wrappers/lib/python3.10/site-packages/bdai_ros2_wrappers/utilities.py", line 55, in wrapper
[simple_bdai.py-1] return callable(*args, **kwargs)
[simple_bdai.py-1] File "/home/dbarry/ariac_ws/install/bdai_ros2_wrappers/lib/python3.10/site-packages/bdai_ros2_wrappers/executors.py", line 628, in spin_once
[simple_bdai.py-1] self._do_spin_once(timeout_sec)
[simple_bdai.py-1] File "/home/dbarry/ariac_ws/install/bdai_ros2_wrappers/lib/python3.10/site-packages/bdai_ros2_wrappers/executors.py", line 590, in _do_spin_once
[simple_bdai.py-1] task, entity, node = self.wait_for_ready_callbacks(*args, **kwargs)
[simple_bdai.py-1] File "/opt/ros/iron/lib/python3.10/site-packages/rclpy/executors.py", line 723, in wait_for_ready_callbacks
[simple_bdai.py-1] return next(self._cb_iter)
[simple_bdai.py-1] File "/opt/ros/iron/lib/python3.10/site-packages/rclpy/executors.py", line 617, in _wait_for_ready_callbacks
[simple_bdai.py-1] waitable.add_to_wait_set(wait_set)
[simple_bdai.py-1] File "/opt/ros/iron/lib/python3.10/site-packages/rclpy/event_handler.py", line 124, in add_to_wait_set
[simple_bdai.py-1] with self.__event:
[simple_bdai.py-1] rclpy._rclpy_pybind11.InvalidHandle: cannot use Destroyable because destruction was requested
The text was updated successfully, but these errors were encountered: