본문 바로가기
VisualSLAM

[VisualSLAM] ORB_SLAM2 설치 및 실행

by yongee97 2022. 11. 29.

* Ubuntu 18.04

* Desktop

 

목적

- ORB_SLAM2 및 ROS 패키지 설치

- Bag 파일로 녹화된 영상의 이미지 처리

- Realsesne2 Camera 실행 및 이미지 처리

 

1. ORB_SLAM2 다운로드 및 설치

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
chmod +x build.sh
./build.sh

 

 

2. 에러 확인 후 아래 내용 반영

 

* Eigen3 패키지 설치

sudo apt-get install libeigen3-dev

 

* CMakeLists.txt 수정

# in the directory including CMakeLists
sed -i 's/++11/++14/g' CMakeLists.txt

* Pangolin 설치

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build && cd build
cmake ..
make -j20
sudo make install
# optional
sudo ldconfig

* 파일 내부 일부 수정

(에러가 뜨는 파일에 한해서 진행)

#include <unistd.h>

 

3. ROS 패키지 설치

./build_ros.sh

 

 

4. bag 파일 이미지 처리

* bag 파일에는 compressed image가 있다고 가정

# terminal 1, roscore
roscore
# terminal 2, image type change
rosrun image_transport republish compressed in:=/camera/color/image_raw _image_transport:=compressed raw out:=/image_out
# terminal 3, ORB_SLAM
rosrun ORB_SLAM2 Mono Vocabulary/ORBvoc.txt Examples/Monocular/D435i.yaml /camera/image_raw:=/image_out
# terminal 4, bag file
rosbag play 2022.bag --topics /camera/color/image_raw/compressed

 

5. Realsense D435i Mono로 처리

# terminal 1, roscore
roscore
# terminal 2, realsense
roslaunch realsense2_camera rs_camera.launch
# terminal 3, ORB_SLAM2
rosrun ORB_SLAM2 Mono Vocabulary/ORBvoc.txt Examples/Monocular/D435i.yaml /camera/image_raw:=/camera/color/image_raw