# ORBSlam2和RealSense相關資訊2020/07/11
* 2020/07/08下載好 orbslam2
Lennarthaller committed "9207b77" version on 22 Apr in 2020
1.新版本將.yaml相機參數都移至 launch檔中
2.新版本通過加速Vocabarary加載(loading)速度,提升啟動時間
3.新本中支援加載相機參數透過cam_info
4.新版本實現刪除了Pangolin依賴項和原始查看器(?
5.所有數據I/O均通過ROS topic進行處理(?
6.可以在運行時使用rqt_reconfigure gui設置參數
7.可應用於Monocular,Stereo,RGB-D三種相機
8.SLAM模式和Localization模式可透過GUI切換
9.可計算攝像機軌跡和稀疏的3D重建
10.能夠實時進行回還檢測並重新定位攝像機
11.測試SLAM在KITTI數據集以立體或單眼,在TUM數據集以RGB-D或單眼
,在EuRoC數據集以立體或單眼運行SLAM系統(詳情可見舊版ORBSLAM的ch4~6)
* 所有依賴向來原檔案,例如:DBoW2
All code in DBoW2 folder. This is a modified version of DBoW2 and DLib library. All files included are BSD licensed.
https://github.com/appliedAI-Initiative/orb_slam_2_ros/blob/master/Dependencies.md
* 需要i7處理器確保時時性能,以及C++11編譯器
* 如果您在學術作品中使用ORB-SLAM2(立體聲或RGB-D)請引用:
@article{murORB2,
title={{ORB-SLAM2}: an Open-Source {SLAM} System for Monocular, Stereo and {RGB-D} Cameras},
author={Mur-Artal, Ra\'ul and Tard\'os, Juan D.},
journal={IEEE Transactions on Robotics},
volume={33},
number={5},
pages={1255--1262},
doi = {10.1109/TRO.2017.2705103},
year={2017}
}
* 相關出版論文
[Monocular] Raúl Mur-Artal, J. M. M. Montiel and Juan D. Tardós. ORB-SLAM: A Versatile and Accurate Monocular SLAM System. IEEE Transactions on Robotics, vol. 31, no. 5, pp. 1147-1163, 2015. (2015 IEEE Transactions on Robotics Best Paper Award). PDF.
[Stereo and RGB-D] Raúl Mur-Artal and Juan D. Tardós. ORB-SLAM2: an Open-Source SLAM System for Monocular, Stereo and RGB-D Cameras. IEEE Transactions on Robotics, vol. 33, no. 5, pp. 1255-1262, 2017. PDF.
[DBoW2 Place Recognizer] Dorian Gálvez-López and Juan D. Tardós. Bags of Binary Words for Fast Place Recognition in Image Sequences. IEEE Transactions on Robotics, vol. 28, no. 5, pp. 1188-1197, 2012. PDF
mutex
* ROS參數parameters,主題topics 和服務services
- [ ] 1. 參數(static-靜態、dynamic-動態、 camera settings-相機參數)
**靜態參數**在啟動時會發送到ROS參數服務器,並且不應更改。他們在launch檔案中被設定好
-load_map:Bool。如果設置為true,則節點將在啟動時嘗試加載map_file提供的地圖。
-map_file:String。加載地圖的文件的名稱。
-voc_file:String。上面提到的配置vocanulary文件的位置路徑。
-publish_pointcloud:Bool。是否應發布包含所有關鍵點(地圖的)的點雲。
-publish_pose:Bool。是否發布PoseStamped消息。**即使這是錯誤**的tf仍將被發布。
-pointcloud_frame_id:String。Pointcloud地圖的Frame ID。
-camera_frame_id:字符串。Pointcloud/map.的Frame ID。
-load_calibration_from_cam:Bool。如果為true,則從**camera_info主題讀取相機校準**。否則,它將從啟動文件參數中讀取。
**動態參數**可以再運行時改變,建議使用指令來更新動態參數
-localize_only:Bool。切換from/to localization。然後,SLAM將不再向地圖更新點雲資料。
reset_map:Bool。設置為true將刪除地圖並重新開始。重置後,參數將自動更新回false。
min_num_kf_in_map:Int。地圖必須包含多少的關鍵幀,才能夠在跟踪丟失後不必重置。
min_observations_for_ros_map:Int。關鍵點必須在點雲中發布的最小觀察數。這根本不會影響SLAM本身的行為。
**相機的固有校準參數以及一些超參數**可以在orb_slam2/config中的特定yaml文件中找到
- [ ] 2. 話題發布和訂閱的主題
節點正在發布以下主題:
-所有節點都會發布(給定設置)包含地圖所有關鍵點的PointCloud2。
-所有節點都會發布(給定設置)帶有攝像機當前姿勢的PoseStamped。
-來自攝像機的實時圖像,其中包含當前找到的關鍵點和狀態文本。
-從Pointcloud Frame ID到攝像機Frame ID(位置)的tf。
節點正在訂閱以下主題:
-The mono node subscribes to:
**-The RGBD node subscribes to:
/camera/rgb/image_raw用於RGB圖像
/camera/depth_registered/image_raw用於深度信息
/camera/rgb/camera_info用於相機校準(如果load_calibration_from_cam)為true**
-The stereo node subscribes to:
- [ ] 3.服務Services
所有節點都可以通過服務node_type/save_map保存地圖。所以save_map服務是:
/orb_slam2_rgbd/save_map
save_map保存地圖的文件名。
* 如何保存地圖
rosservice call /orb_slam2_rgbd/save_map map.bin
您可以將“map.bin”替換為所需的任何文件名。該文件將保存在ROS_HOME下,默認情況下為〜/.ros
* 使用新的/不同的相機
需要調整其他三個參數:Camera.bf,ThDepth和DepthMapFactor。
* 運行realsense節點 rs_rgbd.launch
sudo apt install ros-melodic-rgbd-launch
* 新版網站 https://github.com/appliedAI-Initiative/orb_slam_2_ros
* 舊版本網站 https://github.com/raulmur/ORB_SLAM2
* ROSWIKI官方網站介紹 http://wiki.ros.org/orb_slam2_ros
RealSense像機參數
---
ORBSLAM,像機參數配置 (fx fy cx cy bf ThDepth)
---
* Realsense **fx fy cx cy**數值取得

https://github.com/IntelRealSense/librealsense/blob/165ae36b350ca950e4180dd6ca03ca6347bc6367/third-party/realsense-file/rosbag/msgs/sensor_msgs/CameraInfo.h#L268
* RealSense像機參數 **baseline**

-相機構造在page14
https://www.mouser.com/pdfdocs/Intel_D400_Series_Datasheet.pdf
* **DepthMapFactor**是一個比例因子,表示多少像素對應1公尺

https://github.com/IntelRealSense/realsense-ros/issues/41
* ORBSLAM有關相機參數的原始碼Source code about camera parameter
mThDepth = mbf(baseline)*(float)mThDepth(thDepth)/parameters.fx;

https://github.com/appliedAI-Initiative/orb_slam_2_ros/blob/2850189582eab675a3845869b79b718358825d0a/orb_slam2/src/Tracking.cc#L130
* raulmur(原作著) commented on 20 May 2016:

-Camera.bf= horizontal focal length水平焦距(以像素為單位)乘以基線baseline (以米為單位)。
Camera.bf=fx *baseline(上一張圖可以知道baseline=0.05m)
-ThDepth可以安全地設置在50左右。這在關於ORB-SLAM的立體聲/ rgb-d版本的文件中進行解釋。
https://github.com/raulmur/ORB_SLAM2/issues/89
別人之RealSense參數參考
---

http://m.blog.chinaunix.net/uid-27875-id-5819764.html
在ORB_SLAM2工作目錄下,運行DATA SET
---
https://www.twblogs.net/a/5c980e03bd9eee4a0d0937aa
RealSense下載
---
https://github.com/IntelRealSense/realsense-ros
ROS realsense2的版本幾乎總是落後於RealSense™官方存儲庫中可用的版本。
使用本機v4l2驅動程序,而是使用不穩定的RS-USB協議。
**-官方提供如何維持最佳效能**
https://www.intelrealsense.com/developers/
*rgbdlaunch*
http://wiki.ros.org/rgbd_launch
*realsensecamera*
http://wiki.ros.org/realsense_camera
lsusb
sudo chmod 777 /dev/bus/usb/002/005
相機Calibration
---
-ROS工具
http://wiki.ros.org/camera_calibration/Tutorials/StereoCalibration
-OpenCV介紹
https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#stereorectify
# RealSense calibration tool
https://blog.csdn.net/weixin_39585934/article/details/84147449
rs-sensor-control
Please select the desired streaming profile: 0
Principal Point : 995.526, 562.234
Focal Length : 1381.2, 1381.66
Distortion Model : Inverse Brown Conrady
Distortion Coefficients : [0,0,0,0,0]
Show stream intrinsics again?[y/n]:
相機

啟用ROS的全向機器人(ROS ENABLED OMNIDIRECTIONAL ROBOT)
https://impulsiverobotics.com/2018/04/ros-enabled-omnidirectional-robot/
REP118

https://ros.org/reps/rep-0000.html