-
Notifications
You must be signed in to change notification settings - Fork 136
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
API Changes: execution structure, options pattern, and arcs #427
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
This was referenced Nov 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a number of API breakages that I will be proposing with the following goals:
There are three broad categories of breaking API changes that are being introduced here. Each of these categories can be discussed and iterated on independently, and I'm happy to revert or revise each of them as needed, bearing in mind that some breakages cannot be avoided in order to introduce async execution. I've lumped all three into one PR with the intent of completing all foreseeable API breakages in one fell swoop. If it's desired, I can reorganize this into a sequence of incremental API breaking PRs.
The three categories are broken down below:
1. Execution structure (Context -> Execution -> Node relationship)
(spun out in #428)
This is the most crucial change for the async execution to be feasible. Up until now, rclrs has had a loose coupling between the executor and nodes. That means nodes could be added to or removed from the executor freely. This comes with the following disadvantages:
Due to the last bullet point in particular, I'm proposing a rigid procedure in which:
The minimum publisher example shows a good demonstration of this new procedure.
In this structure, Nodes are no longer allowed to be removed from an Executor or move between Executors. That's a very unlikely use case to begin with, so I don't think there's a downside to this restriction. After #421 we'll be able to introduce custom flavors of Executors, so if anyone really cares about moving their node around between executors, it would be possible to introduce a custom hierarchical executor that can move nodes between other executors.
2. Options Pattern
(spun out in #429)
This is a slight twist on the builder pattern that we were using via
NodeBuilder
up until now.Instead of creating a "builder" object which will eventually
.build()
the final product, we will build an_Options
structure which gets passed into acreate_
function. Here are some examples:create_node
create_subscription
create_service
The user fills up the
_Options
with whichever fields are relevant to them, and the rest of the option fields will use default values. Note that publishers and subscribers will have different default QoS from clients and services, and this is taken into account by the option builders for these different primitive types.3. Arcs
(spun out in #430)
This one is very subjective so I don't mind reverting it, but I felt that the prevalence of
Arc
in the API was adding noise that is seldom relevant to the average user. In this PR, I've refactored the API a little so thatNode
,Subscription
,Publisher
,Client
, andService
each have a respective_State
structure which is public and represents the underlying instance. At the same time,Node
,Subscription
, etc are now type aliases of the formpub type Node = Arc<NodeState>;
pub type Subscription<T> = Arc<SubscriptionState<T>>;
This does not lead to any actual change in the structure or memory management of any of these types; it's a purely superficial renaming. But it reduces how often
Arc
is tossed around in the API and thereby streamlines the 95% (my own estimate) of use cases whereArc
is just an implementation detail. At the same time, it does not interfere with the remaining 5% of use cases where theArc
is relevant, e.g. if a user wants to hold onto aWeak<Node>
for some reason.