-
Notifications
You must be signed in to change notification settings - Fork 263
Allow declaring uninitialized parameters #798
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
Conversation
Parameters can now be declared without a default value and without an override. Attempting to access a statically typed parameter that does not have value will raise an exception. Getting dynamically typed parameters will return an unset parameter value. This change is equivalent to that made in rclcpp: ros2/rclcpp#1673 Signed-off-by: Jacob Perron <[email protected]>
Signed-off-by: Jacob Perron <[email protected]>
| parameters: List[Union[ | ||
| Tuple[str], | ||
| Tuple[str, Parameter.Type], | ||
| Tuple[str, Any], |
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.
wasn't this for passing a value, e.g.: declare_parameters('', [('my_param', 5)])?
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 think the annotation was incorrect before. IIUC, we only expect a tuple up to length 3. The last value of the tuple can have type ParameterDescriptor or Any (for the case of passing a value).
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.
Line 630 in 1b335d3
| ('baz', 2.41), |
We actually can be more specific than using Any, I think Union[int, float, str, bytes, None] would be fine
wjwwood
left a comment
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.
lgtm, with green CI and some manual testing to check for sanity.
Signed-off-by: Jacob Perron <[email protected]>
Signed-off-by: Jacob Perron <[email protected]>
Signed-off-by: Jacob Perron <[email protected]>
This is the same behavior as rclcpp. Signed-off-by: Jacob Perron <[email protected]>
|
Thanks for the reviews. I think I've addressed everything. PTAL. |
ivanpauno
left a comment
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.
LGTM with green CI
Signed-off-by: Jacob Perron <[email protected]>
|
Thanks for triggering CI! |
* Allow declaring uninitialized parameters Parameters can now be declared without a default value and without an override. Attempting to access a statically typed parameter that does not have value will raise an exception. Getting dynamically typed parameters will return an unset parameter value. This change is equivalent to that made in rclcpp: ros2/rclcpp#1673 Signed-off-by: Jacob Perron <[email protected]> * Fix flake8 Signed-off-by: Jacob Perron <[email protected]> * Minor refactor Signed-off-by: Jacob Perron <[email protected]> * Don't allow static parameters to be undeclared Signed-off-by: Jacob Perron <[email protected]> * Return alternative for uninitialized parameters in get_parameter_or Signed-off-by: Jacob Perron <[email protected]> * Ditto for dynamic parameters This is the same behavior as rclcpp. Signed-off-by: Jacob Perron <[email protected]> * Fix lint Signed-off-by: Jacob Perron <[email protected]>
* Allow declaring uninitialized parameters Parameters can now be declared without a default value and without an override. Attempting to access a statically typed parameter that does not have value will raise an exception. Getting dynamically typed parameters will return an unset parameter value. This change is equivalent to that made in rclcpp: ros2/rclcpp#1673 Signed-off-by: Jacob Perron <[email protected]> * Fix flake8 Signed-off-by: Jacob Perron <[email protected]> * Minor refactor Signed-off-by: Jacob Perron <[email protected]> * Don't allow static parameters to be undeclared Signed-off-by: Jacob Perron <[email protected]> * Return alternative for uninitialized parameters in get_parameter_or Signed-off-by: Jacob Perron <[email protected]> * Ditto for dynamic parameters This is the same behavior as rclcpp. Signed-off-by: Jacob Perron <[email protected]> * Fix lint Signed-off-by: Jacob Perron <[email protected]>
Parameters can now be declared without a default value and without an override.
Attempting to access a statically typed parameter that does not have value will raise an exception.
Getting dynamically typed parameters will return an unset parameter value.
This change is equivalent to that made in rclcpp: ros2/rclcpp#1673