Ask Your Question

How to inherit a ROS package

asked 2016-03-16 04:58:52 -0500

Cerin gravatar image

How do you include and customize a third party ROS package without literally copying the files into your catkin workspace?

All the docs I see for adding pre-built packages to your project say to checkout the package into your workspace, but this feels wasteful and prone to maintenance problems, since you're forced to now maintain a fork of the original project add your custom configurations directly to it, making upstream merges potentially difficult.

Is that really the standard practice or is there a better way?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-16 05:35:11 -0500

mgruhler gravatar image

updated 2016-03-16 11:28:24 -0500

(1) If the upstream package can be installed from apt-get, you can find_package the respective package in your CMakeLists.txt and use the exported libraries and headers in your code.

(2) If you only want to configure a package, simply create a new package containing the respective launch and config files.

(3) If you, however, want to customize a package, i.e. changing the code, there is no other way then to clone it to your workspace. You should try to bring your changes upstream as fast as possible, if they are general and can be useful to the community.

If option (1) and (2) don't suit your needs, you will need to use option (3) with the potential maintenance problems you mentioned.


again three options:

(1) put the source in the same workspace as your package (you can have multiple repos etc. therein)

(2) create a chained/overlayed workspace, where you put your package in the one which is highest in the hierarchy and the other in the underlay

(3) you can also install packages using catkin_make -DCMAKE_INSTALL_PREFIX=/opt/ros/indigo install, but there might be some performance issues. Check out this page for more info (about in the middle of the page).

I personally would go for option (2) and wouldn't touch option (3) unless you'd really know what you are doing...

edit flag offensive delete link more


I think I'm looking at option 2. However, what if the package isn't installable from apt-get, but the source is publicly accessible from github or elsewhere? How would you install it outside your workspace where catkin can still find it?

Cerin gravatar image Cerin  ( 2016-03-16 10:34:18 -0500 )edit

see edit above

mgruhler gravatar image mgruhler  ( 2016-03-16 11:29:20 -0500 )edit

What about putting third-party packages in an arbitrary folder outside my workspace and then append that path to my ROS_PACKAGE_PATH as outlined here?

Cerin gravatar image Cerin  ( 2016-03-16 11:52:57 -0500 )edit

This is basically option (2). Better use the overlay structure instead of manually manipulating the ROS_PACKAGE_PATH.

I.e. if you are using catkin. For the legacy rosbuild, this was the way to go.

mgruhler gravatar image mgruhler  ( 2016-03-16 12:32:11 -0500 )edit

That tutorial is outdated and only applies to rosbuild packages. You can't use catkin packages just by modifying your ROS_PACKAGE_PATH.

ahendrix gravatar image ahendrix  ( 2016-03-16 12:35:33 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2016-03-16 04:58:52 -0500

Seen: 185 times

Last updated: Mar 16 '16