Commit 4c05d92
Introduce EventsExecutor implementation (#1391)
* Introduce EventsExecutor implementation (#1389)
Signed-off-by: Brad Martin <[email protected]>
* Fix explosion for reference count updates without GIL
The previous version worked on 22.04+Iron, but fails on 24.04+Jazzy or Rolling. It
seems like the behavior of std::bind() may have changed when asked to bind a py::object
to a callback taking a py::handle.
Signed-off-by: Brad Martin <[email protected]>
* Fix ament linter complaints
Signed-off-by: Brad Martin <[email protected]>
* Switch to non-boost asio library
Signed-off-by: Brad Martin <[email protected]>
* Use internal _rclpy C++ types instead of jumping through Python hoops
Signed-off-by: Brad Martin <[email protected]>
* Reformat with clang-format, then uncrustify again
clang-format fixes things that uncrustify tends to leave alone, but then uncrustify seems slightly
unhappy with that result. Also reflow comments at 100 columns.
This uses the .clang-format file from the ament-clang-format package, with the exception of
SortIncludes being set to false, because I didn't like what it tried to do with includes without
that override.
Signed-off-by: Brad Martin <[email protected]>
* Respect init signal handling options
Signed-off-by: Brad Martin <[email protected]>
* Reconcile signal handling differences with SingleThreadedExecutor
Signed-off-by: Brad Martin <[email protected]>
* test_executor.py: Add coverage for EventsExecutor
Tests that currently work are enabled, and those that don't are annotated what needs to be done before they can be enabled
Signed-off-by: Brad Martin <[email protected]>
* Make spin_once() only return after a user-visible callback
Signed-off-by: Brad Martin <[email protected]>
* Add get_nodes() method
Signed-off-by: Brad Martin <[email protected]>
* Add context management support
Signed-off-by: Brad Martin <[email protected]>
* Remove mutex protection on nodes_ member access
It was being used only inconsistently, and on reflection it wasn't adding any protection beyond what
the GIL already provides.
Signed-off-by: Brad Martin <[email protected]>
* Fix deadlock during shutdown()
Needed to release the GIL while blocking on another lock.
Signed-off-by: Brad Martin <[email protected]>
* A little further on using C++ _rclpy types instead of Python interface
Signed-off-by: Brad Martin <[email protected]>
* Fix issue with iterating through incomplete Tasks
Never bool-test a py::object::attr() return value without an explicit py::cast<bool>.
Signed-off-by: Brad Martin <[email protected]>
* Add support for coroutines to timer handling
Signed-off-by: Brad Martin <[email protected]>
* Fix test_not_lose_callback() test to destroy entities properly
EventsExecutor was exploding because the test was leaving destroyed entities in the node by using an
incorrect API to destroy them.
Signed-off-by: Brad Martin <[email protected]>
* Correct test that wasn't running at all, and remove EventsExecutor from it
* Test methods need to be prefixed with 'test_' in order to function. This had been entirely dead
code, and when I enabled it EventsExecutor deadlocked.
* On reflection, it seems like a deadlock is exactly what should be expected from what this test is
doing. Remove EventsExecutor from the test and document the problem.
Signed-off-by: Brad Martin <[email protected]>
* Warn on every timer added over the threshold, not just the first
Co-authored-by: Janosch Machowinski <[email protected]>
Signed-off-by: Brad Martin <[email protected]>
* Keep rcl_timer_call() tightly coupled with user callback dispatch
This both prevents an issue where user callbacks could potentially queue up if they didn't dispatch
fast enough, and ensures that a timer that has passed its expiration without being dispatched yet
can still be canceled without the user callback being delivered later.
This commit also makes use of the new rcl API for querying the absolute timer expiration time,
instead of the relative number of nanoseconds remaining until it expires. This should both make
things more accurate, and potentially reduce overhead as we don't have to re-query the current time
for each outstanding timer.
Signed-off-by: Brad Martin <[email protected]>
* Protect against deferred method calls happening against a deleted ClockManager
Signed-off-by: Brad Martin <[email protected]>
* Add support for new TimerInfo data passed to timer handlers
Signed-off-by: Brad Martin <[email protected]>
* Simplify spin_once() implementation
This both reduces duplicate code now, and simplifies the asio interface used which would need
replacing.
Signed-off-by: Brad Martin <[email protected]>
* Fix stale Future done callbacks with spin_until_future_complete()
This method can't be allowed to leave its Future done callback outstanding in case the method is
returning for a reason other than the Future being done.
Signed-off-by: Brad Martin <[email protected]>
* Use existing rclpy signal handling instead of asio
Signed-off-by: Brad Martin <[email protected]>
* Replace asio timers with a dedicated timer wait thread
This is dumb on its own, but it helps me move towards eliminating asio.
Signed-off-by: Brad Martin <[email protected]>
* Correct busy-looping in async callback handling
This isn't ideal because there are some ways async callbacks could become unblocked which wouldn't
get noticed right away (if at all); however this seems to match the behavior of
SingleThreadedExecutor.
Signed-off-by: Brad Martin <[email protected]>
* Replace asio::io_context with a new EventsQueue object
Signed-off-by: Brad Martin <[email protected]>
* Add EventsExecutor to new test_executor test from merge
Signed-off-by: Brad Martin <[email protected]>
* Swap 'pragma once' for ifndef include guards
Signed-off-by: Brad Martin <[email protected]>
* Add test coverage for Node.destroy_subscription()
Signed-off-by: Brad Martin <[email protected]>
* Replace '|' type markup with typing.Optional and typing.Union
Python 3.9, still used by RHEL 9, doesn't seem to understand '|' syntax, and
Optional/Union seems to be what gets used throughout the rest of the codebase.
Additionally, fix a couple other mypy nits:
* mypy is mad that I haven't explicitly annotated every __init__ as returning None
* mypy wants generic arguments to service and action clients now
Signed-off-by: Brad Martin <[email protected]>
* Use 'auto' in place of explicit return type on hash
pybind11::hash() is documented as returning ssize_t, but this seems to be a lie because MSVC
doesn't understand that type; so, let's just return whatever we do get.
Signed-off-by: Brad Martin <[email protected]>
* Change initialization of struct members
MSVC didn't like the more concise method.
Signed-off-by: Brad Martin <[email protected]>
* Use subTest in test_executor to distinguish which executor type failed
Signed-off-by: Brad Martin <[email protected]>
* Use time.perf_counter() instead of time.monotonic() in executor test
time.monotonic() has a resolution of 16ms, which is way too coarse for the intervals
this test is trying to measure.
Signed-off-by: Brad Martin <[email protected]>
---------
Signed-off-by: Brad Martin <[email protected]>
Signed-off-by: Brad Martin <[email protected]>
Co-authored-by: Brad Martin <[email protected]>
Co-authored-by: Janosch Machowinski <[email protected]>1 parent 59671a0 commit 4c05d92
File tree
21 files changed
+3335
-325
lines changed- rclpy
- rclpy
- experimental
- src/rclpy
- events_executor
- test
21 files changed
+3335
-325
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
| |||
182 | 187 | | |
183 | 188 | | |
184 | 189 | | |
| 190 | + | |
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
210 | 224 | | |
211 | 225 | | |
212 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
| 251 | + | |
| 252 | + | |
250 | 253 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
0 commit comments