-
Notifications
You must be signed in to change notification settings - Fork 427
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
Parameter service compliance #2515
Draft
mxgrey
wants to merge
4
commits into
ros2:rolling
Choose a base branch
from
mxgrey:parameter_service_compliance
base: rolling
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9bd5769
Comply with rcl_interfaces parameter services documentation
mxgrey dfd40a2
Merge remote-tracking branch 'origin/rolling' into parameter_service_…
mxgrey 1f8620a
Merge remote-tracking branch 'origin/rolling' into parameter_service_…
mxgrey 5db9ffa
Use a constant value that is set upstream
mxgrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not move these lined in to
catch
statement scope? In that case, probably we do not need to havedescription_found
stack variable?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use
description.at(0)
and intentionally segfault when the returned vector is empty, but that will produce a different kind of exception thanParameterNotDeclaredException
. So then we'd have to either duplicate code between multiplecatch
blocks or else make acatch
block that covers all exception types, which might hide other kinds of exceptions that should be handled differently.In general I think exceptions are a rather blunt instrument so I prefer to avoid using them whenever possible. We could avoid exceptions if we are willing to make one of the following tweaks to
NodeParametersInterface
:(1) Add a new argument to
describe_parameters
to override the behavior whenallow_undeclared_parameters
is false:or (2) have a function that gets parameter descriptions one at a time, returning
std::nullopt
when the parameter is undeclared:I don't have a strong opinion about which is better...
Option (1) would make it easy to avoid any code duplication, but the argument is awkward, and I can't think of a name for it that wouldn't be confusing.
Option (2) is probably the cleanest from an API standpoint, but then we have to consider the mutex locking situation. The natural thing to do would be to reimplement
NodeParameters::describe_parameters
by iterating over the newNodeParameters::describe_parameter
method, but that might not be great... CurrentlyNodeParameters::describe_parameters
locks the mutex once at the start of the function and then iterates through all the names while keeping the mutex locked. In theory this reduces thread contention and makes the overall procedure more efficient compared to relocking the mutex for each parameter that we want to describe. We could introduce aNodeParameters::describe_parameter_impl
which doesn't lock the mutex and is used to implement bothNodeParameters::describe_parameter
andNodeParameters::describe_parameters
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a third option would be to reimplement
NodeParameters::describe_parameter
to just not behave differently underallow_undeclared_parameters(false)
, but that wouldn't align with the other rclcpp parameter functions that use exceptions to enforce the parameter declaration constraint.