目录
目的
使用ORB_SLAM2在ROS运行kitti数据集
环境
ubuntu
ROS
.bag格式的kitti数据集
安装相应依赖
根据ORB_SLAM2的README.md,需要的依赖有:
# 2. Prerequisites
We have tested the library in **Ubuntu 12.04**, **14.04** and **16.04**, but it should be easy to compile in other platforms. A powerful computer (e.g. i7) will ensure real-time performance and provide more stable and accurate results.## C++11 or C++0x Compiler
We use the new thread and chrono functionalities of C++11.## Pangolin
We use [Pangolin](https://github.com/stevenlovegrove/Pangolin) for visualization and user interface. Dowload and install instructions can be found at: https://github.com/stevenlovegrove/Pangolin.## OpenCV
We use [OpenCV](http://opencv.org) to manipulate images and features. Dowload and install instructions can be found at: http://opencv.org. **Required at leat 2.4.3. Tested with OpenCV 2.4.11 and OpenCV 3.2**.## Eigen3
Required by g2o (see below). Download and install instructions can be found at: http://eigen.tuxfamily.org. **Required at least 3.1.0**.## DBoW2 and g2o (Included in Thirdparty folder)
We use modified versions of the [DBoW2](https://github.com/dorian3d/DBoW2) library to perform place recognition and [g2o](https://github.com/RainerKuemmerle/g2o) library to perform non-linear optimizations. Both modified libraries (which are BSD) are included in the *Thirdparty* folder.## ROS (optional)
We provide some examples to process the live input of a monocular, stereo or RGB-D camera using [ROS](ros.org). Building these examples is optional. In case you want to use ROS, a version Hydro or newer is needed.
相应依赖的安装已有很多先例,在此不做赘述。
相关阅读
Ubuntu16.04编译,运行ORB_SLAM2_HiHa423的博客-CSDN博客ORB-SLAM2编译安装以及跑KITTI数据集_orb-slam2 kitti_Jinterest的博客-CSDN博客Ubuntu16.04编译,运行ORB_SLAM2_HiHa423的博客-CSDN博客
编译
不使用ROS的编译:
cd ORB_SALM2
chmod +x build.sh
./build.sh
使用ROS的编译 :
1. 下载源代码并解压
把ORB_SALM2解压到工作空间的源文件下/catkin_ws/src中。(工作空间catkin_ws提前创建)
2. catkin_make
在catkin_ws中执行catkin_make
cd ~/catkin_ws/
catkin_make
3. 添加环境变量:
环境变量一个是source ~/.../devel/setup.bash,另一个是
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS。
其中,~/.../devel/setup.bash可以写入~/.bashrc中。
写入方法:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
其中,“PATH/ORB_SLAM2/Examples/ROS”等路径根据实际情况修改。
或者使用文本编辑器gedit或者vim编辑 ~/.bashrc
在终端中输入:
sudo gedit ~/.bashrc
使用gedit打开 ~/.bashrc,弹出文本编辑页面;
在文档末尾,追加:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
source ~/catkin_ws/devel/setup.bash
其中,“PATH/ORB_SLAM2/Examples/ROS”等路径根据实际情况修改。
4. ./build_ros.sh编译
使用ORB_SLAM2源文件文件夹的./build_ros.sh进行编译,先对其赋权,再执行它:
chmod +x build_ros.sh
./build_ros.sh
相关阅读
ORB-SLAM2编译安装以及跑KITTI数据集_orb-slam2 kitti_Jinterest的博客-CSDN博客
运行数据集
启动三个终端,分别用于开启master、运行ORB_SLAM2的可执行程序、播放rosbag。
以单目为例。
1. 开启master
启动一个终端,执行roscore:
roscore
开启master
2. 运行ORB_SLAM2的可执行程序
再启动一个终端,运行ORB_SLAM2的可执行程序 ,执行rosrun:
rosrun ORB_SLAM2 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE
##PATH_TO_VOCABULARY: 算法参数文件。形如/PATH/Vocabulary/ORBvoc.txt:
##PATH_TO_SETTINGS_FILE:相机参数设置文件,形如 /PATH/Examples/ROS/ORB_SLAM2/Asus.yaml
其中,“PATH_TO_VOCABULARY”等路径根据实际情况修改。
以我为例,运行KITTI00-02的数据集:
rosrun ORB_SLAM2 Mono Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml
此时,弹出ORB_SLAM2可执行程序的两个界面。
3. 播放rosbag
再启动一个终端,播放rosbag,执行rosbag play:
rosbag play xxx.bag
播放rosbag。
topic重映射
需要注意的是, 对于自己的数据集,可能存在 数据集的topic话题和ORB_SLAM2用于接受相机数据的topic话题不一致。如果不一致,程序的两个界面将不会有计算结果,不会有变化。因此,需要将二者对应。
比如,ORB_SLAM2用于接受相机数据的topic话题为 `/camera/image_raw`,而我的数据集中相机的topic话题为“kitti/camera_color_left/image_raw”,需要将二者对应,可以再播放数据集时,追加参数:
rosbag play xxx.bag /kitti/camera_color_left/image_raw:=/camera/image_raw
至此, ORB_SLAM2程序的两个界面将出现计算结果。
结果
以我为例:
参考 ORB_SLAM2的README.md:
# 4. Monocular Examples
## KITTI Dataset
1. Download the dataset (grayscale images) from http://www.cvlibs.net/datasets/kitti/eval_odometry.php
2. Execute the following command. Change `KITTIX.yaml`by KITTI00-02.yaml, KITTI03.yaml or KITTI04-12.yaml for sequence 0 to 2, 3, and 4 to 12 respectively. Change `PATH_TO_DATASET_FOLDER` to the uncompressed dataset folder. Change `SEQUENCE_NUMBER` to 00, 01, 02,.., 11.
```
./Examples/Monocular/mono_kitti Vocabulary/ORBvoc.txt Examples/Monocular/KITTIX.yaml PATH_TO_DATASET_FOLDER/dataset/sequences/SEQUENCE_NUMBER
```
# 7. ROS Examples### Building the nodes for mono, monoAR, stereo and RGB-D
1. Add the path including *Examples/ROS/ORB_SLAM2* to the ROS_PACKAGE_PATH environment variable. Open .bashrc file and add at the end the following line. Replace PATH by the folder where you cloned ORB_SLAM2:```
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
```
2. Execute `build_ros.sh` script:```
chmod +x build_ros.sh
./build_ros.sh
```
### Running Monocular Node
For a monocular input from topic `/camera/image_raw` run node ORB_SLAM2/Mono. You will need to provide the vocabulary file and a settings file. See the monocular examples above.```
rosrun ORB_SLAM2 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE
报错
libboost_system
./build_ros.sh编译时报错:/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command
在Example/ROS/ORB_SLAM2/文件夹中的CMakeLists.txt 里面set()上加"-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
)
链接master失败
[ERROR] [1682320579.511743459]: [registerPublisher] Failed to contact master at [localhost:11311]. Retrying...
提示需要启动ROS master,即在程序运行之初,需要先启动一个终端,执行“roscore”。
topic需要对应
kitti数据集中相机数据
rosbag play xxx.bag,同时把xxx.bag的topic /kitti/camera_color_left/image_raw对应为/camera/image_raw
要在Ros中播放一个bag文件并将其topic重映射到另一个名称,可以使用以下命令:
rosbag play xxx.bag /kitti/camera_color_left/image_raw:=/camera/image_raw
这将播放名为"xxx.bag"的bag文件,并将其topic "/kitti/camera_color_left/image_raw" 重映射到 "/camera/image_raw"。这将使您能够在Ros中使用 "/camera/image_raw" topic 来访问bag文件中的数据。
相关阅读
github