confision about ros2 rclpy parameter
I implemented a subclass of node
class MyNode(Node):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.declare_parameter(name='foo',
value='foo_val_init',
descriptor=ParameterDescriptor(name='foo',
type=ParameterType.PARAMETER_STRING))
# just for debuggin
print(self.get_parameter('foo').value)
I have tried to override this value from the command line at the startup of the node but nothing worked. I tried the following
ros2 run mynode run --ros-args -p "foo:=foo_val_cmdline" #(prints foo_val_init)
ros2 run mynode run --ros-args -p foo "foo_val_cmdline" #(prints foo_val_init)
ros2 run mynode run -p foo "foo_val_cmdline" #(prints foo_val_init)
ros2 run mynode run foo "foo_val_cmdline" #(prints foo_val_init)
any idea what I am doing wrong?
I tried looking at demos on the main rclpy
repo and documentation and I think I misunderstanding these inside-node declared params purpose.