ORBSLAM2 ROS跑单目摄像头

首先按照github上将依赖库安装好,摄像头我用的是罗技的具体型号不清楚,按照博客:https://blog.csdn.net/xmy306538517/article/details/59501718 所说的做。

创建一个新的ros工程:

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

再添加句话至 .bashrc文件里面

source ~/catkin_ws/devel/setup.bash`

其中source 作用:使当前shell读入路径为filepath的shell文件并依次执行文件中的所有语句,通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录。例如,当我们修改了/etc/profile文件,并想让它立刻生效,而不用重新登录,就可以使用source命令,如source /etc/profile。其中source 与‘.’作用相同。

下载usb_cam https://github.com/bosch-ros-pkg/usb_cam

将usb_cam放在catkin_ws/src下面

$ cd catkin_ws/src/usb_cam
$ mkdir build
$ cd build
$ cmake ..
$ make
编译ORBSLAM2
$ cd ORB_SLAM2
$ chmod +x build.sh
$ ./build.sh
将摄像头数据发布到topic

提到topic就会想到ros系统的4个重要概念,节点,消息,主题,服务。

  1. 节点:就是一些直接运行任务的进程
  2. 消息:节点之间通过消息进行通信
  3. 主题:节点通过订阅和发布主题,从而收发消息
  4. 服务:他由请求和响应
roslaunch   usb_cam   usb_cam-test.launch

进入~/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src 

打开ros_mono.cc ,将程序里面的topic改成/usb_cam/image+raw

然后进入~/catkin_ws/src/ORB_SLAM里面

$ 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: 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

这时看到解决办法是https://blog.csdn.net/sinat_38343378/article/details/78883919和https://blog.csdn.net/XF920418/article/details/79732729这;两个帖子,出错原因是libboost_system.so 与libboost_filesystem.so找不到链接目录。解决方案是locate 两个文件的位置,将两个人间的.so复制到ORB_SLAM2的lib下.同时.a文件和其他文件也拷贝进到这个ORBSLAM2/lib文件目录下。

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

此时重复步骤就可以通过了

你可能感兴趣的:(SLAM)