(虚拟机和双系统都能正常运行,亲测有效)
1.Astra Pro驱动安装
1.1安装依赖:
$ sudo apt-get install build-essential freeglut3 freeglut3-dev
1.2检查udev版本,需要libudev.so.1,如果没有则添加
#check udev version, Orbbec Driver need libudev.so.1, if can't find it, can make symbolic link from libudev.so.x.x,
#which usually locate in /lib/x86_64-linux-gnu or /lib/i386-linux-gnu
$ ldconfig -p | grep libudev.so.1
$ cd /lib/x86_64-linux-gnu
$ sudo ln -s libudev.so.x.x.x libudev.so.1
1.4下载驱动:https://orbbec3d.com/develop/#registergestoos,选择linux版本:
1.5下载解压
$ cd ~
$ wget http://www.orbbec3d.net/Tools_SDK_OpenNI/2-Linux.zip
1.6选择OpenNI-Linux-x64-2.3解压
$ unzip OpenNI-Linux-x64-2.3.zip
$ cd OpenNI-Linux-x64-2.2
1.7安装
$ sudo chmod a+x install.sh
$ sudo ./install.sh
1.7重插设备
1.8加入环境
$ source OpenNIDevEnvironment
1.9编译例子
$ cd Samples/SimpleViewer
$ make
1.10连接设备,执行例子
$ cd Bin/x64-Release
$ ./SimpleViewer
2.安装Astra Pro的ROS包
安装astra_camera和astra_launch
$ sudo apt-get install ros-kinetic-astra-camera ros-kinetic-astra-launch
3.测试Astra Pro在ros下的rgb和depth图像是否正常显示
新终端,执行astra_launch
$ roslaunch astra_launch astra.launch
使用rqt_image_view, 选择对应话题显示彩色图像或深度图像,若rgb没有正确显示,则需要UVC支持,安装libuvc和libuvc_ros
4.libuvc和libuvc_ros安装
4.1安装libuvc支持
$ cd ~
$ git clone https://github.com/ktossell/libuvc
$ cd libuvc
$ mkdir build
$ cd build
$ cmake ..
$ make && sudo make install
4.2安装libuvc_ros
$ cd ~/catkin_ws/src
$ git clone https://github.com/ktossell/libuvc_ros
$ cd ..
$ catkin_make
注意:使用catkin_make,如果报错,注意libusb.h的位置。使用locate libusb.h,并将其放到合适位置:
$ sudo cp /usr/include/libusb-1.0/libusb.h /usr/local/include/libuvc/
最后修改下libuvc.h中include中的路径即可。
5.测试Astra Pro在ros下的rgb图像是否正常显示
在启动roscore后,使用:
$ rosrun libuvc_camera camera_node
可在rqt_image_view 中查看rgb图像以及深度图像(更改话题名为/camera/depth/image_raw即可)
6.编译ROS环境下的ORB-SLAM2
在装好ROS kinetic的完整版和Pangolin后,依次进行以下步骤:
6.1下载编译ORB-SLAM2:
cd ~
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh
6.2安装ORB-SLAM2的ROS库
添加路径到 .bashrc,即环境变量
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
修改ORB_SLAM2/Examples/ROS中ros_mono.cc和ros_rgbd.cc文件中的话题名为Astra Pro对应的话题名:
即把ros_mono.cc文件中的
ros::Subscriber sub = nodeHandler.subscribe("/camera/image_raw", 1, &ImageGrabber::GrabImage,&igb);
修改为
ros::Subscriber sub = nodeHandler.subscribe("/camera/rgb/image_raw", 1, &ImageGrabber::GrabImage,&igb);
即把ros_rgbd.cc文件中的
message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/rgb/image_raw", 1);message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "camera/depth_registered/image_raw", 1);
修改为
message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/rgb/image_raw", 1);message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "camera/depth/image_raw", 1);
执行编译
在装好ROS kinetic的完整版和Pangolin后,依次进行以下步骤:
6.1下载编译ORB-SLAM2:
cd ~
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh
6.2安装ORB-SLAM2的ROS库
添加路径到 .bashrc,即环境变量
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
修改ORB_SLAM2/Examples/ROS中ros_mono.cc和ros_rgbd.cc文件中的话题名为Astra Pro对应的话题名:
即把ros_mono.cc文件中的
ros::Subscriber sub = nodeHandler.subscribe("/camera/image_raw", 1, &ImageGrabber::GrabImage,&igb);
修改为
ros::Subscriber sub = nodeHandler.subscribe("/camera/rgb/image_raw", 1, &ImageGrabber::GrabImage,&igb);
即把ros_rgbd.cc文件中的
message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/rgb/image_raw", 1);message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "camera/depth_registered/image_raw", 1);
修改为
message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/rgb/image_raw", 1);message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "camera/depth/image_raw", 1);
执行编译
chmod +x build_ros.sh
./build_ros.sh
由于Astra Pro属于奥比中光深度相机系列产品,因此没有双目镜头,无法开启双目模式,只能运行单目和RGBD模式。
运行 Monocular Node
rosrun ORB_SLAM2 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE
当出现下列效果时,说明ORB-SLAM2的ROS端口已经启动,且会出现可视化显示界面和灰度图像显示界面:
再通过launch文件启动Astra Pro即可开始完成属于你自己环境的基于单目的SLAM过程了!
即$ roslaunch astra_launch astra.launch
当出现下列效果时,说明ORB-SLAM2的ROS端口已经成功连接相机端口
运行RGB_D Node
rosrun ORB_SLAM2 RGBD PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE
再通过launch文件启动Astra Pro即可开始完成属于你自己环境的基于RGB-D的 SLAM过程了!
即$ roslaunch astra_launch astra.launch
当出现下列效果时,说明ORB-SLAM2的ROS端口已经成功连接相机端口