Comments (3)
I see Executor::spin_until_future_complete()
, but not rclcpp::spin_until_future_complete()
. How is it meant to be used?
Using it in the main thread outside of an executor looks fine.
future = client.call(req)
executor.spin_until_future_complete(future)
if future.get() is not None:
print('Doing something with result %r', future.get())
Used in a callback done by a single threaded executor would be ok, except from the perspective of the main thread a spin_once()
call might handle multiple callbacks. From a multi threaded executor it would cause rcl_wait()
to be called on the same wait_set in multiple threads.
# main thread
while rclpy.ok()
# OK, though spin_once may handle more than 1 callback since the callback can spin
singleThreadedExecutor.spin_once()
# Not OK, this will dispatch the callback and call rcl_wait again,
# but the callback will also call spin which will call rcl_wait on the
# same wait set in another thread. rcl_wait() warns it is not thread safe.
# multiThreadedExecutor.spin_once()
# ...
# Subscriber callback
def listener_cb(self, response):
future = self.client.call(req)
# Executor has to be given to this object somehow
self.executor.spin_until_future_complete(future)
if future.get() is not None:
print('Doing something with result %r', future.get())
from rclpy.
Thoughts/notes regarding Future objects:
- Every Future needs a Task to set the result of the Future
- These need to be added to the Executor so it can schedule them
- This seems to be the reason but concurrent.futures and asyncio recommend using the executor to create futures
client.call(req)
could returns a future and keep a list of tasks. Executor would pull those tasks off the client object
- These need to be added to the Executor so it can schedule them
- Need to either subclass or create a custom Future class to support both multithreading and asynchronous execution
- concurrent.futures.Future is thread safe but not awaitable
- asyncio.Future is awaitable but not thread safe
- ...
from rclpy.
Connected to #170 because that implements almost everything in the description. #58 (asyncronous wait_for_service) will carry on on it's own.
from rclpy.
Related Issues (20)
- Clock documentation missing (rolling, iron) HOT 1
- `wait_for_message` sporadically fails on a msg_info that is None HOT 1
- StaticSingleThreadedExecutor HOT 3
- wait_for_message Accumulating CPU Load After Repeated Calls HOT 11
- Service client sometimes deadlock due to 'client will not receive response' of newly launched service server node HOT 9
- Log files are given base name `python3....` instead of node name HOT 3
- Humble has higher CPU usage compared to Foxy HOT 15
- Service Client wait_for_service incorrectly returns True HOT 4
- Ros2 Humble is installed on the Ubuntu 22.04 but I get error for no module named rclpy._rclpy_pybind11 while the package is installed (also rclpy is installed for Python 3.10 not Python 3.11) HOT 7
- Exception when instantiating ActionServer as part of ROS package tests HOT 2
- CMake Error (Non-existent Path) When Building From Source HOT 4
- Cannot log in ROS2 node after building with cython HOT 6
- ReadtheDocs page is missing a lot of documentation for API. HOT 7
- SIGINT signal on parent not terminated Turtlesim GUI application HOT 1
- ros2 topic HZ option is not predictable for report freq values when using default rmw_fastrtps_cpp rmw implementation HOT 3
- MultiThreadExecutor may throw exception after destroying subscription with non-default callback group
- Failed to send request: cannot publish data HOT 5
- Lifecycle node `Transition is not registered` exception kills node HOT 1
- debian12 humble source build: invalid use of incomplete type ‘PyFrameObject’
- failed to create domain error when spawning many python nodes at once from launch file with cyclonedds HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rclpy.