-
Notifications
You must be signed in to change notification settings - Fork 412
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
Implicitly cast integer values for double parameters #979
Comments
@jacobperron you were assigned to this from waffle meeting. |
Can you add the affecting parameters name to the exception when you tackle this pls? For example if you load a yaml file or a list of parameters in a launch file, it can be really annoying finding the wrong parameter. |
Fixes #979. When constructing integer ParameterValue objects, also set the double member. When requesting a double value for ParameterValue objects of type integer, do not throw an exception. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
I'm not sure the best way to add the parameter name, since the exception is coming from |
Fixes #979 Signed-off-by: Jacob Perron <jacob@openrobotics.org>
See #1024 for a patch that allows integer values to be cast to double. This does not include arrays of integers being cast to arrays of double (for technical reasons). Regarding improving the error message, two options come to mind:
I'm leaning towards (2), unless there's some unforeseen consequence to this approach. @wjwwood Thoughts? |
I looked into implementing both options. Option (2) certainly seems more intrusive as it requires touching all of the |
See #1027 for an implementation of (2). |
Given that we closed #1024, we can close this as well. @jacobperron feel free to reopen if you think this is in error. |
I closed #1024 since there wasn't a clear path to a solution and I don't intend to spend more time working on it. |
…gth beyond length of string (ros2#979) * Test that lexer never returns length longer than string Signed-off-by: Shane Loretz <sloretz@openrobotics.org> * Fix bug where lexer returned length longer than string Signed-off-by: Shane Loretz <sloretz@openrobotics.org> * Test that peeking 2 ahead never goes beyond NONE or EOF Signed-off-by: Shane Loretz <sloretz@openrobotics.org> * Stop peeking if the first lexeme is NONE or EOF Signed-off-by: Shane Loretz <sloretz@openrobotics.org>
Feature request
Feature description
If we try to pass an integer value to a double parameter from the command line or from a parameters YAML file we get a
rclcpp::ParameterTypeException
. For example, passing a parameter from the command line:results in the following error:
and we can fix it by explicitly making our value a floating point number:
But, it seems reasonable to me that if a user forgets to explicitly provide a floating point value that we should implicitly cast an integer to a float (as is done in many programming languages).
The text was updated successfully, but these errors were encountered: