ORB-SLAM3 ROS 运行

环境为:ROS Melodic 和 Ubuntu 18.04

编译

1、将源码中的 Examples/ROS/ORB_SLAM3 路径添加到ROS_PACKAGE_PATH环境变量中
打开 .bashrc file:

gedit ~/.bashrc

把下面这行加到最下面一行,把“PATH”换成你放ORB_SLAM3的路径

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:“PATH”/ORB_SLAM3/Examples/ROS

2、执行ORB-SLAM3中打开终端,执行 build_ros.sh 文件

chmod +x build_ros.sh
./build_ros.sh

此处碰到第一个问题:会报一个类似如下的错误(我忘记截图了用了别人的例子,大差不差)

<span style="background-color:rgb(255,255,255);">Building ROS nodes
mkdir: cannot create directory ‘build’: File exists
[rosbuild] Building package ORB_SLAM2
[rosbuild] Error from directory check: /opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py  /home/nvidia/ORBSLAM2/ORB_SLAM2/Examples/ROS/ORB_SLAM2
1
Traceback (most recent call last):
  File "/opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py", line 46, in <module>
    raise Exception
Exception
CMake Error at /opt/ros/kinetic/share/ros/core/rosbuild/private.cmake:102 (message):
  [rosbuild] rospack found package "ORB_SLAM2" at "", but the current
  directory is "/home/nvidia/ORBSLAM2/ORB_SLAM2/Examples/ROS/ORB_SLAM2".  You
  should double-check your ROS_PACKAGE_PATH to ensure that packages are found
  in the correct precedence order.
Call Stack (most recent call first):
  /opt/ros/kinetic/share/ros/core/rosbuild/public.cmake:177 (_rosbuild_check_package_location)
 <a href="https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxcheckurl?requrl=http%3A%2F%2FCMakeLists.txt%3A4&skey=%40crypt_d4526f3_cee58ae55fc4f024ed7c53ec14a9f070&deviceid=e229686437474105&pass_ticket=undefined&opcode=2&scene=1&username=@a9980bb39a454579f6fc182cc7150259c54221ac201912fb57b3a10c3a0f480e"> CMakeLists.txt:4</a> (rosbuild_init)


-- Configuring incomplete, errors occurred!
See also "/home/nvidia/ORBSLAM2/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.</span>

解决方法也很简单,大概就是 /ros/melodic/share 这个路径没有ORB_SLAM3的软连接,在命令行输入以下代码即可(“PATH”同上,Ubuntu18.04melodic16.04应该是kinetic)原贴连接

sudo ln -s "PATH"/ORB_SLAM3/Examples/ROS/ORB_SLAM3 /opt/ros/melodic/share/ORB_SLAM3

运行

EuRoC dataset 下载一个.bag文件,在ORB_SLAM文件夹打开终端,输入下面三行命令

roscore
rosrun ORB_SLAM3 Stereo_Inertial Vocabulary/ORBvoc.txt Examples/Stereo-Inertial/EuRoC.yaml true
rosbag play --pause “V1_02_medium.bag” /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw /imu0:=/imu

其中第三行“V1_02_medium.bag”就是你下的文件的名字,第三行代码运行之后记得按下空格键开始播放bag文件
如果下载的是TUM数据,需要对数据进行一些处理,如下

rosrun rosbag fastrebag.py dataset-room1_512_16.bag dataset-room1_512_16_small_chunks.bag

最终运行结果

在这里插入图片描述

  • 8
    点赞
  • 122
    收藏
    觉得还不错? 一键收藏
  • 20
    评论
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值