SLAM算法配置——使用Realsense D435i结合ROS跑通ORB-SLAM2的RGB-D节点

ORB-SLAM2源地址

配置环境依赖

Pangolin,OpenCV,Eigen3,DBoW2 and g2o(源代码里有,不用自己装),ROS(至少为Hydro版本,越新越好)
这些配置过程较为简单,这里不赘述

ORB-SLAM2编译

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2

可以看到源码里包含build.sh和build_ros.sh,赋予这个脚本权限,直接执行即可

chmod +x build.sh
./build.sh
chmod +x build_ros.sh
./build_ros.sh

值得一提的是哪怕你只想用ROS版本,也必须先执行build.sh脚本。因为他会编译一些依赖项,解压一些本地文件,具体可参考build.sh里的内容。

编译过程中的报错

`/usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv’ 
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line 
collect2: error: ld returned 1 exit status 
CMakeFiles/RGBD.dir/build.make:218: recipe for target ‘../RGBD’ failed 
make[2]: * [../RGBD] Error 1 
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/RGBD.dir/all’ failed 
make[1]: * [CMakeFiles/RGBD.dir/all] Error 2 
make[1]: * 正在等待未完成的任务…. 
/usr/bin/ld: CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv’ 
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line 
collect2: error: ld returned 1 exit status 
CMakeFiles/Stereo.dir/build.make:218: recipe for target ‘../Stereo’ failed 
make[2]: * [../Stereo] Error 1 
CMakeFiles/Makefile2:104: recipe for target ‘CMakeFiles/Stereo.dir/all’ failed 
make[1]: * [CMakeFiles/Stereo.dir/all] Error 2 
Makefile:127: recipe for target ‘all’ failed 
make: * [all] Error 2

这里的解决方法参考了这篇博客

locate  boost_system
/usr/lib/x86_64-linux-gnu/libboost_system.a
/usr/lib/x86_64-linux-gnu/libboost_system.so
/usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0

locate boost_filesystem
/usr/lib/x86_64-linux-gnu/libboost_filesystem.a
/usr/lib/x86_64-linux-gnu/libboost_filesystem.so
/usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.58.0

解决方法:
把libboost_system.so、libboost_system.so.1.58.0、libboost_filesystem.so、libboost_filesystem.so.1.58.0这四个文件复制到ORB_SLAM2/lib下,然后修改ORBSLAM2/Examples/ROS/ORBSLAM2下的Cmakelists.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
${PROJECT_SOURCE_DIR}/../../../lib/libboost_filesystem.so 
${PROJECT_SOURCE_DIR}/../../../lib/libboost_system.so
)

使用bag数据集跑通

roscore

新建一个终端

rosrun ORB_SLAM2 RGBD Vocabulary/ORBvoc.txt [path_to_yaml_file]

如果提示找不到yaml文件的话,改用绝对路径。yaml是配置文件,里面包含相机的内参等程序参数,Realsense官方数据格式
具体到Realsense D435i,baseline是50mm,根据他来修改bf,bf = baseline * fx

# IR projector baseline times fx (aprox.)
Camera.bf: 40.0

RGB的topic名字:/camera/rgb/image_raw
Depth的topic名字:/camera/depth_registered/image_raw
彩色图与深度图必须是配准过的,ROS的简单使用可以参照这篇博客,里面有关于topic名字映射(rosbag play时)的介绍。

rosbag play [path_to_bag_file] [actual_topic_name]:=[virtual_topic_name] [actual_topic_name]:=[virtual_topic_name]

自制数据集结果展示

SLAM算法配置——使用Realsense D435i结合ROS跑通ORB-SLAM2的RGB-D节点_第1张图片

你可能感兴趣的:(软件配置,ROS)