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

Revision history [back]

You can get the base_directory from roslib. In Python it is something like:

DIR = roslib.packages.get_pkg_dir("your_package_name", required=True)

So you can retrieve your file by using DIR + "/folder_where_file_is/" + "filename.avi" (You can use a similar code in C++ as the string class overrides the + operator).

Bear in mind that when you do "rosrun pkg executable" then the current directory is the process cwd, so if you run it from your home that is where the file will be searched for. Alternatively you can use absolute paths, like "/home/yourname/path_to_file/file.avi".

Bear in mind that the above solutions are in decreasing order of portability and in increasing order of troublemakingability (I guess you won't find this word in the Oxford dictionary).