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)
- KeyError in ActionServer._execute_goal HOT 5
- [Feature] Static Type Checking With ament_mypy HOT 1
- Added optional TimerInfo to timer callback
- :farmer: `test_guard_condition` failing consisntent in CycloneDDS HOT 2
- Add utility function to get datetime.datetime from Time HOT 1
- Decode ROS2 raw byte data using rclpy.serialization.deserialize_message HOT 3
- Rate object's destroy() does not destroy the underlying Timer object, leading to CPU usage explosion HOT 6
- Update the executor to not throw ExternalShutdownException
- Make nodes, publishers, subscriptions, services, clients, action servers, action clients Python context managers
- aarch64 cross compiling HOT 9
- Executors mishandle invalid waitables HOT 4
- context.on_shutdown is never called HOT 7
- Bad interaction between `torch.compile` and `MultiThreadedExecutor` HOT 1
- First Time Contributors Documentation (CONTRIBUTING.md) HOT 2
- Python message with uint32 Assertion `PyLong_Check(field)' failed HOT 2
- Memory leak in ActionServer. ```taken_data = self._handle.take_goal_request``` HOT 4
- [Bug] error when node created with rclpy.node.Node HOT 1
- Async tasks are processed in LIFO not FIFO HOT 4
- Incompatibility with calling spin_until_future_complete while in callback HOT 10
- Logging with `rclpy` to file misses messages unless accompanied by a consistent stream HOT 2
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.