Skip to content
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

Can't load non-absolute node name in parameter file #648

Closed
Karsten1987 opened this issue Jun 8, 2021 · 7 comments
Closed

Can't load non-absolute node name in parameter file #648

Karsten1987 opened this issue Jun 8, 2021 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@Karsten1987
Copy link
Contributor

Bug report

I have a parameter file in the style of

some_node_name:
  ros__parameters:
    a_list:
        - item1
        - item2

Expected behavior

ros2 param load works to load the correct parameters for node some_node_name even though the node name is not specified as absolute.

Actual behavior

error is raised: param file does not contain parameters for /some_node_name, only for nodes: dict_keys(['some_node_name'])

Note that there's a simple mismatch between the node names given that one is absolute.

Additional information

The reproducer here is based on a ros2-control example in which I would like to use the spawner script to spawn a controller with a given type and a parameter file.
@v-lopez fyi

@v-lopez
Copy link
Contributor

v-lopez commented Jun 8, 2021

I believe this is done on purpose, as the initial behavior allowed both, but after some discussion #590 (comment) and subsequent messages this was the conclusion: #600

@Karsten1987
Copy link
Contributor Author

Isn't there a mismatch in the way we load parameters then? I can pass the same yaml file to a node within a launch file without the leading slash, but if I later on start a node and load that parameter file via ros2 param load ... the forward slash has to be present?

@v-lopez
Copy link
Contributor

v-lopez commented Jun 8, 2021

I don't know enough about all the use cases, but yeah sounds like a mismatch, which gives more importance to what I requested here ros2/rclpy#671 since basically the same code is reimplemented in multiple places, mismatches like this are bound to happen.

@v-lopez
Copy link
Contributor

v-lopez commented Jun 8, 2021

pinging @audrow @ivanpauno @clalancette

@ivanpauno
Copy link
Member

Isn't there a mismatch in the way we load parameters then?

Maybe, I really don't know why rcl accepts a relative name in a parameters file.
Does that only match /some_node_name or also /my_ns/some_node_name?

I think we can copy what rcl does in ros2 param load.
In the case it only matches /some_node_name, we could use in the future /**/some_node_name to match both options.

@audrow audrow self-assigned this Jun 17, 2021
@fujitatomoya
Copy link
Collaborator

Does that only match /some_node_name or also /my_ns/some_node_name?

both match.

i guess ros2 param load is the correct behavior. or rcl_yaml_param_parser?

@fujitatomoya
Copy link
Collaborator

This has been fixed with ros2/rclpy@3053a8a

  • non-absolute node name case.
### ros2 param load
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run demo_nodes_cpp parameter_blackboard
[INFO] [1698706220.128919541] [parameter_blackboard]: Parameter blackboard node named '/parameter_blackboard' ready, and serving '6' parameters already!
...
root@tomoyafujita:~/ros2_ws/colcon_ws# cat params.yaml
parameter_blackboard:
  ros__parameters:
    foo: bar
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param load /parameter_blackboard params.yaml
Set parameter foo successful
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param get /parameter_blackboard foo
String value is: bar

### --ros-args --params-file params.yaml
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run demo_nodes_cpp parameter_blackboard --ros-args --params-file params.yaml
[INFO] [1698706337.110460136] [parameter_blackboard]: Parameter blackboard node named '/parameter_blackboard' ready, and serving '7' parameters already!
...
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param get /parameter_blackboard foo
String value is: bar
  • absolute name case
### ros2 param load
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run demo_nodes_cpp parameter_blackboard
[INFO] [1698706519.744738775] [parameter_blackboard]: Parameter blackboard node named '/parameter_blackboard' ready, and serving '6' parameters already!
...
root@tomoyafujita:~/ros2_ws/colcon_ws# cat params.yaml
/parameter_blackboard:
  ros__parameters:
    foo: bar
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param load /parameter_blackboard params.yaml
Set parameter foo successful
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param get /parameter_blackboard foo
String value is: bar

### --ros-args --params-file params.yaml
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run demo_nodes_cpp parameter_blackboard --ros-args --params-file params.yaml
[INFO] [1698706478.171368734] [parameter_blackboard]: Parameter blackboard node named '/parameter_blackboard' ready, and serving '7' parameters already!
...
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param get /parameter_blackboard foo
String value is: bar
  • wildcard case
### ros2 param load
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run demo_nodes_cpp parameter_blackboard
[INFO] [1698706679.815384266] [parameter_blackboard]: Parameter blackboard node named '/parameter_blackboard' ready, and serving '6' parameters already!
...
root@tomoyafujita:~/ros2_ws/colcon_ws# cat params.yaml
/**/parameter_blackboard:
  ros__parameters:
    foo: bar
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param load /parameter_blackboard params.yaml
Set parameter foo successful
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param get /parameter_blackboard foo
String value is: bar

### --ros-args --params-file params.yaml
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 run demo_nodes_cpp parameter_blackboard --ros-args --params-file params.yaml
[INFO] [1698706712.118549727] [parameter_blackboard]: Parameter blackboard node named '/parameter_blackboard' ready, and serving '7' parameters already!
...
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 param get /parameter_blackboard foo
String value is: bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants