实验环境ubuntu 14.04+ros indigo
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
在’src’目录中可能没有任何软件包,只有一个CMakeLists.txt,依然可以编译它:
$ cd ~/catkin_ws/
$ catkin_make
在主文件夹下ctrl+h后找到隐藏文件夹.bashrc。在.bashrc 最下面添加
source /opt/ros/indigo/setup.bash`
source ~/catkin_ws/devel/setup.bash`
[usb_cam下载链接] (https://github.com/bosch-ros-pkg/usb_cam)
把usb_cam放到catkin_ws/src下
$ cd catkin_ws/src/usb_cam
$ mkdir build
$ cd build
$ cmake ..
$ make
[orb_slam2 下载链接] ( https://github.com/raulmur/ORB_SLAM2 )
安装orb slam2依赖
安装 g++11
$ sudo apt-get install gcc g++
安装 Pangolin
$ sudo apt-get install libglew-dev #安装Glew
$ sudo apt-get install cmake #安装CMake
$ sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev #安装Boost
$ sudo apt-get install libpython2.7-dev #安装Python2'Python3
下载、编译、安装Pangolin:
$ git clone https://github.com/stevenlovegrove/Pangolin.git
$ cd Pangolin
$ mkdir build
$ cd build
$ cmake -DCPP11_NO_BOOST=1 ..
$ make
$ sudo make install
注意:Pangolin最新版本会编译失败请使用旧版本
$sudo apt-get update
$sudo apt-get install libcv-dev
安装Eigen
$ sudo apt-get install libeigen3-dev
BLAS and LAPACK
$ sudo apt-get install libblas-dev
$ sudo apt-get install liblapack-dev
$ git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
$ cd ORB_SLAM2
$ chmod +x build.sh
$ ./build.sh
生成的libORB_SLAM2.so位于lib目录下,可执行程序mono_tum, mono_kitti, rgbd_tum, stereo_kitti, mono_euroc and stereo_euroc位于Examples目录下。
$ roslaunch usb_cam usb_cam-test.launch
进入~/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src
打开 ros_mono.cc 把程序里面的topic改为 /usb_cam/image_raw
具体还要查看自己的rviz(即上一步打开的摄像头窗口的标题)
然后进入~/catkin_ws/src/ORB_SLAM
$ chmod +x build_ros.sh
$ ./build_ros.sh
$ ~/catkin_ws/src/ORB_SLAM2$ rosrun ORB_SLAM2 Mono /home/caylaxu/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/caylaxu/catkin_ws/src/ORB_SLAM2/my.yaml
有两个参数,第二个参数是相机参数文件,根据自己的相机参数修改。
都上一步为止已经成功跑起来了,我们来玩点好玩的吧
参照step4启动摄像头然后执行一下命令
~/catkin_ws/src/ORB_SLAM2$ rosrun ORB_SLAM2 MonoAR /home/caylaxu/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/caylaxu/catkin_ws/src/ORB_SLAM2/my.yaml
如果没有界面出来不要着急,参照step5 打开 ros_mono_ar.cc把程序里面的topic改为 /usb_cam/image_raw
具体还要查看自己的rviz(即上一步打开的摄像头窗口的标题)
然后进入~/catkin_ws/src/ORB_SLAM
$ chmod +x build_ros.sh $ ./build_ros.sh
首先确保SLAM ON 然后点击添加物体,最终效果如下