Ask Your Question
1

Supplying filename arguments to launch files

asked 2015-06-25 11:55:23 -0600

kamek gravatar image

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2015-06-25 17:32:29 -0600

Maxim Rovbo gravatar image

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
edit flag offensive delete link more

Comments

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!

kamek gravatar imagekamek ( 2015-06-29 11:32:45 -0600 )edit
1

answered 2015-06-25 12:45:48 -0600

Thomas D gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-06-25 11:55:23 -0600

Seen: 929 times

Last updated: Jun 25 '15