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

How to import files to ROS package with catkin?

asked 2014-03-26 09:06:38 -0600

chet gravatar image

updated 2014-03-26 09:06:57 -0600

This is my first ROS package and I think this is a pretty easy question but I'm not sure how to most appropriately do this:

I am trying to build a ROS package with GTSAM:

which requires Boost C++ to be installed:

Both libraries are installed in my /usr/local/ directory. I'd like to use these libraries in my ROS package but I'm not sure the proper way of doing so. Should I just #include as usual and have a readme saying to install these libraries before using this ROS package? Or should include the installation in my ROS package directory?

Sorry for the noob question and thanks for the help.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-03-26 10:14:24 -0600

ahendrix gravatar image

You'll want to declare dependencies on both packages in your package.xml, and then use the find_package() command in CMake to locate them and add the appropriate include directories and libraries to your project.

There's a fairly good catkin build on how to declare and use external dependencies:

It looks like GTSAM is already a CMake package, so you should be able to use find_package with it without issues. I did a quick google search and found someone at Georgia Tech doing this from rosbuild: ; you'll probably need to change the rosbuild macros to normal cmake macros, but otherwise you should be able to do something similar.

Since you're installed GTSAM from source, and most of the other people that use your package will probably do the same thing, you may not want to declare your dependency on gtsam in your package.xml ; this will prevent the ROS tools from trying to verify that it's installed, which is difficult to do for source packages.

If you do get to a point where you'd like to release your package to the ROS build farm, you'll probably want to get the GTSAM maintainers to release it as a plain CMake package into ROS. This is fairly easily done through Bloom.

Side notes on Boost:

  • ROS depends on Boost. You may hit issues if you try to compile against a different version of Boost than the rest of ROS.
  • If you're on a Mac and have Boost installed through homebrew, you should be fine with the usual procedure. You'll be using the same version of Boost that the rest of ROS.
  • If you're on a different system, you'll probably hit issues if you're trying to depend on a different version of Boost than the rest of ROS.
  • If you don't need any of the features in the latest version of Boost, I would strongly suggest trying to use the system version of Boost
  • If you REALLY need a newer version of Boost, you can try to build all of ROS from source against the newer version to avoid version conflicts.
edit flag offensive delete link more

answered 2014-03-26 09:57:32 -0600

Wolf gravatar image

You can embed external lib packages using standard cmake (find_package, include_directories and target_link_libraries). I think both mentioned packages provide a " config.cmake" file. If these files are in the CMAKE_PREFIX_PATH they can be found just like it is described for the OpenCV package in the answer of this question:

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-03-26 09:06:38 -0600

Seen: 1,513 times

Last updated: Mar 26 '14