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

How can I use catkin package resources with the devel space?

asked 2013-01-09 03:06:41 -0500

cdellin gravatar image

updated 2013-01-09 03:24:26 -0500

I'm having trouble using package resources from the devel space of a catkin workspace. After I successfully run catkin_make, I have new build and devel folders. If I source ws/devel/setup.bash, I can then run binaries and use libraries, scripts, etc as I'd expect. But what about package-relative resources?

First question: How to I specify these resources in the package's CMakeLists.txt? I wasn't able to find any examples in the docs. Here's what I've been doing:

$ cat ws/source/path/to/my_package/CMakeLists.txt
...
install(
  DIRECTORY my_resources DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
...

(but of course this isn't used for the devel space, right?)

Second question: How do I find these resources if I'm using the devel space?

My first try was rospack. Here's the result:

$ rospack find my_package
ws/build/path/to/my_package/catkin_generated/stamps/my_package

This location doesn't hold any resources (copies or links to the source space). (Or should it?)

I also stumbled upon catkin_find. Here's the result:

$ catkin_find my_package
ws/devel/share/my_package
ws/source/path/to/my_package

I suppose the second one is what I want? Is this always the right thing to do?

Sidenote: It appears through some magic that roslaunch knows where to look for launch files (or does it search everything in the catkin_find list?).

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-01-09 03:26:52 -0500

KruseT gravatar image

You are right that things listed in CMakeLists.txt with an install(...) macro does not automatically get moved into the devel space.

catkin_find can help you, it takes more arguments, like:

$ catkin_find roscpp package.xml
$ catkin_find roscpp srv/Empty.srv

It will search folders in a specific order to find what you look for. catkin_find is based on the CMAKE_PREFIX_PATH and the contents of a file called .catkin in your devel space.

Not sure whether there is a cleaner way to refer to other packages (cmake, python).

edit flag offensive delete link more

Comments

Fantastic! This was just what I needed. This was difficult to find because the catkin_find usage message uses the word "project", whereas it would make more sense to me (as a ROS user, not a cakin dev) if it were the word "package" instead.

cdellin gravatar image cdellin  ( 2013-01-09 05:06:23 -0500 )edit
1

answered 2013-01-09 12:14:11 -0500

Dirk Thomas gravatar image

updated 2013-01-09 12:15:09 -0500

If you need a way to find these resource in cases where you do not know if the package is catkinized or not you can use this code which works for all ROS distros:

import rospkg
rp = rospkg.RosPack()
path = rp.get_path('my_package')```

The resulting path will either point to the source folder or the install folder of the package.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-01-09 03:06:41 -0500

Seen: 1,840 times

Last updated: Jan 09 '13