来了!接着上篇,开始orb-slam3 的稠密回环建图实测(奥比中光Astrapro 相机)
老样子,先上效果图:
开发环境:NX+Ubuntu18.04+ROS-melodic
四、NX + Astrapro 相机+orb-slam3 稠密回环建图
首先小白老师分享的ORB-SLAM3的可回环的稠密地图版本,具体在这篇博客,下载但是却没有相关的具体实现教程,这里我们先使用 奥比中光Astrapro 两款相机进行配置实现
4.1 配置环境
其实与orb-slam2的环境配置一样,使用的仍然是pagolin0.5,和opencv3.2.0版本(3.4.x也可以),pcl1.8.1+vtk7.1.1 这里不重复,具体配置可以去我之前写的实测 (二),里面的依赖使用的是相同的配置。
4.2 安装编译
(1)下载源码
链接如下:http://t.csdn.cn/nMOZx
(2)修改pointcloudmapping.cc
打开src / pointcloudmapping.cc,110-112行修改如下,将rgb的颜色修改正确
p.b = color.ptr<uchar>(m)[n*3+2];
p.g = color.ptr<uchar>(m)[n*3+1];
p.r = color.ptr<uchar>(m)[n*3];
在void PointCloudMapping::viewer() 中的while循环里的最后(200-201之间)加入下面一行,用于保存点云地图,同时在开头增加 #include <pcl/io/pcd_io.h>
pcl::io::savePCDFileBinary( "vslam.pcd", *globalMap );
(3)修改camkelist.txt
打开CMakeLists.txt ,将48行左右的 “ find_package( PCL 1.12 REQUIRED ) ”中的1.12改为1.8,修改后如下:
find_package( PCL 1.8 REQUIRED )
(4)开始ubuntu下编译
打开build.sh,在 make 后 加上 -j4 ,提高编译速度,然后开始编译:
cd ORB_SLAM3_detailed_comments-dense_map_newchmod +x build.sh./build.sh
(5)ROS下编译
打开CMakeLists.txt,增加下面4行:
find_package(Eigen3 3.1.0 REQUIRED)
find_package(Pangolin REQUIRED)
find_package(PCL REQUIRED) //新增这一行include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../../../
${PROJECT_SOURCE_DIR}/../../../include
${PROJECT_SOURCE_DIR}/../../../include/CameraModels
${PROJECT_SOURCE_DIR}/../../../Thirdparty/Sophus
${Pangolin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS} //新增这一行
)add_definitions( ${PCL_DEFINITIONS} ) //新增这一行
link_directories( ${PCL_LIBRARY_DIRS} ) //新增这一行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_SLAM3.so
-lboost_system
)
修改 Examples/ROS/ORB_SLAM3/src/ros_rgbd.cc的topic
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);
开始编译:
添加环境配置
gedit ~/.bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/nx/你自己的路径/Example/ROS
source ~/.bashrc开始编译
chmod +x build_ros.sh
./build_ros.sh
编译成功后,配置所需的yaml文件
4.3 开始试验
(1)启动相机
sudo su //不运行su命令,直接打开会丢失深度信息
souce devel setup.bash
roslaunch astra_carma astrapro.launch
(2)稠密建图
rosrun ORBSLAM3 RGBD Vocabulary/ORBvoc.txt Examlpe/ROS/ORB_SLAM3/astrapro.yaml