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

Catkinize GTSAM

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

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
0

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

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)
project(gtsam)

find_package(catkin REQUIRED COMPONENTS)

include_directories(
    gtsam
    ${catkin_INCLUDE_DIRS}
    ${Boost_INCLUDE_DIRS}
)

and at the bottom,

catkin_package()
install(DIRECTORY ${PROJECT_NAME}
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
        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
4

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

gvdhoorn gravatar image

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

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

Comments

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 -0500 )edit
1

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 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 1,642 times

Last updated: Apr 02 '18