设为首页 加入收藏

TOP

ROS Kinetic下编译安装ORB_SLAM2(一)
2019-03-02 20:08:05 】 浏览:601
Tags:ROS Kinetic 编译 安装 ORB_SLAM2

ROS版本:  Kinetic


2.新建一个WorkSpace
$ mkdir catkin_ws
$ cd ./catkin_ws
$ mkdir src


3.设定src为工作空间,在src目录下:
$ catkin_init_workspace


切记,Python 中一定要安装catkin_pkg模块
pip install catkin_pkg

pip3 install catkin_pkg


安装一些依赖项:
sudo apt install autotools-dev ccache doxygen dh-autoreconf git liblapack-dev libblas-dev libgtest-dev libreadline-dev libssh2-1-dev pylint clang-format-3.8
python-autopep8 python-catkin-tools python-pip python-git python-setuptools python-termcolor python-wstool --yes


5.下载ORB_SLAM2源码:
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2


6.将ORB_SLAM2文件移入catkin_ws/src下
$ sudo mv ORB_SLAM2 ./catkin_ws/src


7.安装ORB_SLAM2,Ranul Mur-Artal大神的github(https://github.com/raulmur/ORB_SLAM2)中写的很清楚了
cd ORB_SLAM2
chmod +x build.sh
./build.sh


8.编译安装ROS版的ORB_SLAM2,在ORB_SLAM2目录下:
chmod +x build_ros.sh
./build_ros.sh


此时就开始有坑了,可能会出现一下错误:
CMake Error at /opt/ros/kinetic/share/ros/core/rosbuild/public.cmake:129 (message):


  Failed to invoke rospack to get compile flags for package 'ORB_SLAM2'.
  Look above for errors from rospack itself.  Aborting.  Please fix the
  broken dependency!


Call Stack (most recent call first):
  /opt/ros/kinetic/share/ros/core/rosbuild/public.cmake:207 (rosbuild_invoke_rospack)
  CMakeLists.txt:4 (rosbuild_init)
-- Configuring incomplete, errors occurred!


此时记得在 ~/.bashrc末尾添加:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS


  其中PATH是自己的工作空间路径(/home/(user名)/catkin_ws/src),然后记得:
$ source ~/.bashrc


还没解决的话,使用以下命令:
$ sudo rosdep fix-permissions
$ rosdep update




然后继续编译,可能又会出现一个坑,心累~:
MakeFiles/Makefile2:718: recipe for target 'CMakeFiles/Mono.dir/all' failed
make[1]: *** [CMakeFiles/Mono.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** No rule to make target '/opt/ros/kinetic/lib/libopencv_calib3d3.so.3.2.0', needed by '../RGBD'. Stop.
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/RGBD.dir/all' failed
make[1]: *** [CMakeFiles/RGBD.dir/all] Error 2
make[2]: *** No rule to make target '/opt/ros/kinetic/lib/libopencv_calib3d3.so.3.2.0', needed by '../Stereo'. Stop.
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/Stereo.dir/all' failed
make[1]: *** [CMakeFiles/Stereo.dir/all] Error 2


解决办法:修改ORB_SLAM2/Examples/ROS/ORB_SLAM2中CMakelists.txt,在set那里添加-lboost_system:


set(LIBS
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so
-lboost_system
)


然后在编译,就能够成功了.


如果要在ROS下利用自己的摄像头跑ORB_SLAM2,那麽还需要安装usb_cam


下载链接(https://github.com/ros-drivers/usb_cam),下载下来,一样的移到src下


或这在src下利用git命令   


git clone https://github.com/bosch-ros-pkg/usb_cam.git


编译usb_cam:
$ mkdir build
$ cd build
$ cmake ..
$ make


打开摄像头,需要启动ros,在两个不同的终端分别执行以下命令:
$ roscore
$ roslaunch usb_cam usb_cam-test.launch


这样,就能启动摄像头了,其中,我们可以打开位于usb_cam/launch下的launch文件:
<launch>
  <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
    <param name="video_device" value="/dev/video1" />
    <param name="image_width" value="1280
编程开发网

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Ubuntu 16.04下C++调用Python3.5.. 下一篇编译安装DSO并在线运行摄像头

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

array(4) { ["type"]=> int(8) ["message"]=> string(24) "Undefined variable: jobs" ["file"]=> string(32) "/mnt/wp/cppentry/do/bencandy.php" ["line"]=> int(217) }