rtabmap ros包编译

今天在优酷看到关于rtabmap ros包跑起来的视频。里面有闭环检测,所以想跑跑,看看相应的代码。。

安装过程有一点问题:

1.打开wiki 看看:

2. 打开github.

3.  依据连接  https://github.com/introlab/rtabmap_ros 进行安装。。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RTAB-Map (Real-Time Appearance-Based Mapping) is a RGB-D Graph SLAM approach based on a global Bayesian loop closure detector. The loop closure detector uses a bag-of-words approach to determinate how likely a new image comes from a previous location or
a new location. When a loop closure hypothesis is accepted, a new constraint is added to the map‘s graph, then a graph optimizer minimizes the errors in the map. A memory management approach is used to limit the number of locations used for loop closure detection
and graph optimization, so that real-time constraints on large-scale environnements are always respected. RTAB-Map can be used alone with a hand-held Kinect or stereo camera for 6DoF RGB-D mapping, or on a robot equipped with a laser rangefinder for 3DoF mapping.

Installation

ROS distribution

RTAB-Map is released as binaries in the ROS distribution.

  • Indigo$ sudo apt-get install ros-indigo-rtabmap-ros
  • Hydro$ sudo apt-get install ros-hydro-rtabmap-ros

Build from source

This section shows how to install RTAB-Map ros-pkg on ROS Hydro/Indigo (Catkin build). RTAB-Map works only with the PCL 1.7, which is the default version installed with ROS Hydro/Indigo (Fuerte and Groovy are not supported).

  • Note for ROS Indigo: If you want SURF/SIFT, you have to build OpenCV from source to have access to
    nonfree module. Install it in /usr/local (default) and the rtabmap library should link with it instead of the one installed in ROS.

find_package( OpenCV REQUIRED )   在cmakelist.txt中

  • The next instructions assume that you have setup your ROS workspace using this
    tutorial. The workspace path is ~/catkin_ws and your ~/.bashrc contains:

    source /opt/ros/hydro/setup.bash
    source ~/catkin_ws/devel/setup.bash
  1. First, you need to install the RTAB-Map standalone libraries (don‘t checkout in the Catkin workspace but install in your Catkin‘s devel folder).

    $ cd ~
    $ git clone https://github.com/introlab/rtabmap.git rtabmap    【不要以catkin_make 的形式放到src下】
    $ cd rtabmap/build
    $ cmake -DCMAKE_INSTALL_PREFIX=~/catkin_ws/devel ..  [<---double dots included          注意生成的位置]
    $ make -j4
    $ make install
  2. Now install the RTAB-Map ros-pkg in your src folder of your Catkin workspace.
    $ cd ~/catkin_ws
    $ git clone https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
    $ catkin_make

Update to new version

$ cd rtabmap

$ git pull origin master
$ cd build
$ make
$ make install

$ roscd rtabmap_ros
$ git pull origin master
$ cd ~/catkin_ws
$ catkin_make

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

直接以它的cmakelists 安装会出现

