从零开始的ORB_SLAM3运行( 二 )


将库文件转移到ros文件夹下
sudo rm -rf /opt/ros/melodic/include/cv_bridgesudo rm -rf /opt/ros/melodic/share/cv_bridgesudo rm -rf /opt/ros/melodic/lib/cv_bridgesudo cp -rf /usr/local/include/cv_bridge /opt/ros/melodic/include/cv_bridgesudo cp -rf /usr/local/share/cv_bridge /opt/ros/melodic/share/cv_bridgesudo cp -rf /usr/local/lib/python2.7/dist-packages/cv_bridge /opt/ros/melodic/lib/cv_bridge
中ROS软件包的编译 首先需要添加ros软件包路径
//打开bash环境配置文件gedit ~/.bashrc//在文件最下方插入下面这句话(其中PATH改为真实绝对路径)export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM3/Examples/ROS
修改~/git///ROS//文件
//修改第33到39行代码,由于使用的是opencv4.5.1,故注释掉以下部分find_package(OpenCV 4.0 QUIET)#if(NOT OpenCV_FOUND)#find_package(OpenCV 2.4.3 QUIET)#if(NOT OpenCV_FOUND)#message(FATAL_ERROR "OpenCV > 2.4.3 not found.")#endif()#endif()
修改~/git///ROS//src/文件
//修改第62行中的rostopic话题名称为/cam0/image_raw,与数据集中topic话题名称统一ros::Subscriber sub = nodeHandler.subscribe("/cam0/image_raw", 1, &ImageGrabber::GrabImage,&igb);
编译ros文件夹中的源码
cd ~/git/ORB_SLAM3/Examples/ROS/ORB_SLAM3mkdir buildcd buildcmake ..make
下载ROS bag格式数据集并运行数据集

从零开始的ORB_SLAM3运行

文章插图
cd ~wget http://robotics.ethz.ch/~asl-datasets/ijrr_euroc_mav_dataset/machine_hall/MH_01_easy/MH_01_easy.bag//终端1roscore//终端2rosbag play ~/MH_01_easy.bag//终端3rosrun ORB_SLAM3 Mono /home/s/git/ORB_SLAM3/Vocabulary/ORBvoc.txt /home/s/git/ORB_SLAM3/Examples/ROS/ORB_SLAM3/Asus.yaml
运行成功示例
错误提示以及修正方案 编译过程中出现错误
CMake Error at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1947 (message):Unable to find the requested Boost libraries.Boost version: 1.65.1Boost include path: /usr/includeCould not find the following Boost libraries:boost_python37No Boost libraries were found.You may need to set BOOST_LIBRARYDIR to thedirectory containing Boost libraries or BOOST_ROOT to the location ofBoost.Call Stack (most recent call first):vision_opencv/cv_bridge/CMakeLists.txt:11 (find_package)
解决方法:参考的安装的第三步
编译过程中出现错误,make 66%时出现错误
[ 66%] Building CXX object src/CMakeFiles/cv_bridge_boost.dir/module.cpp.oIn file included from /usr/include/python2.7/numpy/ndarrayobject.h:27:0,from /home/nano/catkin_ws/src/cv_bridge/src/module.hpp:26,from /home/nano/catkin_ws/src/cv_bridge/src/module.cpp:35:/home/nano/catkin_ws/src/cv_bridge/src/module.hpp: In function ‘int do_numpy_import()’:/usr/include/python2.7/numpy/__multiarray_api.h:1537:144: error: return-statement with no value, in function returning ‘int’ [-fpermissive]efine import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IMPORT_ARRAY_RETVAL; } }^/usr/include/python2.7/numpy/__multiarray_api.h:1537:144: note: in definition of macro ‘import_array’efine import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IMPORT_ARRAY_RETVAL; } }^~~~~~src/CMakeFiles/cv_bridge_boost.dir/build.make:62: recipe for target 'src/CMakeFiles/cv_bridge_boost.dir/module.cpp.o' failedmake[2]: *** [src/CMakeFiles/cv_bridge_boost.dir/module.cpp.o] Error 1CMakeFiles/Makefile2:930: recipe for target 'src/CMakeFiles/cv_bridge_boost.dir/all' failedmake[1]: *** [src/CMakeFiles/cv_bridge_boost.dir/all] Error 2Makefile:140: recipe for target 'all' failedmake: *** [all] Error 2
解决方法:参考的安装的第四步