---
# System prepended metadata

title: Visual_SLAM教學

---

Outline
===

>[name=吳昱鋒][time=2022_08_26]

[TOC]

# Intsall ROS Melodic
http://wiki.ros.org/melodic/Installation/Ubuntu

* RTAB-Map & RTAB-Map ros-pkg (Included g2o)
> $ sudo apt install ros-melodic-rtabmap ros-melodic-rtabmap-ros

* Install GTSAM from Ubuntu PPA
* PPA，表示Personal Package Archives，也就是个人软件包集。 有很多軟體因为種種原因，不能進入官方的Ubuntu的軟體倉庫。 為了方便Ubuntu用户使用，launchpad.net 提供了ppa，允许用户建立自己的軟體倉庫， 自由的上傳軟體。
> $ sudo add-apt-repository ppa:borglab/gtsam-release-4.0
> $ sudo apt update
> $ sudo apt install libgtsam-dev libgtsam-unstable-dev

# Intsall RTAB-Map
> $ cd ~
* Note the version differences
* (RTAB-Map and RTAB-Map ros-pkg should be the same version)
* Link:https://github.com/introlab/rtabmap/releases/tag/0.20.16
> $ wget https://github.com/introlab/rtabmap/archive/refs/tags/0.20.16.tar.gz
> $ tar -xzvf rtabmap-***.tar.gz (Unzip to /home)
> $ cd rtabmap/build
> $ cmake ..
> $ make
> $ sudo make install

# Install RTAB-Map ros-pkg
> $ cd ~/catkin_ws/src
* Note the version differences
* (RTAB-Map and RTAB-Map ros-pkg should be the same version)
* Link:https://github.com/introlab/rtabmap_ros/releases/tag/0.20.16-melodic
> $ wget https://github.com/introlab/rtabmap_ros/archive/refs/tags/0.20.16-melodic.tar.gz
> $ tar -xzvf rtabmap_ros-***.tar.gz (Unzip to /catkin_ws/src)
> $ sudo ldconfig
> $ catkin_make -DRTABMAP_SYNC_MULTI_RGBD=ON 

# Install Realsense D435 SDK
**librealsense**
* Link:https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md
> $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
> $ sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
> $ sudo apt-get install librealsense2-dkms
> $ sudo apt-get install librealsense2-utils
> $ sudo apt-get install librealsense2-dev
> $ sudo apt-get install librealsense2-dbg
* test
> $ realsense-viewer 

**realsense-ros**
* Link:https://github.com/IntelRealSense/realsense-ros
> $ sudo apt-get install ros-$ROS_DISTRO-realsense2-camera
> $ mkdir -p realsense_ws/src
> $ cd realsense_ws/src/
> $ git clone https://github.com/IntelRealSense/realsense-ros.git
> $ cd realsense-ros
> $ git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1`
> $ cd ..
> $ catkin_init_workspace
> $ cd ..
> $ catkin_make clean
> $ catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
> $ catkin_make install
> $ echo "source ~/realsense_ws/devel/setup.bash" >> ~/.bashrc
> $ source ~/.bashrc

# CMake Upgrade
* Link:https://zhuanlan.zhihu.com/p/93480024
* Link:https://cmake.org/files/
> $ cd ~/Download
> $ wget https://cmake.org/files/v3.23/cmake-3.23.0-linux-aarch64.tar.gz
> $ tar -xzvf cmake-3.23.0-linux-x86_64.tar.gz
> $ sudo mv cmake-3.23.0-linux-x86_64 /opt/cmake-3.23.0
> $ sudo ln -sf /opt/cmake-3.23.0/bin/* /usr/bin

Check CMake Version
> $ cmake --version

# Navigation to Octomap
> $ rtabmap-databaseViewer 
* file → opendatabase → open your .db file
* ![](https://i.imgur.com/sOos9h8.png)

* Edit → Detect more loop closure(偵測更多的閉環)
* ![](https://i.imgur.com/42UCqUd.png)

* Export 3D map(匯出3D地圖，存成.pcd檔)
![](https://i.imgur.com/lDR61wj.png)

* 開啟CloudCompare
* 匯入剛剛.pcd的檔地圖
![](https://i.imgur.com/n75NRPB.png)
![](https://i.imgur.com/ueVBAwv.png)
![](https://i.imgur.com/j8z36RW.png)


# evo trajectory and ATE test
* Link: https://zhuanlan.zhihu.com/p/364825667
* Link: https://blog.csdn.net/KYJL888/article/details/89956551

* 秀出軌跡
> evo_traj kitti twocamfb.txt onecamceiling.txt onecamline.txt onecam60.txt twocam60_o.txt proposed.txt -p --plot_mode=xz
* 軌跡參數設定
> evo_config set plot_show_legend false
> evo_config show   &emsp;  //秀出所有參數
> evo_config set plot_trajectory_linestyle --   &emsp;  //設定軌跡線為虛線
> evo_config set plot_reference_linestyle -     &emsp;  //設定參考軌跡線為實線
* 軌跡誤差
> evo_ape kitti gt.txt fb.txt -va --plot --plot_mode xz --save_plot ./tra1plot --save_results ./tra1.zip