undefined reference to `cv::ocl::integral(cv::ocl::oclMat const&, cv::ocl::oclMat&)‘   等一些问题  。。。这都是opencv的一些问题,所以加了自己安装的opencv

find_package( OpenCV REQUIRED )   在cmakelist.txt中  库依赖加opencv..  见后面改的cmakelist .

//

还是出现错误,后goole搜索 参考 https://code.google.com/p/rtabmap/issues/detail?id=8

Found that there some extra steps to install on ROS indigo. Note that ROS indigo is not officially released yet... it seems that ROS indigo doesn‘t provide its own opencv binaries like in ROS hydro where OpenCV is built with "nonfree" module (required by
rtabmap). So OpenCV should be installed manually to have "nonfree" module. By doing so, rtabmaplib can build but the ros-pkg use catkin opencv links from "cv_bridge" package (which seems to link to opencv installed through apt-get and not the one compiled
manually).

Workaround:

-Uninstall all opencv packages in synaptic.

-This will remove also ros-indigo-vision-opencv, so we need to compile it and linking to our OpenCV installed manually. So in catkin workspace:

$ roscd

$ cd ..

$ git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv

$ catkin_make

~~~~~~~~~~~~~~~~~~~~~~~~~~~

编译通过。。

cmake_minimum_required(VERSION 2.8.3)
project(rtabmap_ros)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages

find_package( OpenCV REQUIRED )
find_package(catkin REQUIRED COMPONENTS
             cv_bridge roscpp rospy sensor_msgs std_msgs std_srvs nav_msgs geometry_msgs visualization_msgs
             image_transport tf tf_conversions laser_geometry pcl_conversions
             pcl_ros nodelet dynamic_reconfigure rviz message_filters class_loader
             genmsg stereo_msgs move_base_msgs
)

# Optional components
find_package(costmap_2d)
find_package(octomap_ros)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
find_package(RTABMap 0.9.0 REQUIRED)

#Qt stuff
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED)
INCLUDE(${QT_USE_FILE})

## We also use Ogre
include($ENV{ROS_ROOT}/core/rosbuild/FindPkgConfig.cmake)
pkg_check_modules(OGRE OGRE)
include_directories( ${OGRE_INCLUDE_DIRS} )
link_directories( ${OGRE_LIBRARY_DIRS} )

## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()

#######################################
## Declare ROS messages and services ##
#######################################

## Generate messages in the 'msg' folder
add_message_files(
   FILES
   Info.msg
   KeyPoint.msg
   MapData.msg
   Graph.msg
   NodeData.msg
   Link.msg
   OdomInfo.msg
   UserData.msg
   Point2f.msg
)

## Generate services in the 'srv' folder
 add_service_files(
   FILES
   GetMap.srv
   ListLabels.srv
   PublishMap.srv
   ResetPose.srv
   SetGoal.srv
   SetLabel.srv
 )

## Generate added messages and services with any dependencies listed here
generate_messages(
   DEPENDENCIES
   std_msgs
   geometry_msgs
   sensor_msgs
)

#add dynamic reconfigure api
generate_dynamic_reconfigure_options(cfg/Camera.cfg)

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
  INCLUDE_DIRS include
  LIBRARIES rtabmap_ros
  CATKIN_DEPENDS cv_bridge roscpp rospy sensor_msgs std_msgs std_srvs nav_msgs geometry_msgs visualization_msgs
                 image_transport tf tf_conversions laser_geometry pcl_conversions
                 pcl_ros nodelet dynamic_reconfigure rviz message_filters class_loader
                 stereo_msgs move_base_msgs
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}/include
  ${RTABMap_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
)

# libraries
SET(Libraries
   ${catkin_LIBRARIES}
   ${RTABMap_LIBRARIES}
)

## RVIZ plugin
qt4_wrap_cpp(MOC_FILES
  src/rviz/MapCloudDisplay.h
  src/rviz/MapGraphDisplay.h
  src/rviz/InfoDisplay.h
  src/rviz/OrbitOrientedViewController.h
)

# tf:message_filters, mixing boost and Qt signals
set_property(
   SOURCE src/rviz/MapCloudDisplay.cpp src/rviz/MapGraphDisplay.cpp src/rviz/InfoDisplay.cpp src/rviz/OrbitOrientedViewController.cpp
   PROPERTY COMPILE_DEFINITIONS QT_NO_KEYWORDS
   )

SET(rtabmap_ros_lib_src
   src/nodelets/data_throttle.cpp
   src/nodelets/stereo_throttle.cpp
   src/nodelets/data_odom_sync.cpp
   src/nodelets/point_cloud_xyzrgb.cpp
   src/nodelets/point_cloud_xyz.cpp
   src/nodelets/disparity_to_depth.cpp
   src/nodelets/obstacles_detection.cpp
   src/MsgConversion.cpp
   src/OdometryROS.cpp
   src/rviz/MapCloudDisplay.cpp
   src/rviz/MapGraphDisplay.cpp
   src/rviz/InfoDisplay.cpp
   src/rviz/OrbitOrientedViewController.cpp
   ${MOC_FILES}
)   

# If costmap_2d is found, add the plugin
IF(costmap_2d_FOUND)
MESSAGE(STATUS "WITH costmap_2d")
include_directories(${costmap_2d_INCLUDE_DIRS})
SET(Libraries
  ${costmap_2d_LIBRARIES}
  ${Libraries}
  )
SET(rtabmap_ros_lib_src
  src/costmap_2d/static_layer.cpp
  ${rtabmap_ros_lib_src}
  )
ENDIF(costmap_2d_FOUND)

## Declare a cpp library
add_library(rtabmap_ros
   ${rtabmap_ros_lib_src}
)
target_link_libraries(rtabmap_ros
  ${Libraries}
  ${QT_LIBRARIES}
  ${OGRE_LIBRARIES}
)
add_dependencies(rtabmap_ros rtabmap_generate_messages_cpp)

# If octomap is found, add definition
IF(octomap_ros_FOUND)
MESSAGE(STATUS "WITH octomap")
include_directories(
  ${octomap_ros_INCLUDE_DIRS}
)
SET(Libraries
  ${octomap_ros_LIBRARIES}
  ${Libraries}
)
add_definitions(-DWITH_OCTOMAP)
ENDIF(octomap_ros_FOUND)

add_executable(rtabmap src/CoreNode.cpp src/CoreWrapper.cpp)
add_dependencies(rtabmap rtabmap_generate_messages_cpp)
target_link_libraries(rtabmap rtabmap_ros ${Libraries} ${OpenCV_LIBS} )

add_executable(rgbd_odometry src/RGBDOdometryNode.cpp)
target_link_libraries(rgbd_odometry rtabmap_ros ${Libraries} ${OpenCV_LIBS} )

add_executable(stereo_odometry src/StereoOdometryNode.cpp)
target_link_libraries(stereo_odometry rtabmap_ros ${Libraries} ${OpenCV_LIBS} )

add_executable(map_optimizer src/MapOptimizerNode.cpp)

target_link_libraries(map_optimizer rtabmap_ros ${Libraries} ${OpenCV_LIBS} )

add_executable(map_assembler src/MapAssemblerNode.cpp)
add_dependencies(map_assembler ${${PROJECT_NAME}_EXPORTED_TARGETS} ${OpenCV_LIBS} )
target_link_libraries(map_assembler rtabmap_ros ${Libraries} ${OpenCV_LIBS} )

add_executable(grid_map_assembler src/GridMapAssemblerNode.cpp)
target_link_libraries(grid_map_assembler rtabmap_ros ${Libraries} ${OpenCV_LIBS} )

add_executable(camera src/CameraNode.cpp)
target_link_libraries(camera ${Libraries} ${OpenCV_LIBS})

add_executable(rtabmapviz src/GuiNode.cpp src/GuiWrapper.cpp src/PreferencesDialogROS.cpp)
target_link_libraries(rtabmapviz rtabmap_ros ${QT_LIBRARIES} ${Libraries}  )

add_executable(data_player src/DbPlayerNode.cpp)
target_link_libraries(data_player rtabmap_ros ${QT_LIBRARIES} ${Libraries} ${OpenCV_LIBS} )

add_executable(odom_msg_to_tf src/OdomMsgToTFNode.cpp)
target_link_libraries(odom_msg_to_tf rtabmap_ros ${Libraries} ${OpenCV_LIBS} )

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
#   scripts/my_python_script
#   DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables and/or libraries for installation
install(TARGETS
   rtabmap_ros
   rtabmap
   rtabmapviz
   rgbd_odometry
   stereo_odometry
   map_assembler
   grid_map_assembler
   map_optimizer
   data_player
   camera
   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
 )

## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
   FILES_MATCHING PATTERN "*.h"
   PATTERN ".svn" EXCLUDE
)

## Mark other files for installation (e.g. launch and bag files, etc.)
install(FILES
   launch/rgbd_mapping.launch
   launch/data_recorder.launch
   launch/rgbd_mapping_kinect2.launch
   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
)
install(DIRECTORY
   launch/config
   launch/data
   launch/demo
   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
)

## install plugins/nodelets xml
install(FILES
   nodelet_plugins.xml
   plugin_description.xml
   costmap_plugins.xml
   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_rtabmap.cpp)
# if(TARGET ${PROJECT_NAME}-test)
#   target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

参考:

1.wiki_ros

http://wiki.ros.org/rtabmap         http://wiki.ros.org/rtabmap_ros

2.github

https://github.com/introlab/rtabmap

https://github.com/introlab/rtabmap_ros

时间: 2024-10-13 19:07:46

rtabmap ros包编译的相关文章

创建一个ROS包

先前笔者不知道catkin到底是个什么东东,后来终于在官方网站上找到了答案,原来catkin是ROS的一个官方的编译构建系统,是原本的ROS的编译构建系统rosbuild的后继者.catkin的来源有点复杂,我们可以慢慢的讲一下其中的渊源.ROS来源于Willow Garage这个公司,他们希望借助开源的力量,使ROS发扬光大.而在英语中,willow的意思是柳树,catkin是柳絮的意思,为了纪念的作用吧,因而为这个软件命名为catkin.      这篇博客的主要内容是介绍如何使用catki

一个ros包依赖另一个ros包提供的库

背景: 编写一个点云配准的ros包,记为A,在其中打算使用多种点云配准算法. 同一个ros工作空间下有另一个ros包,记为B,B中提供了几种点云配准算法,并将它们都编译成一个库文件并安装在工作空间中. 实施情况: 在A的代码中,include ros包B所提供的头文件,同时要对A的CMakeLists.txt和package.xml做如下修改, CMakeLists.txt find_package(catkin REQUIRED COMPONENTS ndt_registration ) ca

liunx命令6 vim编辑、压缩命令、rpm、yum及源码包编译安装

[[email protected] ~]# yum install -y vim-enhanced vim打开文件编辑(有颜色) [[email protected] ~]# vim  !$                   //上一条命令的最后一条参数 [[email protected] ~]# vim +10 !$                //打开文件进入第十行 :set number                                 //显示行号 vim 一般模式

异常的学习笔记+打包+doc的包编译

jvm默认的异常处理机制就是调用printStackTrace方法 对于多异常的处理.应该是定义更具体的异常来捕捉捕捉问题 捕获异常代码块出现继承关系 应该把被继承的异常放在子类异常块的后面 throw 和 throws的区别 throw是是用在函数上,而throws是使用在函数内 throw后面跟的是异常对象,而throws跟的是异常类可以 多个 对异常的分类: 1.编译时被检测到的异常. (值得去处理的异常,或者是希望得到调用者处理,并不影响运算意向) 2.编译时不被检测到的异常(运行时异常

Linux学习之建立yum源、yum命令的使用及rpm包编译安装

一.什么是Yum Yum的全称为 Yellowdog Update Modifier,其主要目的是为了解决RPM包安装时的依赖关系的问题.yum只是一个用于软件安装的前端工具,其主要的服务对象还是RPM软件包. 二.yum配置客户端         1.主配置文件(中心配置文件):/etc/yum.conf.              通常不需要进行修改,保持其默认配置即可.         2.提供repo配置文件,指明仓库访问路径及各种属性信息.              在目录/etc/y

源码包编译安装mariaDB

前言 MySQL是一个关系型数据库管理系统,是最流行的关系型数据库管理系统,由于其体积小.速度快.总体拥有成本低,并且之前是完全开源,所以大受欢迎.但由于后面MySQL卖给了SUN,随后SUN被Oracle收购,虽然也有开源免费版本,但是很多功能都需要另外购买商业版本,导致现在MySQL使用份额逐渐减少.所以MariaDB就是因为这种原因诞生出来,成为数据库管理系统是MySQL的一个分支. 先前已经使用二进制安装了mariaDB(详细请查看http://www.178linux.com/8787

源码包编译安装之--实战

最近安装公司安排很多程序让源码安装的活,今天和大家分享一下. 本文就以nginx为例进行源码安装的讲解: 解压: 1.# tar xf nginx-1.4.7.tar.gz{xz|bz2|gz} 2.# cd nginx-1.4.7 ./configure 还需通过许多选项指定编译特性 查看: ./configure--help --prefix=PATH        setinstallation prefix     nginx安装路径 --prefix=PATH        set i

在Editplus中配置java的(带包)编译(javac)和执行(java)的方法

配置的前提是电脑安装了JDK而且配置好了相关的环境变量(JAVA_HOME,path和classpath). 配置好后在命令行中输入javac和java验证是否配置成功: 假设出现上面的情况则说明配置成功. 首先打开Editplus,打开工具-配置自己定义工具(或者使用快捷键Alt+G): 然后点击"组名",将Group 1改为"Java编译与执行": 然后点击"加入工具"-"程序": 1加入编译功能 "菜单文字&q

CentOS程序包管理器rpm、yum以及程序包编译安装详解

一.程序包管理器RPM和Yum简介 程序包管理器:将编译好的应用程序的各组成文件打包成一个或几个程序包文件,可以更方便地实现程序包的安装.升级.卸载和查询等管理操作. rpm软件包管理器(RPM Package Manager):rpm包存在依赖关系,依赖关系复杂,安装时间很长,虽然可以忽略依赖关系,但是可能会导致程序包安装后无法正常使用. yum程序包管理器( Yellow dog Updater, Modified):yum是基于RPM包管理,自动解决程序包间的依赖关系.根据配置文件的资源地