Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create common structures for executors to use #2143

Merged
merged 25 commits into from
Apr 14, 2023

Conversation

mjcarroll
Copy link
Member

Broken off of #2142 so that it can be used as a base for #2140.

This introduces a few main structures:

  • ExecutorNotifyWaitable - an object used to collect node and callback group guard conditions from things associated with an executor.
  • ExecutorEntitiesCollector - an object to collect entities from executor-associated nodes and callback groups
  • ExecutorEntitiesCollection - a collection of entities that are associated with an executor via callback groups and nodes.

CC: @alsora @mauropasse

@mjcarroll mjcarroll force-pushed the mjcarroll/executor_structures branch from d77bac1 to d53349a Compare March 29, 2023 17:05
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
@mjcarroll mjcarroll force-pushed the mjcarroll/executor_structures branch from d53349a to 9099635 Compare March 29, 2023 17:37
@mjcarroll mjcarroll marked this pull request as ready for review March 29, 2023 17:38
@mjcarroll
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
* Add callback to EntitiesCollector constructor
* Make function to check automatically added callback groups take a list

Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
Also change node's get_guard_condition to return shared_ptr

Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
@mjcarroll mjcarroll force-pushed the mjcarroll/executor_structures branch from 3b7266c to a6c4c1b Compare April 3, 2023 17:09
Check if guard condition is valid before adding it to the waitable

Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
@mjcarroll
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@mjcarroll
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Signed-off-by: Michael Carroll <michael@openrobotics.org>
@mjcarroll
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Signed-off-by: Michael Carroll <michael@openrobotics.org>
Signed-off-by: Michael Carroll <michael@openrobotics.org>
@mjcarroll
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@mjcarroll
Copy link
Member Author

