-
Notifications
You must be signed in to change notification settings - Fork 217
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
declare_parameters allows conflicting type definition #879
Comments
I'm working on a PR and I think I even found a bug in the current test cases: rclpy/test/test_node.py:
The author tried to create declared a PARAMETER_DOUBLE, but value is '10' instead of '10.', so the type is later PARAMETER_INTEGER. |
ros2/rclpy#879 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
This also stops users from using empty lists as default values: An empty list is interpreted as byte-array even if the user explicitly declared a string_array |
See my comments here. I don't think we can reasonably fix it without breaking a lot of currently valid code. |
That can be solved using: param = Parameter('my_param', type_=Parameter.Type.STRING_ARRAY, value=[])
node.declare_parameter(param.name, param.get_parameter_value()) |
@NikolasE @fujitatomoya I think we need to improve docs. |
I think we need a more detailed tutorial in https://github.com/ros2/ros2_documentation/, but at least #957 clarified a bit how it works in the API docs. |
Bug report
rclpy
Steps to reproduce issue
self.declare_parameters(namespace="", parameters=[("param_name", "HelloWorld", ParameterDescriptor(type=ParameterType.PARAMETER_BOOL, description="a parameter"))])
Expected behavior
Exception or Warning that the given type in the ParameterDescriptor does not fit to the type of the value.
Actual behavior
ParameterDescription.type is ignored, parameter-type is deduced from value (-> string-parameter)
Feature request
Feature description
Raise an InvalidParameterValueException
Implementation considerations
Could break existing code but fixing the value-type mismatch is easy
The text was updated successfully, but these errors were encountered: