티스토리 뷰

 작성자 : 한양대학원 융합로봇시스템학과 유승환 석사과정 (CAI LAB)

 

 오늘은 Jeston Nano에서 ORB SLAM2를 설치 및 실행을 해보겠습니다~! 참고로 ROS-Melodic으로 구동할겁니다. ORB SLAM2는 RGBD 카메라로 3D Mapping을 하는 기술입니다. 저는 카메라로 RealSense D435를 사용합니다. 제가 존경하는 분께서 SLAM을 작업해볼 기회를 주셔서 이번 기회에 작업을 정리해보고자 합니다!

ORB SLAM 2 결과물 일부 // 출처 : https://github.com/raulmur/ORB_SLAM2


 

raulmur/ORB_SLAM2

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

github.com


0. 기본적인 환경 셋팅 (JetPack, OpenCV, ROS, RealSense-lib 설치)

 

NVIDIA Jeston 환경 셋팅 1-2편 (JetPack 설치 On Jeston Nano)

작성자 : 한양대학원 융합로봇시스템학과 석사과정 유승환  이번에는 Jeston Nano에 JetPack 설치를 해보겠습니다! 작성 날짜 기준으로 JetPack은 Version 4.5이며, 기본적으로 Ubuntu 18.04, CUDA 10.2, cuDNN 8..

ropiens.tistory.com

 

NVIDIA Jeston 환경 셋팅 2-1편 (OpenCV 3.4.0 설치 on Jeston Nano)

작성자 : 한양대학원 융합로봇시스템학과 석사과정 유승환  저의 목표는 ROS-Melodic를 활용하여 카메라(Real-Sense)에서 얻은 이미지를 YOLOv3로 Object Detecting하고 Detect한 좌표를 ros-topic으로 받아오는.

ropiens.tistory.com

 

NVIDIA Jeston 환경 셋팅 3편 (ROS, RealSense-SDK, RealSense-ROS설치)

작성자 : 한양대학원 융합로봇시스템학과 석사과정 유승환  오늘도 NVIDIA Jeston 환경 셋팅을 해보겠습니다! 전편의 Jetpack, OpenCV 설치에 이어서, ROS, RealSense-SDK 그리고 RealSense-ROS를 설치해보겠습..

ropiens.tistory.com


1. ORB SLAM에 필요한 lib 설치

(1) Pangolin

 

stevenlovegrove/Pangolin

Pangolin is a lightweight portable rapid development library for managing OpenGL display / interaction and abstracting video input. - stevenlovegrove/Pangolin

github.com

  • Dependencies 설치
# 1. OpenGL
sudo apt install libgl1-mesa-dev

# 2. Glew
sudo apt install libglew-dev

# 3. CMake
sudo apt install cmake

# 4. python
sudo apt install libpython2.7-dev
sudo apt-get install python-pip
sudo python -mpip install numpy pyopengl Pillow pybind11

# 5. wayland
sudo apt install pkg-config
sudo apt install libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols

# 6. PCL For ROS
sudo apt-get install libopenni2-dev
sudo apt-get install ros-melodic-pcl-ros
  •  Building
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
cmake --build .

(2) Eigen 3

# Eigen 3
sudo apt install libeigen3-dev

2. Building ORB-SLAM2 Library and Examples

# clone the repository
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2

# build
cd ORB_SLAM2
chmod +x build.sh
./build.sh
  • build를 하게 되면 아래와 같은 Make 에러가 발생할겁니다.

출처 : https://github.com/raulmur/ORB_SLAM2/issues/661

  • 이 에러는 아래의 2가지 파일을 수정하면 해결됩니다.

(1) ~/ORB_SLAM2/build.sh

  - line 7, 16, 31에서 make -j   -->  make -j2 로 수정해줍니다. (메모리 용량 때문)

echo "Configuring and building Thirdparty/DBoW2 ..."

cd Thirdparty/DBoW2
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j2

cd ../../g2o

echo "Configuring and building Thirdparty/g2o ..."

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j2

cd ../../../

echo "Uncompress vocabulary ..."

cd Vocabulary
tar -xf ORBvoc.txt.tar.gz
cd ..

echo "Configuring and building ORB_SLAM2 ..."

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j2

(2) ~/ORB_SLAM2/include/System.h

 - inclued 라인에 #include <unistd.h> 를 추가해줍니다.

#include <unistd.h> 

 - 참고 깃헙 링크 : github.com/raulmur/ORB_SLAM2/issues/661

 

build.sh error · Issue #661 · raulmur/ORB_SLAM2

Simply installed depencies and run build.sh. got error: /usr/local/include/eigen3/Eigen/src/Core/util/Constants.h:162:37: note: declared here EIGEN_DEPRECATED const unsigned int AlignedBit = 0x80; ...

github.com


3. Building ORB-SLAM2 Library and Examples (ROS)

  • 마지막 설치입니다.
  • 아래의 export에서 '~/ORB_SLAM2/Examples/ROS' 부분은 예시입니다.
  • 자신의 ORB_SLAM2 설치 위치에 맞게 setting 하면 됩니다.
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/ORB_SLAM2/Examples/ROS

chmod +x build_ros.sh
./build_ros.sh
  • 이 빌드를 하면 또 에러가 뜰겁니다. 

에러 내용 // 출처 : https://github.com/raulmur/ORB_SLAM2/issues/551

  • 이것도 아래의 2개의 파일을 수정하면 됩니다.

(1) ~/ORB_SLAM2/build_ros.sh

  - line 7에서 make -j   -->  make -j2  로 수정해줍니다. 

echo "Building ROS nodes"

cd Examples/ROS/ORB_SLAM2
mkdir build
cd build
cmake .. -DROS_BUILD_TYPE=Release
make -j2

(2) ~/ORB_SLAM2/CMakeLists.txt

 - 아래의 링크를 참고하여 코드 3줄(초록색 부분)을 추가합니다.

 - 깃헙 링크 : github.com/raulmur/ORB_SLAM2/pull/507/commits/5a5cc2aba95bcd40dfb41a7b084ad6c8ef60fa64

 

Added missing Boost dependency in ROS package by rdelfin · Pull Request #507 · raulmur/ORB_SLAM2

The ROS package was missing Boost as a dependency, causing the linker to fail. This pull request fixes the issue.

github.com


4. ROS Examples (ORB SLAM2 : RGB-D)

- ORB SLAM2에서는 3가지 버전을 제공합니다.

- Mono(only rgb img), Stereo(카메라 2대를 이용), RGB-D(rgb + depth img)

- 저는 RGB-D 버전을 사용해보겠습니다.


(1) ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_rgbd.cc 수정

- 카메라 토픽을 수정합니다.

- (저는 RealSense D435 모델 기준으로 작성했습니다, 다른 카메라를 사용하신다면 rostopic list로 확인하면 됩니다.)

- line 68 : /camera/rgb/image_raw -> /camera/color/image_raw

- line 69 : camera/depth_registered/image_raw -> /camera/depth/image_rect_raw

# ros_rgbd.cc

# line 68
message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/color/image_raw", 1);

# line 69
message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "/camera/depth/image_rect_raw", 1);

- 수정한 후 ORB_SLAM2 폴더를 재빌드 해줍니다.

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

chmod +x build_ros.sh
./build_ros.sh

(2) RGB-D Node 실행

- 3개의 터미널 창을 키고 각각의 창에 아래의 명령어를 입력합니다.

# terminal 1

# FAN ON
sudo sh -c 'echo 130 > /sys/devices/pwm-fan/target_pwm'

# ROS ON
roscore
# terminal 2

# RealSense Node ON
roslaunch realsense2_camera rs_camera.launch
# terminal 3

# RGB-D SLAM Node ON
cd ~/ORB_SLAM2

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

rosrun ORB_SLAM2 RGBD ~/ORB_SLAM2/Vocabulary/ORBvoc.txt ~/ORB_SLAM2/Examples/RGB-D/TUM1.yaml

- 아래와 같은 창이 뜨면 성공!!

 


 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31