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

Locate CATKIN_PACKAGE_SHARE_DESTINATION in devel space

asked 2020-06-12 10:51:07 -0600

tomlankhorst gravatar image

I have a package that needs some binary resources at run-time.

In CMakeLists.txt, I install:

install( DIRECTORY resources/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/resources )

I would find them in/opt/ros/..../share/pkg/resources.

That works fine when installing the package.

However, how would I locate these resources during development? They are not installed in the devel/share location.

edit retag flag offensive close merge delete

Comments

Dirk Thomas gravatar image Dirk Thomas  ( 2020-06-12 11:55:15 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-06-12 11:55:18 -0600

Dirk Thomas gravatar image

Depending on your programming language there is API to get the path of your package which is the directory containing the package.xmlfile: see https://wiki.ros.org/Packages#Client_...

Python:

import rospkg
rospack = rospkg.RosPack()
rospack.get_path('your_package_name')

C++:

#include <ros/package.h>
std::string path = ros::package::getPath("your_package_name");

And in your case the relative path of resources is the same so you should be easily able to construct the path you want which works for both cases - the devel / src as well as the install space.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2020-06-12 10:51:07 -0600

Seen: 1,252 times

Last updated: Jun 12 '20