码迷,mamicode.com
首页 > 其他好文 > 详细

rtabmap ros包编译

时间:2015-05-14 16:44:10      阅读:588      评论:0      收藏:0      [点我收藏+]

标签:ros   slam   

     今天在优酷看到关于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

rtabmap ros包编译

标签:ros   slam   

原文地址:http://blog.csdn.net/zyh821351004/article/details/45719541

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!