Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
While rclpy is task-based and built with asynchronous support, its custom implementation imposes significant limitations and lacks integration with Python's asyncio ecosystem. Integrating rclpy nodes with modern asyncio based Python libraries like FastAPI and pyserial-asyncio is difficult and often forces developers into complex multi-threaded solutions.
Inspired by @sloretz's PR #971, this PR introduces an asyncio-based executor that runs nodes entirely on the asyncio event loop, that has become the de facto standard for IO programming in the Python community.
Current Status
This is a POC implementation demonstrating the feasibility of an asyncio executor.
Known limitations include:
KeyboardInterupt
Key Architectural Decisions
Before proceeding with a complete implementation, input on several architectural choices is needed:
asyncio.run_in_executor
._wait_for_ready_callbacks
.Future
objects: do we move entirely to the asyncio future, improve the rclpy Future to support asyncio (yield self), or replicate the asyncio approach of executor.create_future()?I believe that this PR has the potential to be a big game changer for rclpy, enabling many new applications and improving the performance of rclpy nodes.
Looking forward to your feedback.