使用zed摄像头+ros kinetic跑ORB_SLAM2

  • Post author:
  • Post category:其他


1.zed-ros-wrapper安装

sudo apt-get install libpcl1
sudo apt-get install ros-kinetic-pcl-ros 
cd ~/catkin/src
git clone https://github.com/stereolabs/zed-ros-wrapper
cd ~/catkin
catkin_make zed-ros-wrapper
source ./devel/setup.bash

详情可以查看官方文档

http://wiki.ros.org/zed-ros-wrapper

此外里面列举了该package中可以发布的话题:

  • Left camera


    • /zed/rgb/image_rect_color

      : Color rectified image (left RGB image by default).


    • /zed/rgb/image_raw_color

      : Color unrectified image (left RGB image by default).


    • 5.使用zed的其中的单个摄像头,进行单目slam/zed/rgb/camera_info

      : Camera calibration data.


    • /zed/left/image_rect_color

      : Color rectified left image.



    • /zed/left/image_raw_color

      : Color unrectified left image.


    • /zed/left/camera_info

      : Left camera calibration data.

  • Right camera


    • /zed/right/image_rect_color

      : Color rectified right image.



    • /zed/right/image_raw_color

      : Color unrectified right image.


    • /zed/right/camera_info

      : Right camera calibration data.

  • Depth and point cloud


    • /zed/depth/depth_registered

      : Depth map image registered on left image (by default 32 bits float, in meters).


    • /zed/point_cloud/cloud_registered

      : Registered color point cloud.


    • /zed/confidence/confidence_image

      : Confidence image.


    • /zed/confidence/confidence_map

      : Confidence image. (Floating Point values)


    • /zed/disparity/disparity_image

      : Disparity image

  • Tracking


    • /zed/odom

      : Absolute 3D position and orientaton relative to the odometry frame. (pure visual odometry)


    • /zed/map

      : Absolute 3D position and orientation relative to the map frame. (Sensor Fusion algorithm)

  • Inertial Data


    • /zed/imu/data

      : Accelerometer, Gyroscope and Orientation data in Earth frame.


    • /zed/imu/data_raw

      : Accelerometer and Gyroscope data in Earth frame.

其中标红色的是我本次所使用的两个topic,它们发布的信息格式为sensor_msgs/Image。

2.ORB_SLMA2安装文档

参考链接

https://github.com/raulmur/ORB_SLAM2

  • 安装Pangolin

参考链接

https://github.com/stevenlovegrove/Pangolin

安装依赖:C++11 、OpenGL、 Glew、CMake

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
cmake --build .

3.OPENCV,Eigen3

我之前安装好了,ros会自带,如果需要请自行安装。顺带一题,这个ORB_SLAM2不用依赖ros也是可以的,只是ros比较方便而已(废话)。


DBoW2 and g2o 在ORB_SLAM库里自带。

4.安装ORB_SLAM2

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh

执行./build.sh中会安装

DBoW2 and g2o

不过我电脑出现一个问题,在make -j时,执行一半电脑会卡死。于是我将build.sh文件中的-j删除就顺利安装了。有朋友知道这个问题可以留言,让我学习学习。

5.编译ros-example节点

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
chmod +x build_ros.sh
./build_ros.sh

在这里也会出现编译错误”/usr/bin/ld: CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: undefined reference to symbol “的问题,我们需要在/home/teun/ORB_SLAM2/Examples/ROS/ORB_SLAM2/CMakeList.txt文件里添加一句:

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_systeml 或者 -lboost_system



)

那么我们就安装完成了。

5.使用zed的其中的单个摄像头,进行单目slam

首先我们打开文件夹/home/xp/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2,可以看到编译好的几个可执行文件

如果没有看到那就没有编译好。

我们打开src中的ros_mono.cc,将里面的订阅话题改为zed发布的话题:

ros::Subscriber sub = nodeHandler.subscribe(”

/zed/left/image_raw_color

“, 1, &ImageGrabber::GrabImage,&igb);

我使用的是左摄像头数据,当然你们选择什么都可以。这里我是用的zed,你们可以用电脑自带的摄像头也是ok的,不过你需要将其rgb数据给发布出来。

另外更改在目录/home/xp/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2下

Asus.yaml

里的信息,这里是摄像头的内参等信息。

摄像头发布的分辨率和帧率可以在zed.launch文件中查看!!

我们可以直接使用zed-SDK里对zed进行标定的参数。标定参数在/usr/local/zed/settings文件夹里。将信息填入

Asus.yaml

里。

当然,你需要先安装ZED-SDK,如果使用自己的摄像头也需要自己进行标定。



更改程序后需要重新./build_ros.sh编译!!!!!!!!!!!!!!

6.运行实现单目slam

roslaunch zed_wrapper zed.launch

rosrun ORB_SLAM2 Mono /home/xp/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/xp/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml 

如果是双目,你需要降低分辨率和帧率进行测试,不然会崩掉的。

roslaunch zed_wrapper zed.launch

rosrun ORB_SLAM2 Stereo /home/xp/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/xp/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/EuRoC.yaml true

结果良好,点云图为稀疏图,双目效果不如单目,估计是双目对电脑性能要求太高吧!有问题可以留言讨论。



版权声明:本文为BetterEthan原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。