Search code examples
yamlroslaunch

How To Reference Yaml File Relative to Launch File?


I have a launch file that is loading a yaml file:

<launch>
    <rosparam command="load file="filename.yaml" />
    <node pkg="my_package" type="my_package_node" name="my_package_node" />
</launch>

The filename.yaml file cannot be found unless I put a complete path: "/home/username/blah/blah/blah". Seeing as this launch file is used on multiple machines by different users and locations for the repository, I obviously cannot hard-code the path. So now what? How do I reference it relative to the location of the launch file?


Solution

  • Best answer I could find myself was to use $(find package_name) as a starting point:

    <launch>
        <rosparam command="load file="$(find package_name)/../../yamlFolder/filename.yaml" />
        <node pkg="my_package" type="my_package_node" name="my_package_node" />
    </launch>
    

    Seems kinda silly though. No reference to the path relative to the launch file itself? Would definitely like a better answer.