Skip to content
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

Problem using rclpy.spin_until_future_complete inside Python plugin #785

Open
angel-ayala opened this issue Jun 23, 2023 · 2 comments
Open
Milestone

Comments

@angel-ayala
Copy link
Contributor

I'm using the Emitter send_string service call inside the step() python method, and when using rclpy.spin_until_future_complete() occurs a deadlock since the future never gets done. Apparently is because the step() never ends and therefore, the driver step never finish it iteration.

A workaround for this was using a condition to check Future.done() at every step() call but that leads to a information delay.

Can this be done differently?

@ygoumaz
Copy link
Contributor

ygoumaz commented Jun 26, 2023

Are you using an asynchronous client call?

See https://docs.ros.org/en/humble/How-To-Guides/Sync-Vs-Async.html for more information. A solution using future.done() is also mentioned. I don't know any cleaner way to do it. I think I had tested the Emitter plugin when you submitted your PR and it was working fine. The delay shouldn't be over 1 timestep, or is it?

@angel-ayala
Copy link
Contributor Author

The issue happen when call the Emitter.send_string C++ service inside the python plugin, and according how the driver works seems to be that way since the rclpp::spin_some() happens after the execution of the python step() method and needs to use the future.done() method to check for the service status.
However, this behavior only allow to call Emitter.send_string service in one step yes, and the next step no, why? I'm not sure. Maybe is related to the moment when rclpp::spin_some() and rclpy.spin_once() are called, requiring to be sync.

However it seems to be an issue to use C++ and Python ROS node in the same controller and how the Nodes spin call are synced. Should the ROS nodes be running in a separated thread just as the ros2_supervisor works?

@ygoumaz ygoumaz added this to the 2023.1.2 milestone Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants