Resolving package paths in controller `params_file`?

So I just discovered that the controller manager can take a params_file param for each controller and runtime load it! That would be a great way to break up our massive hardware.yaml files into per-controller yamls. It looks like this:

JSON

controller_manager:
  ros__parameters:
    ...
    my_controller:
      type: my_controller/MyController
      params_file:
        - my_pkg/config/my_controller.yaml

Unfortunately I could only so far get it to work with full paths, or paths relative to the current working directory, which are not portable… It seems like it basically adds --params-file X to the rclcpp::NodeOptions arguments field. But since there’s no bash expansion happening we cant simply add $(ros2 pkg prefix --share m1_2_hardware) or something…

Can anyone think of any workarounds for this? I think it’s probably not possible but just wanted to ask. Maybe we can add a call to ament_index_cpp::get_package_share_directory in here somehow?

With the following code snippet, you can enable substitutions inside of param files:

<param from="..." allow_substs="true" />

Then you can use $(env) and $(find-pkg-share) etc in your parameter file.

This is, as far as I know, only documented in the changelog for galactic…

3 Likes