feat: Added callback group events executor#3097
feat: Added callback group events executor#3097jmachowinski wants to merge 13 commits intoros2:rollingfrom
Conversation
273c322 to
66467b3
Compare
rclcpp/include/rclcpp/executors/events_cbg_executor/events_cbg_executor.hpp
Show resolved
Hide resolved
rclcpp/include/rclcpp/executors/events_cbg_executor/events_cbg_executor.hpp
Show resolved
Hide resolved
rclcpp/include/rclcpp/experimental/executors/events_cbg_executor/events_cbg_executor.hpp
Outdated
Show resolved
Hide resolved
rclcpp/include/rclcpp/experimental/executors/events_cbg_executor/events_cbg_executor.hpp
Outdated
Show resolved
Hide resolved
rclcpp/include/rclcpp/executors/events_cbg_executor/events_cbg_executor.hpp
Outdated
Show resolved
Hide resolved
rclcpp/src/rclcpp/executors/events_cbg_executor/events_cbg_executor.cpp
Outdated
Show resolved
Hide resolved
rclcpp/src/rclcpp/experimental/executors/events_cbg_executor/events_cbg_executor.cpp
Outdated
Show resolved
Hide resolved
|
@jmachowinski can you add this to the executor unit-tests? |
f7b3021 to
7eb2fca
Compare
This commit adds the callback group events executor. It features: - multithreading support - correct handling of sim time - usage of the events subsystem Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
Signed-off-by: Janosch Machowinski <j.machowinski@cellumation.com>
Signed-off-by: Janosch Machowinski <j.machowinski@cellumation.com>
Signed-off-by: Janosch Machowinski <j.machowinski@cellumation.com>
Signed-off-by: Janosch Machowinski <j.machowinski@cellumation.com>
4933042 to
26fd9db
Compare
Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
…ager This code was copied straight from the executor and seems to be a workaround for the multithreaded executor, that breaks in this use case. The correct solution for us is to do the timer->call() from within the worker thread. This fixes a deadlock due to double acquisition of an internal lock within the timer manager. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
In case the next timer wakeup time is not changed by an insertion of a timer, don't wake up the timer thread. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
26fd9db to
430c2dd
Compare
|
Pulls: #3097 |
Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
skyegalaxy
left a comment
There was a problem hiding this comment.
Aside from some spelling nits and a handful of small implementation questions, this is looking great! Very excited to get this over the finish line soon.
rclcpp/include/rclcpp/executors/events_cbg_executor/events_cbg_executor.hpp
Outdated
Show resolved
Hide resolved
| added_nodes_cpy = added_nodes; | ||
| } | ||
|
|
||
| // *3 is a rough estimate of how many callback_group a node may have |
There was a problem hiding this comment.
What would happen in the case where a node might have more than 3 callback groups?
There was a problem hiding this comment.
you get slight runtime overhead, as the vector needs to be resized.
| } | ||
| } | ||
|
|
||
| // FIXME inform scheduler about remove cbgs |
There was a problem hiding this comment.
what are the side-effects of leaving this as is and not informing the scheduler here?
rclcpp/src/rclcpp/executors/events_cbg_executor/events_cbg_executor.cpp
Outdated
Show resolved
Hide resolved
rclcpp/src/rclcpp/executors/events_cbg_executor/events_cbg_executor.cpp
Outdated
Show resolved
Hide resolved
| * This is needed, as clocks may be deleted during normal operation, | ||
| * and be don't have a way to create a permanent ros time clock. | ||
| */ | ||
| class ClockConditionalVariable |
There was a problem hiding this comment.
I think it could be worth eventually merging the functionality of this ClockConditionalVariable variant with the existing one and cutting down on the duplicate code if it's not too complex to do.
rclcpp/src/rclcpp/executors/events_cbg_executor/timer_manager.hpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
yes, that is the idea. |
| * \param options common options for all executors | ||
| * \param number_of_threads number of threads to have in the thread pool, | ||
| * the default 0 will use the number of cpu cores found (minimum of 2) | ||
| * \param yield_before_execute if true std::this_thread::yield() is called |
There was a problem hiding this comment.
this parameter yield_before_execute isn't present in this constructor
|
|
||
| std::unique_ptr<cbg_executor::CBGScheduler> scheduler; | ||
|
|
||
| std::thread rcl_polling_thread; |
There was a problem hiding this comment.
this thread doesn't appear to be used anywhere
|
|
||
| class TimerManager | ||
| { | ||
| std::array<TimerQueue, 3> timer_queues; |
There was a problem hiding this comment.
| std::array<TimerQueue, 3> timer_queues; | |
| constexpr int NUM_TYPES_OF_TIMERS = 3; | |
| std::array<TimerQueue, NUM_TYPES_OF_TIMERS> timer_queues; |
|
|
||
| // as, we remove an reappend ready callback_groups during execution, | ||
| // the first ready cbg may not contain the lowest id. Therefore we | ||
| // need to search the whole deque |
There was a problem hiding this comment.
Not a blocker for this PR, but I think it would be interesting to see if we could find a way to efficiently index ready_callback_groups by ID as well as the order, so that instead of searching through the entire deque, we could do something like ready_callback_groups.pop_by_id(max_id)
|
@jmachowinski we also need DCO for some of the newer commits |
This commit adds the callback group events executor. It features:
Description
This moved the events cbg executor from cm_executors into rlcpp mainline.
Did you use Generative AI?
No