2019年4月18日,跑程序ROS下的ORB-SLAM2

2019年4月18日,跑程序ROS下的ORB-SLAM2,按照帖子跑,https://blog.csdn.net/learning_tortosie/article/details/79881165
编译./build_ros.sh就出错,未果,今天先到这儿.

2019年5月13日,继续试试ROS下的ORB-SLAM2,

安装ROS:

官网(http://wiki.ros.org/cn/kinetic/Installation),跟随步骤安装即可。

创建工作空间

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src

编译工作空间

cd ..
catkin_make

将ORB_SLAM2移入catkin_ws/src下

用命令sudo gedit ~/.bashrc打开 .bashrc 文件,添加下边行:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
这里的PATH是:/home/thomas/catkin_ws/src
还要写入一行source /home/thomas/catkin_ws/devel/setup.sh
终端执行source ~/.bashrc

编译ROS下的ORB_SLAM2

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

此处./build_ros.sh后出错

thomastao@thomastao-Lenovo:~/catkin_ws/src/ORB_SLAM2$ ./build_ros.sh
Building ROS nodes
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.12") 
[rosbuild] Building package ORB_SLAM2
[rosbuild] Cached build flags older than manifests; calling rospack to get flags
-- Using CATKIN_DEVEL_PREFIX: /home/thomastao/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/devel
-- Using CMAKE_PREFIX_PATH: /home/thomastao/catkin_ws/devel;/opt/ros/kinetic
-- This workspace overlays: /home/thomastao/catkin_ws/devel;/opt/ros/kinetic
-- Found PythonInterp: /usr/bin/python (found suitable version "2.7.12", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Skip enable_testing() for dry packages
-- Using CATKIN_TEST_RESULTS_DIR: /home/thomastao/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/test_results
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- Found PythonInterp: /usr/bin/python (found version "2.7.12") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.20
-- BUILD_SHARED_LIBS is on
[rosbuild] using multiarch 'x86_64-linux-gnu' for finding Boost
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
[rosbuild] Including /opt/ros/kinetic/share/roslisp/rosbuild/roslisp.cmake
[rosbuild] Including /opt/ros/kinetic/share/roscpp/rosbuild/roscpp.cmake
[rosbuild] Including /opt/ros/kinetic/share/rospy/rosbuild/rospy.cmake
Build type: Release
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- Performing Test COMPILER_SUPPORTS_CXX0X
-- Performing Test COMPILER_SUPPORTS_CXX0X - Success
-- Using flag -std=c++11.
-- Found Eigen3: /usr/include/eigen3 (Required is at least version "3.1.0") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/thomastao/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build
Scanning dependencies of target rospack_genmsg_libexe
[  0%] Built target rospack_genmsg_libexe
Scanning dependencies of target rosbuild_precompile
[  0%] Built target rosbuild_precompile
Scanning dependencies of target MonoAR
Scanning dependencies of target Stereo
Scanning dependencies of target Mono
Scanning dependencies of target RGBD
[ 11%] Building CXX object CMakeFiles/Mono.dir/src/ros_mono.cc.o
[ 22%] Building CXX object CMakeFiles/Stereo.dir/src/ros_stereo.cc.o
[ 33%] Building CXX object CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o
[ 55%] Building CXX object CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o
[ 55%] Building CXX object CMakeFiles/MonoAR.dir/src/AR/ros_mono_ar.cc.o
[ 66%] Linking CXX executable ../Mono
[ 77%] Linking CXX executable ../MonoAR
[ 77%] Built target Mono
[ 77%] Built target MonoAR
[ 88%] Linking CXX executable ../RGBD
/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:213: 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]: *** 正在等待未完成的任务....
[100%] Linking CXX executable ../Stereo
/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:213: 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

解决办法:
可以直接在/home/thomastao/catkin_ws/src/ORB_SLAM2/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 
)

注意

ORB-SLAM默认订阅的话题为/camera/image_raw,而usb_cam节点发布的话题为/usb_cam/image_raw,因此需要在ros_mono.cc中修改订阅的话题,这点要特别注意。因为源文件的更改必须要重新编译,这非常耗时。
这里修改了catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src里的ros_mono.cc文件,以后跑数据集的话要改回来

跑双目ROS,要cd进catkin_ws/src/ORB_SLAM2跑

下载rosbag (e.g. V1_01_easy.bag) from the EuRoC dataset (http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets) 放进catkin_ws/src/ORB_SLAM2/dataset. Open 3 tabs on the terminal and run the following command at each tab:

roscore
rosrun ORB_SLAM2 Stereo Vocabulary/ORBvoc.txt Examples/Stereo/EuRoC.yaml true
rosbag play --pause V1_01_easy.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw

ok,结束

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值