aarch flaked: :( Build Status

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a pretty thorough review and I didn't really see any issues. I assume a lot of them have been ironed out by the tests and existing applications which exercise it well.

lgtm

Comment on lines +276 to +282
/**
* TODO(mjcarroll): Assert this when we are enforcing that nodes must be destroyed
* after their created callback groups.
RCLCPP_EXPECT_THROW_EQ(
entities_collector.remove_callback_group(cb_group),
std::runtime_error("Node must not be deleted before its callback group(s)."));
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we enforce this? Or when do you think this TODO could be resolved?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe my understanding is incorrect, but should a callback group be allowed to exist without being created by a node?

If callback groups can exist independently, and outlive their creating node, then this todo is resolved by simply never doing this check, because it is based on an invalid assumption.

If callback groups should not outlive their creating node, then maybe the API should be updated to not return SharedPtr and instead use WeakPtr, which we could then check here.

@clalancette
Copy link
Contributor

Windows unfortunately has a bunch of new failures that probably need to be looked into. They were not in the nightlies.

(for that matter, we should also probably run CI on Windows Debug to see what it has to say here)

@mjcarroll
Copy link
Member Author

Windows unfortunately has a bunch of new failures that probably need to be looked into. They were not in the nightlies.

Yeah, I'm looking into them.

@mjcarroll
Copy link
Member Author

Windows debug for rclcpp, lifecycle demo, and robot state publisher: Build Status

@mjcarroll
Copy link
Member Author

Windows release again: Build Status

@mjcarroll
Copy link
Member Author

Try again as None, so I don't hit path length limits: Build Status

@clalancette
Copy link
Contributor

@mjcarroll Given our long discussion yesterday, where are we with this PR? I think we came to the conclusion that we have a flaky test in test_rclcpp, is there anything else that we need here?

@mjcarroll
Copy link
Member Author

@mjcarroll Given our long discussion yesterday, where are we with this PR? I think we came to the conclusion that we have a flaky test in test_rclcpp, is there anything else that we need here?

The test in test_rclcpp is unrelated this pull request, it's the pull request using the rclcpp::WaitSet is where that test failure came in.

@clalancette
Copy link
Contributor

@ros-pull-request-builder retest this please

@clalancette
Copy link
Contributor

Rpr job is happy. One last CI on Linuxen, since there has been a merge since the last one, then I'll go ahead and merge this:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • RHEL Build Status

@clalancette clalancette merged commit e3d9d81 into rolling Apr 14, 2023
@delete-merged-branch delete-merged-branch bot deleted the mjcarroll/executor_structures branch April 14, 2023 18:56
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request Apr 28, 2023
* Deprecate callback_group call taking context

* Add base executor objects that can be used by implementors

* Template common operations

* Add callback to EntitiesCollector constructor
* Make function to check automatically added callback groups take a list

* Make executor own the notify waitable

* Add pending queue to collector, remove from waitable

Also change node's get_guard_condition to return shared_ptr

* Change interrupt guard condition to shared_ptr

Check if guard condition is valid before adding it to the waitable

* Make get_notify_guard_condition follow API tick-tock

* Improve callback group tick-tocking

* Add thread safety annotations and make locks consistent

* Remove the "add_valid_node" API

* Only notify if the trigger condition is valid

* Only trigger if valid and needed

Signed-off-by: Michael Carroll <michael@openrobotics.org>
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request Apr 29, 2023
* Deprecate callback_group call taking context

* Add base executor objects that can be used by implementors

* Template common operations

* Add callback to EntitiesCollector constructor
* Make function to check automatically added callback groups take a list

* Make executor own the notify waitable

* Add pending queue to collector, remove from waitable

Also change node's get_guard_condition to return shared_ptr

* Change interrupt guard condition to shared_ptr

Check if guard condition is valid before adding it to the waitable

* Make get_notify_guard_condition follow API tick-tock

* Improve callback group tick-tocking

* Add thread safety annotations and make locks consistent

* Remove the "add_valid_node" API

* Only notify if the trigger condition is valid

* Only trigger if valid and needed

Signed-off-by: Michael Carroll <michael@openrobotics.org>
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request Apr 29, 2023
* Deprecate callback_group call taking context

* Add base executor objects that can be used by implementors

* Template common operations

* Add callback to EntitiesCollector constructor
* Make function to check automatically added callback groups take a list

* Make executor own the notify waitable

* Add pending queue to collector, remove from waitable

Also change node's get_guard_condition to return shared_ptr

* Change interrupt guard condition to shared_ptr

Check if guard condition is valid before adding it to the waitable

* Make get_notify_guard_condition follow API tick-tock

* Improve callback group tick-tocking

* Add thread safety annotations and make locks consistent

* Remove the "add_valid_node" API

* Only notify if the trigger condition is valid

* Only trigger if valid and needed

Signed-off-by: Michael Carroll <michael@openrobotics.org>
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request Apr 29, 2023
* Deprecate callback_group call taking context

* Add base executor objects that can be used by implementors

* Template common operations

* Add callback to EntitiesCollector constructor
* Make function to check automatically added callback groups take a list

* Make executor own the notify waitable

* Add pending queue to collector, remove from waitable

Also change node's get_guard_condition to return shared_ptr

* Change interrupt guard condition to shared_ptr

Check if guard condition is valid before adding it to the waitable

* Make get_notify_guard_condition follow API tick-tock

* Improve callback group tick-tocking

* Add thread safety annotations and make locks consistent

* Remove the "add_valid_node" API

* Only notify if the trigger condition is valid

* Only trigger if valid and needed

Signed-off-by: Michael Carroll <michael@openrobotics.org>
alsora pushed a commit to irobot-ros/rclcpp that referenced this pull request May 3, 2023
* Deprecate callback_group call taking context

* Add base executor objects that can be used by implementors

* Template common operations

* Add callback to EntitiesCollector constructor
* Make function to check automatically added callback groups take a list

* Make executor own the notify waitable

* Add pending queue to collector, remove from waitable

Also change node's get_guard_condition to return shared_ptr

* Change interrupt guard condition to shared_ptr

Check if guard condition is valid before adding it to the waitable

* Make get_notify_guard_condition follow API tick-tock

* Improve callback group tick-tocking

* Add thread safety annotations and make locks consistent

* Remove the "add_valid_node" API

* Only notify if the trigger condition is valid

* Only trigger if valid and needed

Signed-off-by: Michael Carroll <michael@openrobotics.org>
Barry-Xu-2018 pushed a commit to Barry-Xu-2018/rclcpp that referenced this pull request Jan 12, 2024
* Deprecate callback_group call taking context

* Add base executor objects that can be used by implementors

* Template common operations

* Add callback to EntitiesCollector constructor
* Make function to check automatically added callback groups take a list

* Make executor own the notify waitable

* Add pending queue to collector, remove from waitable

Also change node's get_guard_condition to return shared_ptr

* Change interrupt guard condition to shared_ptr

Check if guard condition is valid before adding it to the waitable

* Make get_notify_guard_condition follow API tick-tock

* Improve callback group tick-tocking

* Add thread safety annotations and make locks consistent

* Remove the "add_valid_node" API

* Only notify if the trigger condition is valid

* Only trigger if valid and needed

Signed-off-by: Michael Carroll <michael@openrobotics.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants