(难 真难 看了无数教程踩了无数坑 最后终于跑通了 以此记录以下 水平有限 如有错误 还请各位批评指正)
目录
一.安装ROS
二.ORB-SLAM2的安装和配置
2.1安装Pangoline
2.2检查OPenCV版本
2.3安装Eigen3
2.4安装编译ORB_SLAM2核心库
三.SDK安装与测试
四.通过D455来运行ORB-SLAM2
直接参考这篇帖子
Ubuntu18.04安装Ros(最新最详细亲测)_向日葵骑士Faraday的博客-CSDN博客_ubuntu18.04安装ros
(参考张虎大佬的《机器人SLAM导航核心技术与实战》)
重点!先不要盲目安装各种依赖 在安装ROS melodic后里面会自带OpenCV3.2.0,和eigen3,如果重复安装会导致后面发生各种奇奇怪怪的错误
建议安装Pangoline0.5版本
链接: https://pan.baidu.com/s/1SpJaQnSqrwIoIZd3Yrk0gg 提取码: 6ujg
也可去官网自己下载
解压后
cd Pangolin-0.5
sudo apt-get install libglew-dev
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev
sudo apt-get install libpython2.7-dev
、、cmake
mkdir build && cd build
cmake ..
make -j4
sudo make install
这里不建议重新安装新版本
pkg-config opencv --modversion
用上面的命令检查OpenCV版本
Ubuntu18.04中自带的Eigen3.3.4版本太新了,而ORB-SLAM2中的核心库采用比较旧的Eigen,会直接导致编译报错所以要换个更旧的Eigen3.2.10
用以下命令更改别名来移除系统中的Eigen3.3.4
sudo mv -f /usr/include/eigen3 /usr/include/eigen3.dafault.bak
下载Eigen源码
git clone https://github.com/libeigen/eigen.git
切换代码分支
cd eigen
git checkout 3.2.10
编译安装
mkdir build
cd build
cmake ..
sudo make install
将eigen3/Eigen复制到上一级目录
sudo cp -rf /usr/local/include/eigen3/Eigen /usr/local/include/
将eigen3和Eigen文件夹复制到/usr/include/之中
sudo cp -rf /usr/local/include/eigen3 /usr/include/
sudo cp -rf /usr/local/include/Eigen /usr/include/
下载ORB_SLAM2源码
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
编译ORB_SLAM2源码
cd ORB-SLAM2
chmod +x build.sh
./build.sh
这部分可能会发生usleep()函数未声明的错误,所以要在ORB-SLAM2中所有报错的源码中添加
#include
运行到build.sh就能完成ORB_SLAM2核心库和配套例程的编译,而配套例程中的ROS例程则需要用单独的脚本编译
在环境变量ROS_PACKAGE_PATH中制定要编译的ROS包的路径
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/ORB_SLAM2/Examples/ROS
在ORB-SLAM2/Examples/ROS/ORB-SLAM2/src中修改ros_rgbd.cc的topic订阅:
message_filters::Subscriber rgb_sub(nh, "/camera/color/image_raw", 1);
message_filters::Subscriber depth_sub(nh, "/camera/aligned_depth_to_color/image_raw", 1);
编译ROS例程
cd ORB_SLAM2
chmod +x build_ros.sh
./build_ros.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: 无法添加符号: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/RGBD.dir/build.make:215: recipe for target '../RGBD' failed
修改ORB_SLAM2_modified/Examples/ROS/ORB_SLAM2/文件夹下的cmakelist,
-lboost_system一句加上(这里需要电脑中安装了PCL库 可以去/usr/include中看一下 但是一般安装了ROS后都有 一定注意不要重复安装 否则会出错)
find_package(Pangolin REQUIRED)
find_package(PCL 1.7 REQUIRED)
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../../../
${PROJECT_SOURCE_DIR}/../../../include
${Pangolin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
)
add_definitions(${PCL_DEFINITIONS})
link_directories(${PCL_LIBRARY_DIRS})
set(LIBS
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PCL_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_system
)
1、 D435i ----- Ubuntu18.04下D435i使用(SDK安装与测试)_杰尼君的博客-CSDN博客
编译ROS Wrapper
mkdir realsense
cd realsense
mkdir src
cd src
git https://github.com/intel-ros/realsense.git
cd ..
catkin_make
source devel/setup.bash
打开.bashrc文件添加source
sudo gedit .bashrc
在最下行添加
source /home/bread/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/devel/setup.bash
启动相机
roslaunch realsense2_camera rs_rgbd.launch
可能会报错 参考ubuntu18.04 D435i ROS ORB-SLAM2_哦*&的博客-CSDN博客
sudo apt-get install ros-melodic-rgbd-launch
在ORB-SLAM2文件中打开终端用TUM1.yaml的参数运行
rosrun ORB_SLAM2 RGBD Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml
未完待续