# Supplying filename arguments to launch files

I have a node that has a filename as a private parameter. The files can be located anywhere and have really long filenames. What I would like to do is

$roslaunch package_name launch_file.launch file:=reallylongfilename12345932.txt  where I running this command from the directory containing the file, so I can take advantage of tab-completing the filenames. I have an arg in my launch file called file that accepts this filename, but not the path. As a result, my node cannot open the file because it doesn't have the full path, just the name. Short of hardcoding in the path in the launch file, and being able to tab-complete the long file names, is there a way I can pass the full path of the file to my parameter? edit retag close merge delete ## 2 Answers Sort by » oldest newest most voted You can create a script that takes the name of the file as a parameter and forms the correct roslaunch call with the full path. So, if you have a package "mypackage", a launchfile "test.launch", than you could create a script mypackage/scripts/helper.bash : #!/bin/bash if [ "$1" != "" ]; then
echo "Full path to the file:"
echo "$PWD/$1"

roslaunch mypackage test.launch file:="$PWD/$1"
else
echo "\$0: file not specified"
fi


If you want to pass the filename "filename" from the local directory you could use the following command :

rosrun mypackage helper.bash filename

more

Thanks, this is actually the approach I had taken but I was checking if there was some built-in functionality I didn't know about. Thanks again!

( 2015-06-29 11:32:45 -0600 )edit

When using roslaunch it starts all nodes thinking they are in your ~/.ros/ directory. So you can create a symlink in your ~/.ros/ directory to the actual file you want to load. Then set your arg to look at the symlink by default. When creating the symlink you will be able to use tab completion.

more