Skip to content

Commit

Permalink
Fix incorrect comparsion on whether parameter type is NOT_SET (#1032) (
Browse files Browse the repository at this point in the history
…#1283)

* Fix incorrect comparsion on whether parameter type is NOT_SET
* Add a test case to check fixing

Signed-off-by: Barry Xu <[email protected]>
Co-authored-by: Barry Xu <[email protected]>
  • Loading branch information
xueying4402 and Barry-Xu-2018 authored May 24, 2024
1 parent 0657425 commit 091f7eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rclpy/rclpy/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def declare_parameters(
descriptor.dynamic_typing = True

if isinstance(second_arg, Parameter.Type):
if second_arg.value == Parameter.Type.NOT_SET:
if second_arg == Parameter.Type.NOT_SET:
raise ValueError(
f'Cannot declare parameter {{{name}}} as statically typed of type NOT_SET')
if descriptor.dynamic_typing is True:
Expand Down
5 changes: 5 additions & 0 deletions rclpy/test/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ def test_declare_parameters(self):
)]
)

# Declare a parameter with parameter type 'Not Set'
with self.assertRaises(ValueError):
self.node.declare_parameter(
'wrong_parameter_value_type_not_set', Parameter.Type.NOT_SET)

def reject_parameter_callback(self, parameter_list):
rejected_parameters = (param for param in parameter_list if 'reject' in param.name)
return SetParametersResult(successful=(not any(rejected_parameters)))
Expand Down

0 comments on commit 091f7eb

Please sign in to comment.