Add rcl guard condition on_trigger_callback#966
Add rcl guard condition on_trigger_callback#966mauropasse wants to merge 1 commit intoros2:rollingfrom
Conversation
Signed-off-by: Mauro Passerino <mpasserino@irobot.com>
| { | ||
| rcl_event_callback_t on_trigger_callback; | ||
| const void * user_data; | ||
| size_t trigger_count; |
There was a problem hiding this comment.
@mauropasse implementation looks good, but could you explain the use case of trigger_count?
| /** | ||
| * This API sets the callback function to be called whenever the | ||
| * guard_condition is triggered. | ||
| * |
There was a problem hiding this comment.
I think it would be nice to add explanation about how trigger_count works internally.
|
I think i should have looked at #995 1st. |
|
Hi @fujitatomoya, sorry I should have closed this PR when opened #995. The goal was having a way to generate an event when a timer was reset. Since a guard condition is triggered when a timer is reset, the first idea was adding a callback directly to a guard condition ( The last case in which I'd still like a guard condition to have a callback, is the situation where a new entity (pub/sub/etc) is created from a node. When this happens, the node's guard condition is triggered. If we have a callback there, we can rebuild the waitset looking only for new entities added/removed from the node, instead of iterating through all the nodes of the system (which is quite expensive). But I guess we could have there an |
This PR adds the
on_trigger_callbackcallback to rcl guard conditions.If the
on_trigger_callbackis set to a guard condition, it will be called every time the guard condition is triggered.If not, a counter will count the times the guard condiiton was triggered, and if eventually a callback is set it will use the counter as argument.
This PR is aligned to the recently added listener callbacks to the RMW entities (subscriptions, clients, services).
The motivation behind this PR, be able to wake up events driven executors (not relying on a wait set) when guard conditions are triggered. For example, a timer is reset after being cancelled, so it's inner guard condition is triggered and we can take actions to update the next trigger time for the timer.
Signed-off-by: Mauro Passerino mpasserino@irobot.com