Robotics StackExchange | Archived questions

How include resources in catkin package script?

Suppose that I have a package "mypack" and at "mypack\scripts" there are python scripts and at "mypack\scripts\resources" there are some files (.png, .txt, etc) that are used by my script. Is there a way to import these resources without need FULL path (\home\user\catkin\src\mypack\scripts\resources\file)?

Obs. Relative path (\resources\file) only works when I use ROSRUN inside scripts, ROSLAUNCH don't.

To solve this I import rospkg and get the package path (\home\user\catkin\src\mypack) + "\scripts\resources", but I would like to know if there is a more pythonic way to do this.

Asked by Hieronix on 2015-11-07 10:48:28 UTC

Comments

Answers

You could have a look at the roslib.package example. It contains examples for both python adn C++. So for python: roslib.packages.get_pkg_dir('mypack')

Asked by MartinK on 2017-07-04 06:15:34 UTC

Comments