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

libg2o in ros hydro

asked 2013-11-19 11:28:47 -0500

smishra gravatar image

updated 2013-11-20 05:17:55 -0500

tfoote gravatar image

Hi all, I'm getting into doing some SLAM development and I am trying to use the libg2o package that I installed using:

sudo apt-get install ros-hydro-libg2o.

But, when I run catkin_make I get:

Could not find module Findlibg2o.cmake or a configuration file for package libg2o.

I have tried setting up my CMakeList.txt file several different ways. The above error was obtained using: find_package(libg2o REQUIRED)

I am running hydro on ubuntu 12.04lts

Thanks

Scott

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-07-11 11:11:42 -0500

pmolina gravatar image

I know this is an old thread but I found a solution on the rgbd-slamv2 code ( http://felixendres.github.io/rgbdslam... )

Indeed you need a create a FindG2O.cmake file and put the code below.

# Locate the g2o libraries
# A general framework for graph optimization.
#
# This module defines
# G2O_FOUND, if false, do not try to link against g2o
# G2O_LIBRARIES, path to the libg2o
# G2O_INCLUDE_DIR, where to find the g2o header files
#
# Niko Suenderhauf <niko@etit.tu-chemnitz.de>
# Adapted by Felix Endres <endres@informatik.uni-freiburg.de>

IF(UNIX)

  IF(G2O_INCLUDE_DIR AND G2O_LIBRARIES)
    # in cache already
    SET(G2O_FIND_QUIETLY TRUE)
  ENDIF(G2O_INCLUDE_DIR AND G2O_LIBRARIES)

  MESSAGE(STATUS "Searching for g2o ...")
  FIND_PATH(G2O_INCLUDE_DIR
    NAMES core math_groups types
    PATHS /usr/local /usr
    PATH_SUFFIXES include/g2o include)

  IF (G2O_INCLUDE_DIR)
    MESSAGE(STATUS "Found g2o headers in: ${G2O_INCLUDE_DIR}")
  ENDIF (G2O_INCLUDE_DIR)

  FIND_LIBRARY(G2O_CORE_LIB             
    NAMES g2o_core 
    PATHS /usr/local /usr 
    PATH_SUFFIXES lib)
  FIND_LIBRARY(G2O_STUFF_LIB            
    NAMES g2o_stuff 
    PATHS /usr/local /usr 
    PATH_SUFFIXES lib)
  FIND_LIBRARY(G2O_TYPES_SLAM3D_LIB     
    NAMES g2o_types_slam3d 
    PATHS /usr/local /usr 
    PATH_SUFFIXES lib)
  FIND_LIBRARY(G2O_SOLVER_CHOLMOD_LIB   
    NAMES g2o_solver_cholmod 
    PATHS /usr/local /usr 
    PATH_SUFFIXES lib)
  FIND_LIBRARY(G2O_SOLVER_PCG_LIB       
    NAMES g2o_solver_pcg 
    PATHS /usr/local /usr 
    PATH_SUFFIXES lib)
  FIND_LIBRARY(G2O_SOLVER_CSPARSE_LIB   
    NAMES g2o_solver_csparse 
    PATHS /usr/local /usr 
    PATH_SUFFIXES lib)
  FIND_LIBRARY(G2O_INCREMENTAL_LIB      
    NAMES g2o_incremental 
    PATHS /usr/local /usr 
    PATH_SUFFIXES lib)
  FIND_LIBRARY(G2O_CSPARSE_EXTENSION_LIB
    NAMES g2o_csparse_extension
    PATHS /usr/local /usr
    PATH_SUFFIXES lib)

  SET(G2O_LIBRARIES ${G2O_CSPARSE_EXTENSION_LIB}
                    ${G2O_CORE_LIB}           
                    ${G2O_STUFF_LIB}          
                    ${G2O_TYPES_SLAM3D_LIB}   
                    ${G2O_SOLVER_CHOLMOD_LIB} 
                    ${G2O_SOLVER_PCG_LIB}     
                    ${G2O_SOLVER_CSPARSE_LIB} 
                    ${G2O_INCREMENTAL_LIB}                        
                    )

  IF(G2O_LIBRARIES AND G2O_INCLUDE_DIR)
    SET(G2O_FOUND "YES")
    IF(NOT G2O_FIND_QUIETLY)
      MESSAGE(STATUS "Found libg2o: ${G2O_LIBRARIES}")
    ENDIF(NOT G2O_FIND_QUIETLY)
  ELSE(G2O_LIBRARIES AND G2O_INCLUDE_DIR)
    IF(NOT G2O_LIBRARIES)
      IF(G2O_FIND_REQUIRED)
        message(FATAL_ERROR "Could not find libg2o!")
      ENDIF(G2O_FIND_REQUIRED)
    ENDIF(NOT G2O_LIBRARIES)

    IF(NOT G2O_INCLUDE_DIR)
      IF(G2O_FIND_REQUIRED)
        message(FATAL_ERROR "Could not find g2o include directory!")
      ENDIF(G2O_FIND_REQUIRED)
    ENDIF(NOT G2O_INCLUDE_DIR)
  ENDIF(G2O_LIBRARIES AND G2O_INCLUDE_DIR)

ENDIF(UNIX)

Also make module and make sure you add it to your CMAKE_MODULE_PATH env variable in cmake. (you can use this line

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/")

I hope this helps.

edit flag offensive delete link more

Comments

Hi,

Could you mention where we are supposed to add the cmake file, and where we need to set CMAKE_MODULE_PATH? Are these in the libg2o package?

Thanks in advance!

Tanmay gravatar image Tanmay  ( 2015-05-26 17:52:06 -0500 )edit

@Tanmay in the rgbdslam project the file is at src/rgbdslam_v2-indigo/cmake-modules/FindG2O.cmake if that helps. my ros distribution is "Indigo" so you may need to change that to whatever distro you're on.

jacksonkr_ gravatar image jacksonkr_  ( 2016-02-12 10:09:41 -0500 )edit
2

answered 2014-02-18 23:27:58 -0500

croesmann gravatar image

updated 2014-02-18 23:28:36 -0500

I had a similar problem in groovy and hydro. After comparing fuerte-libg2o with groovy-libg2o, I found out that in /opt/ros/groovy/share/libg2o the folder cmake is missing. I copied the cmake folder from my fuerte distro and it worked. You can get the relevant files here:

www.dropbox.com/s/l0q4oc7yuk00t92/if_...

In addition, my compiler had problems finding the cs.h. Therefore I used the FindSuiteSparse.cmake script (It is included in if_g2o_is_missed.zip).

Inside CMakeLists.txt I handled libg2o like a common catkin-package and added this:

find_package(SuiteSparse)
if(CSPARSE_FOUND)
  message(STATUS "CSPARSE_IS_FOUND")
else(CSPARSE_FOUND)
  message(STATUS "CSPARSE_NOTFOUND")
endif(CSPARSE_FOUND)

FIND_PACKAGE(libg2o REQUIRED)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${CSPARSE_INCLUDE_DIR}
  ${CHOLMOD_INCLUDE_DIR}
  ${libg2o_INCLUDE_DIRS}
)

 target_link_libraries(node
   ${catkin_LIBRARIES}
   ${CHOLMOD_LIBRARIES}
   ${CSPARSE_LIBRARIES}
    /usr/lib/libcxsparse.so # not included in findSUITESPARSE cmake macro
   ${libg2o_LIBRARIES}
 )

Maybe a better solution would be to create a FindG2O.cmake Hope this helps.

edit flag offensive delete link more
1

answered 2013-11-20 05:18:56 -0500

tfoote gravatar image

updated 2013-12-18 06:59:31 -0500

If it's a catkin package you should be using:

find_package(catkin REQUIRED COMPONENTS libg2o ...)

Edit: It's not a catkin package so what you're doing is right. However it appears that libg20 is not installing it's cmake files which are needed for find_package(G2O) to work.

A ticket should be filed with g2o https://github.com/RainerKuemmerle/g2o/issues

edit flag offensive delete link more

Comments

I tried that first and got an error saying that the package libg2o could not be found

smishra gravatar image smishra  ( 2013-11-20 05:20:44 -0500 )edit

I do not believe libg2o is a catkin package, it should have its own documentation for how to find and use it.

William gravatar image William  ( 2013-11-20 06:47:51 -0500 )edit

After learning a little bit about CMake and find_package, I found that i needed to use a findG2O.cmake module in order for find_package to work

smishra gravatar image smishra  ( 2013-12-03 06:41:20 -0500 )edit

the libg2o.pc file is missing in /opt/ros/hydro/lib/pkgconfig/, is that intentional? My belief is that it should be there...

po1 gravatar image po1  ( 2013-12-18 03:22:19 -0500 )edit
1

libg2o is *not* a catkin package (see build_type in https://github.com/ros-gbp/libg2o-release/blob/release/hydro/libg2o/2013.07.03-2/package.xml#L30). Therefore it may not provide a pkg-config file if the maintainer has not handcrafted one.

Dirk Thomas gravatar image Dirk Thomas  ( 2013-12-18 05:58:07 -0500 )edit

Don't know if it's a good idea or not, but I just filed a request here: https://github.com/ros-gbp/libg2o-release/issues/2 . A pull request might follow

po1 gravatar image po1  ( 2013-12-18 06:05:28 -0500 )edit

has any one solved this problem?

Wilk gravatar image Wilk  ( 2014-01-09 10:08:22 -0500 )edit

I second Wilk, I would be very interested to know what the best solution is for this problem

pnyholm gravatar image pnyholm  ( 2014-05-12 12:23:42 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2013-11-19 11:28:47 -0500

Seen: 5,231 times

Last updated: Jul 11 '14