ros2 / ros2cli

ROS 2 command line interface tools
Apache License 2.0
183 stars 165 forks source link

`ros2 param load` sets the unexpected parameter value from yaml #863

Open fujitatomoya opened 1 year ago

fujitatomoya commented 1 year ago

Bug report

Required Info:

Steps to reproduce issue

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run demo_nodes_cpp parameter_blackboard --ros-args -r __ns:=/demo
[INFO] [1698430890.996467163] [demo.parameter_blackboard]: Parameter blackboard node named '/demo/parameter_blackboard' ready, and serving '6' parameters already!
...
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run demo_nodes_cpp parameter_blackboard --ros-args -r __ns:=/foobar
[INFO] [1698430892.707078622] [foobar.parameter_blackboard]: Parameter blackboard node named '/foobar/parameter_blackboard' ready, and serving '6' parameters already!
...
root@tomoyafujita:~/ros2_ws/colcon_ws# cat params.yaml 
/foobar/parameter_blackboard:
  ros__parameters:
    test_double: 1e-06
    test: hoge
/demo/parameter_blackboard:
  ros__parameters:
    test_double: 5e-06

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param load /demo/parameter_blackboard params.yaml
Set parameter test_double successful
Set parameter test successful
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param list /demo/parameter_blackboard
  qos_overrides./parameter_events.publisher.depth
  qos_overrides./parameter_events.publisher.durability
  qos_overrides./parameter_events.publisher.history
  qos_overrides./parameter_events.publisher.reliability
  start_type_description_service
  test
  test_double
  use_sim_time

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param get /demo/parameter_blackboard test
String value is: hoge

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param get /demo/parameter_blackboard test_double
String value is: 1e-06

Expected behavior

for /demo/parameter_blackboard, i was expecting only test_double with 5e-06

Actual behavior

/demo/parameter_blackboard is set with the parameters of /foobar/parameter_blackboard siliently.

Additional information

i think rclpy.parameter.parameter_dict_from_yaml_file should be called with targeted remote node name. if wildcard is not enabled, it should generate the exception if it can find /** in the yaml parameter file. and then we can check the target_nodes are actually in the yaml parameter file.

fujitatomoya commented 1 year ago

either @iuhilnehc-ynos or @Barry-Xu-2018 , can you take a look at the following patches?

sloretz commented 1 year ago

@clalancette assigned for you to review 🧇