-
Notifications
You must be signed in to change notification settings - Fork 417
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
Allow declaring parameters with uninitialized values #1649
Comments
Follow-up from #1588 |
Although this would be a behavior change, IMO, we should backport this to Galactic. My reasoning is that, currently, there is no way to support "optional" parameters besides allowing undeclared parameters or optionally declaring parameters (I consider the latter as an anti-pattern as discussed in #1588). Therefore, without this feature users will have to resort to less than desirable solutions for scenarios where they need optional parameter values. Prior to Galactic, this feature was possible as users could declare a parameter with an unset type with:
|
Fixes #1649 Allow declaring parameters without an initial value or override. This was possible prior to Galactic, but was made impossible since we started enforcing the types of parameters in Galactic. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
For reference, this is the original PR adding static typing of parameters: #1522 |
* Declare parameters uninitialized Fixes #1649 Allow declaring parameters without an initial value or override. This was possible prior to Galactic, but was made impossible since we started enforcing the types of parameters in Galactic. Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove assertion Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Throw NoParameterOverrideProvided exception if accessed before initialized Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Add test getting static parameter after it is set Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Do not throw on access of uninitialized dynamically typed parameter Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Rename exception type Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove unused exception type Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Uncrustify Signed-off-by: Jacob Perron <jacob@openrobotics.org>
* Declare parameters uninitialized Fixes #1649 Allow declaring parameters without an initial value or override. This was possible prior to Galactic, but was made impossible since we started enforcing the types of parameters in Galactic. Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove assertion Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Throw NoParameterOverrideProvided exception if accessed before initialized Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Add test getting static parameter after it is set Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Do not throw on access of uninitialized dynamically typed parameter Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Rename exception type Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove unused exception type Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Uncrustify Signed-off-by: Jacob Perron <jacob@openrobotics.org>
* Declare parameters uninitialized Fixes #1649 Allow declaring parameters without an initial value or override. This was possible prior to Galactic, but was made impossible since we started enforcing the types of parameters in Galactic. Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove assertion Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Throw NoParameterOverrideProvided exception if accessed before initialized Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Add test getting static parameter after it is set Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Do not throw on access of uninitialized dynamically typed parameter Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Rename exception type Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove unused exception type Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Uncrustify Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Feature request
Feature description
There are situations where we want to declare a parameter, but not initialize it until later.
For example, it would be nice to declare a parameter, with a type like this without it throwing an exception because the user did not provide an override at runtime:
node->declare_parameter(name, type);
We could then later set the value of the parameter programmatically from the node itself (e.g. with
set_parameter
) or let the user set it later with a service call (e.g.ros2 param set
).Implementation considerations
After declaring a parameter without an initial value and if there is no user-provided override, then I would expect the parameter to have a value of "UNSET", and trying to access a value might throw an exception.
The text was updated successfully, but these errors were encountered: