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

Catkinize GTSAM

asked 2018-04-01 17:29:07 -0600

alavin89 gravatar image

GTSAM is a useful library for SLAM and I'd like to include it in my project (which I build with catkin build my_project). GTSAM is a cmake library, so how can I "catkinize" it? That is, I would like to edit the current gtsam/CMakeLists.txt such that when I run catkin build my_project GTSAM gets installed and I can include its headers within my_project source files.

I've been through catkin docs and other questions (e.g.), but at this point I'm guessing blindly what lines to enter and where. Thanks in advance for any help!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-04-02 10:13:32 -0600

alavin89 gravatar image

The suggestions by @gvdhoorn are valid and a good approach, but given the constraint on installing GTSAM via catkin_build here is a solution:

Add to the top of the current gtsam/CMakeLists.txt add,

cmake_minimum_required(VERSION 2.8.3)

find_package(catkin REQUIRED COMPONENTS)


and at the bottom,

        PATTERN ".cpp" EXCLUDE
        PATTERN ".txt" EXCLUDE
        PATTERN ".in" EXCLUDE
        PATTERN ".dox" EXCLUDE

And the package.xml should be updated to reflect catkin: <buildtool_depend>catkin</buildtool_depend>.

edit flag offensive delete link more

answered 2018-04-02 01:19:40 -0600

gvdhoorn gravatar image

updated 2018-04-02 01:24:00 -0600

This may not be the answer you were expecting, but in short: I wouldn't catkinise GTSAM. it's not needed.

Treat it as a system dependency, meaning that you'd treat it as just about any other "non-ROS" library. See wheher CMake already has a FindGTSAM.cmake (or whether someone else has written one) and add a find_package(GTSAM REQUIRED) to your CMakeLists.txt.

Then add ${GTSAM_LIBRARIES} to your target_link_libraries(..) and ${GTSAM_INCLUDE_DIRECTORIES} to include_directories(..).

That should do it.

Edit: see #q263158 for an earlier question about this (which links to stackoverflow/44395859).

See CognitiveRobotics/omnimapper/CMakeLists.txt for an example that shows the system dependency approach (but note that repository is a bit old).

If you really want/need to, you could take a look at RoboStat/gtsam-in-ros.

edit flag offensive delete link more


Thank you these are useful tips. I agree for most people it's probably best not to catkinize GTSAM, but my workspace builds beautifully because we catkinize everything. Another useful link: gtsam_catkin middleman repo.

alavin89 gravatar image alavin89  ( 2018-04-02 10:16:01 -0600 )edit

I don't really understand how "catkinise everything" is any better than rosdep install --from-paths .. -i, but if you're happy, then ok.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-03 05:06:16 -0600 )edit

Question Tools

1 follower


Asked: 2018-04-01 17:29:07 -0600

Seen: 1,591 times

Last updated: Apr 02 '18