ROS of ORB_SLAM2 runs the kitti dataset

Table of contents

Purpose

environment

Install the corresponding dependencies

compile 

1. Download the source code and unzip it

2. catkin_make

3. Add environment variables:

4. ./build_ros.sh compile

run dataset

1. Start the master 

 2. Run the executable program of ORB_SLAM2

3. Play rosbag

topic remapping

result

report error

link master failed

topic needs to correspond


Purpose

Run the kitti dataset in ROS using ORB_SLAM2

environment

ubuntu

ROS

kitti dataset in .bag format

Install the corresponding dependencies

According to README.md of ORB_SLAM2, the required dependencies are:

# 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.

There are many precedents for the installation of corresponding dependencies, so I won’t repeat them here.

Related Reading

Compile Ubuntu16.04, run ORB_SLAM2_HiHa423's Blog-CSDN Blog

compile 

Compilation without ROS:

cd ORB_SALM2  
chmod +x build.sh
./build.sh

Compilation using ROS:

1. Download the source code and unzip it

Unzip ORB_SALM2 to /catkin_ws/src under the source file of the workspace. (The workspace catkin_ws is created in advance)

2. catkin_make

Execute catkin_make in catkin_ws

cd ~/catkin_ws/
catkin_make

3. Add environment variables:

One of the environment variables is source ~/.../devel/setup.bash, and the other is

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS。

Among them, ~/.../devel/setup.bash can be written into ~/.bashrc.

Write method:

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

Among them, the paths such as "PATH/ORB_SLAM2/Examples/ROS" are modified according to the actual situation.

Or use the text editor gedit or vim to edit ~/.bashrc

在终端中输入:
sudo gedit ~/.bashrc

使用gedit打开 ~/.bashrc,弹出文本编辑页面;
在文档末尾,追加:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
source ~/catkin_ws/devel/setup.bash

Among them, the paths such as "PATH/ORB_SLAM2/Examples/ROS" are modified according to the actual situation. 

4. ./build_ros.sh compile

Use ./build_ros.sh in the ORB_SLAM2 source file folder to compile, first authorize it, and then execute it:

chmod +x build_ros.sh
./build_ros.sh

 Related Reading

Compile and install ORB-SLAM2 and run the KITTI dataset_orb-slam2 kitti_Jinterest's Blog-CSDN Blog

run dataset

Start three terminals, which are used to start the master, run the executable program of ORB_SLAM2, and play rosbag respectively.

Take monocular as an example.

1. Start the master 

Start a terminal and execute roscore:

roscore

open master 

 2. Run the executable program of ORB_SLAM2

Start another terminal, run the executable program of ORB_SLAM2, and execute 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

Among them, paths such as "PATH_TO_VOCABULARY" are modified according to the actual situation.

In my case, run the dataset of KITTI00-02:

 rosrun ORB_SLAM2 Mono Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml

At this point, two interfaces of the ORB_SLAM2 executable program pop up.

3. Play rosbag

Start another terminal, play rosbag, execute rosbag play: 

rosbag play xxx.bag

Play rosbag. 

topic remapping

It should be noted that for your own data set, there may be inconsistencies between the topic topic of the data set and the topic topic used by ORB_SLAM2 to receive camera data. If they are not consistent, there will be no calculation results and no changes in the two interfaces of the program. Therefore, it is necessary to match the two.

For example, the topic topic ORB_SLAM2 uses to receive camera data is `/camera/image_raw`, while the topic topic of the camera in my data set is "kitti/camera_color_left/image_raw", the two need to be matched, and when the data set can be played again, Additional parameters:

rosbag play xxx.bag /kitti/camera_color_left/image_raw:=/camera/image_raw

So far, the calculation results will appear on the two interfaces of the ORB_SLAM2 program.

result

Take me for example:

Refer to README.md of ORB_SLAM2:

# 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

report error

libboost_system

./build_ros.sh compiles and reports an error: /usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command
set() in CMakeLists.txt in the Example/ROS/ORB_SLAM2/ folder Add "-lboost_system", that is

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
)

link master failed

[ERROR] [1682320579.511743459]: [registerPublisher] Failed to contact master at [localhost:11311].  Retrying...

The prompt needs to start ROS master, that is, at the beginning of the program running, you need to start a terminal and execute "roscore".

topic needs to correspond

Camera data in kitti dataset

rosbag play xxx.bag, and at the same time, the topic /kitti/camera_color_left/image_raw of xxx.bag corresponds to /camera/image_raw

To play a bag file in Ros and remap its topic to another name, you can use the following command:

rosbag play xxx.bag /kitti/camera_color_left/image_raw:=/camera/image_raw

This will play the bag file named "xxx.bag" and remap its topic "/kitti/camera_color_left/image_raw" to "/camera/image_raw". This will enable you to use the "/camera/image_raw" topic in Ros to access the data in the bag file.

Related Reading

github

GitHub - raulmur/ORB_SLAM2: Real-Time SLAM for Monocular, Stereo and RGB-D Cameras, with Loop Detection and Relocalization Capabilities

Guess you like

Origin blog.csdn.net/weixin_56337147/article/details/130344059