ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

From ROS kinetic on you can use $(eval to check whether the path is absolute and prepend $(env PWD)/ if it is not. That way you can pass a file with relative path and the node will receive a full path automatically. For your example it should look something like this:

<launch>
    <arg name="file" />
    <node pkg="kinematics" type="trajectory.py" name="trajectory_animation" respawn="true">
        <param name="file" value="$(arg file)" if="$(eval file[0] == '/')" />
        <param name="file" value="$(env PWD)/$(arg file)" unless="$(eval file[0] == '/')" />
    </node>
</launch>

Of course it would be nicer to have direct support for this mechanism in roslaunch (also in bash completion...) via something like <arg type="file", but someone would have to implement it of course.