ubuntu18.04运行ORBSLAM2踩坑记录

  • Post author:
  • Post category:其他


坑1:

error: ‘usleep’ was not declared in this scope

usleep(3000);

解决办法:

在对应报错文件中添加头文件:#include<unistd.h>

坑2:

当编译执行到

./build.sh

文件时,报错Eigen3 found!之类错误。

解决办法:

从目录ORB_SLAM2-master/cmake_modules/下找到FindEigen3.cmake文件,

然后把它复制到报错的CMakeLists.txt对应的路径下/src中

然后在CMakeLists.txt文件中添加以下两行配置:

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${EIGEN3_INCLUDE_DIRS})

坑3:

当编译执行到./build_ros.sh文件时,报错Eigen3 found!

解决方法:

在主文件夹下直接查找FindEigen3.cmake文件,然后把它复制到报错的orb-slam2/Examples/ROS/ORB-SLAM21/CMakeLists.txt对应的路径下/src中,在CMakeLists.txt中,

添加:

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include_directories($ {EIGEN3_INCLUDE_DIRS})


坑4:

解决方案:修改Examples/ROS/ORB_SLAM2/文件夹下的CMakeLists.txt文件

即在相应位置添加:一行 -lboost_system

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_system
)

坑5:ROS路径设置的问题

由于ORBSLAM2中设置了rosbuild_init(),而我们编译文档之前需要先关联工作区间。报错如下:

[rosbuild] rospack found package “ORB_SLAM2” at “”, but the current directory is “/home/xiaoC/ORB_SLAM2/Examples/ROS/ORB_SLAM2”

解决方法:
sudo vim ~/.bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/xiaoC/ORB_SLAM2/Examples/ROS
source ~/.bashrc
理论上上述应该是ok的,如果不ok再执行下面语句。
ok与否判别,通过输出echo $ROS_PACKAGE_PATH进行查看


cd /opt/ros/melodic/
sudo vim setup.bash 
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/xiaoC/ORB_SLAM2/Examples/ROS
source setup.bash

测试是否添加成功两种方式
roscd ORB_SLAM2
echo $ROS_PACKAGE_PATH



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