Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Utilize rclcpp::WaitSet as part of the executors - #2142

Merged
wjwwood merged 106 commits into
rollingfrom
mjcarroll/rclcpp_waitset_executor
Mar 29, 2024
Merged

wjwwood merged 106 commits into
rollingfrom
mjcarroll/rclcpp_waitset_executor

Conversation

@mjcarroll

@mjcarroll mjcarroll commented Mar 28, 2023

Copy link
Copy Markdown
Member

Improve number of rcl_wait_set creations and deletions by making the default Single/Multithreaded executors work like the static single threaded executor in terms of entity collection rebuilding.

TODOS

  • The concepts of entity collector and notify waitable come from add events-executor and timers-manager in rclcpp #2140, they need to be rectified with that pull request and iRobot copyright needs to be added to appropriate files
  • restore static-single threaded files (removed for ease of testing)
  • documentation/test coverage on some of the new structures

Comment thread rclcpp/src/rclcpp/executors/executor_entities_collection.cpp Outdated
@alsora

ghost commented Mar 28, 2023

Copy link
Copy Markdown
Collaborator

@mjcarroll I looked into the new entities collection and collector classes and they look great.

I think that there are very few changes needed in order to use them with the events-executor:

  1. add to ExecutorEntitiesCollection some public methods such as
rclcpp::ClientBase::WeakPtr get_client(const rcl_client_t * client_handle);

  1. the ExecutorNotifyWaitable in the events-executor should have an execute function that refresh the events-executor collections. to do so, it will need to access some internal methods of the events-executor. this could be configurable through a lambda function passed during construction.

Comment thread rclcpp/src/rclcpp/executors/executor_entities_collector.cpp Outdated
@mjcarroll
mjcarroll force-pushed the mjcarroll/rclcpp_waitset_executor branch from b74b192 to ad3f3e5 Compare March 29, 2023 18:07
Michael Carroll added 7 commits March 29, 2023 19:42
Signed-off-by: Michael Carroll <[email protected]>
* Add callback to EntitiesCollector constructor
* Make function to check automatically added callback groups take a list

Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
@mjcarroll
mjcarroll force-pushed the mjcarroll/rclcpp_waitset_executor branch from ad3f3e5 to 14e009e Compare March 31, 2023 02:04
@mjcarroll
mjcarroll changed the base branch from rolling to mjcarroll/executor_structures March 31, 2023 02:05
@mjcarroll
mjcarroll force-pushed the mjcarroll/rclcpp_waitset_executor branch 2 times, most recently from 4191445 to ed791d3 Compare March 31, 2023 02:13
@mjcarroll
mjcarroll marked this pull request as ready for review March 31, 2023 13:46
Michael Carroll added 4 commits April 3, 2023 17:09
Also change node's get_guard_condition to return shared_ptr

Signed-off-by: Michael Carroll <[email protected]>
Check if guard condition is valid before adding it to the waitable

Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
@mjcarroll
mjcarroll force-pushed the mjcarroll/rclcpp_waitset_executor branch from ed791d3 to 974e845 Compare April 3, 2023 18:55
Michael Carroll added 2 commits April 3, 2023 19:30
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
@dhood

ghost commented Apr 24, 2024

Copy link
Copy Markdown
Member

hey @wjwwood , I was just in a roscontrol WG meeting where @christophfroehlich mentioned a regression that they've seen only in rolling testing build. they're manually building a waitset around a subscription, which maybe is a bit of a niche case, but wanted to flag it for triaging before the next sync is planned - it might not be possible to have a subscription in two wait sets after the changes in this PR?

@christophfroehlich

ghost commented Apr 24, 2024

Copy link
Copy Markdown

Thanks for pinging this here. It is already failing on main, I think this change here was released already.

@dhood

ghost commented Apr 25, 2024

Copy link
Copy Markdown
Member

ok - although I have a new thought - maybe now the intended behaviour is being enforced! The exception "subscription already associated with a wait set" might mean that it was never appropriate to have it in two wait sets 😅

@fujitatomoya

ghost commented Apr 25, 2024

Copy link
Copy Markdown
Collaborator

it might not be possible to have a subscription in two wait sets after the changes in this PR?

No, we cannot add the subscription to different wait set after this change. there is a test case to expect the exception,

EXPECT_THROW(
node_topics->add_subscription(subscription, callback_group_in_different_node),
std::runtime_error);

CC: @wjwwood @mjcarroll

@wjwwood

ghost commented Apr 25, 2024

Copy link
Copy Markdown
Member

maybe now the intended behaviour is being enforced! The exception "subscription already associated with a wait set" might mean that it was never appropriate to have it in two wait sets 😅

Sorry, just catching up on this, yes indeed that is the case. Technically the constraint is that you cannot wait on one subscription from two different wait sets simultaneously, but we enforce that by not allowing a single subscription to be contained in/associated with more than one wait set at a time.

@wjwwood

ghost commented Apr 25, 2024

Copy link
Copy Markdown
Member

they're manually building a waitset around a subscription, which maybe is a bit of a niche case, but wanted to flag it for triaging before the next sync is planned

If you want to use a subscription with a wait set manually (and that is totally ok to do), then you need to make sure the subscription is not part of a callback group that was added to an executor. You can do that by creating a callback group that has the automatically_add_to_executor_with_node flag set to false (

bool automatically_add_to_executor_with_node = true);
) and use it when creating the subscription. That will ensure that callback group is never added to an executor (and therefore a wait set) when the node is added to an executor.

@dhood

ghost commented Apr 26, 2024

Copy link
Copy Markdown
Member

oo hadn't noticed that before; awesome! thanks for the pointers!

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.