一、安装Intel Realsense SDK
二、在Ubuntu18.04下安装Ros-melodic
三、安装realsense-ros
以上三部分链接:https://blog.csdn.net/weixin_45702256/article/details/108673424
https://blog.csdn.net/weixin_45702256/article/details/109329644
四、ORB——SLAM2安装
参考连接:https://github.com/raulmur/ORB_SLAM2
gcc g++ opencv Eigen3.3 cmake Pangolin
1、没有cmake、gcc g++的进行下载安装
#1 cmake
sudo apt-get install cmake
#2 gcc、g++
sudo apt-get install gcc g++
2、Pangolin安装
# 1 依赖
sudo apt-get install libglew-dev
# 2 下载安装包
git clone https://github.com/stevenlovegrove/Pangolin.git
# 3 安装
cd Pangolin
mkdir build
cd build
cmake -DCPP11_NO_BOOSR=1 ..
sudo make
sudo make install
3、安装Eigen 3.3.4
sudo apt-get install libeigen3-dev
4、ORB_SLAM2安装
在ROS下,将ORB——SLAM2文件放在home/catkin_ws/src下
cd ~/catkin_ws/src/
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh
运行./build.sh时将文件内make -j
改为make
./build.sh:编译出错
问题:ORB_SLAM2/src/System.cc: error: ‘usleep’ was not declared in this scope usleep(5000);
此时在对应文件中加入头文件
#include<unistd.h>
对应文件:
Examples/Moncular/mono_euroc.cc
Examples/Moncular/mono_kitti.cc
Examples/Moncular/mono_tum.cc
Examples/RGB-D/rgbd_tum.cc
Examples/Stereo/stereo_euroc.cc
Examples/Stereo/stereo_kitti.cc
文件:/home/wyh/catkin_ws/src/ORB_SLAM2/src
src/LocalMapping.cc
src/LoopClosing.cc
src/System.cc
src/Tracking.cc
src/Viewer.cc
#ROS环境运行
chmod +x build_ros.sh
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/catkin_ws/src/ORB_SLAM2/Examples/ROS
./build_ros.sh
问题:运行./build_ros.sh出错:
解决:修改home/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/文件夹下的CMakeLists.txt文件
加入代码:-lboost_system
5、D435i运行测试
a:在ORB-SLAM2/Examples/ROS/ORB-SLAM2/src中修改ros_rgbd.cc的topic订阅:
message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/color/image_raw", 1);
message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "/camera/aligned_depth_to_color/image_raw", 1);
b: 重新编译ORB-SLAM2
chmod +x build_ros.sh
./build_ros.sh
C:启动相机
roslaunch realsense2_camera rs_rgbd.launch
出现错误:
此问题解决:
sudo apt-get install ros-melodic-rgbd-launch
同时打开topic出错:
此问题解决:
D:利用TUM1.yaml的参数
rosrun ORB_SLAM2 RGBD Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml
E:修改参数利用D435i参数运行
rosrun ORB_SLAM2 RGBD Vocabulary/ORBvoc.txt Examples/RGB-D/D435i.yaml
rosrun ORB_SLAM2 RGBD /home/wyh/catkin_wyh/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/wyh/catkin_wyh/src/ORB_SLAM2/Examples/RGB-D/D435i.yaml /camera/rgb/image_raw:=/camera/color/image_raw /camera/depth_registered/image_raw:=/camera/aligned_depth_to_color/image_raw
F:D435i参数获取:
roslaunch realsense2_camera rs_rgbd.launch
rostopic echo /camera/color/camera_info
D435ℹi文件内容:
%YAML:1.0
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
# Camera calibration and distortion parameters (OpenCV)
Camera.fx: 614.216064453125
Camera.fy: 613.1551513671875
Camera.cx: 326.0156555175781
Camera.cy: 245.55152893066406
Camera.k1: 0.0
Camera.k2: 0.0
Camera.p1: 0.0
Camera.p2: 0.0
Camera.k3: 0.0
Camera.width: 640
Camera.height: 480
# Camera frames per second
Camera.fps: 30.0
# IR projector baseline times fx (aprox.)
#bf = baseline (in meters) * fx, D435i的 baseline = 50 mm
Camera.bf: 30.711
# Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
Camera.RGB: 1
# Close/Far threshold. Baseline times.
ThDepth: 40.0
# Deptmap values factor
DepthMapFactor: 1000.0
#--------------------------------------------------------------------------------------------
# ORB Parameters
#--------------------------------------------------------------------------------------------
# ORB Extractor: Number of features per image
ORBextractor.nFeatures: 1000
# ORB Extractor: Scale factor between levels in the scale pyramid
ORBextractor.scaleFactor: 1.2
# ORB Extractor: Number of levels in the scale pyramid
ORBextractor.nLevels: 8
# ORB Extractor: Fast threshold
# Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
# Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
# You can lower these values if your images have low contrast
ORBextractor.iniThFAST: 20
ORBextractor.minThFAST: 7
#--------------------------------------------------------------------------------------------
# Viewer Parameters
#--------------------------------------------------------------------------------------------
Viewer.KeyFrameSize: 0.05
Viewer.KeyFrameLineWidth: 1
Viewer.GraphLineWidth: 0.9
Viewer.PointSize:2
Viewer.CameraSize: 0.08
Viewer.CameraLineWidth: 3
Viewer.ViewpointX: 0
Viewer.ViewpointY: -0.7
Viewer.ViewpointZ: -1.8
Viewer.ViewpointF: 500
参考连接:https://blog.csdn.net/jiangchuanhu/article/details/92795791
https://blog.csdn.net/weixin_44436677/article/details/105587986
https://blog.csdn.net/qq_41839222/article/details/86503113
六、RTAB安装(map)
链接:https://github.com/introlab/rtabmap_ros
https://www.ncnynl.com/archives/201709/1991.html
https://blog.csdn.net/qq_41839222/article/details/86503113
1、安装rtabmap
git clone https://github.com/introlab/rtabmap.git
cd rtabmap/build
# cmake -DCMAKE_INSTALL_PREFIX=~/catkin_ws/devel ..
cmake ..
make -j4
sudo make install
2、安装rtabmap_ros
#个版本环境
##a:Noetic
sudo apt install ros-noetic-rtabmap-ros
##b: Melodic
sudo apt install ros-melodic-rtabmap-ros
##c: Kinetic
sudo apt-get install ros-kinetic-rtabmap-ros
##d: Indigo
sudo apt-get install ros-indigo-rtabmap-ros
#安装
cd ~/catkin_ws
git clone https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
catkin_make -j1
3、修改catkin_ws/src/rtabmap_ros/launch中的rtabmap.launch
<!-- RGB-D related topics -->
<arg name="rgb_topic" default="/camera/color/image_raw" />
<arg name="depth_topic" default="/camera/aligned_depth_to_color/image_raw" />
<arg name="camera_info_topic" default="/camera/color/camera_info" />
<arg name="depth_camera_info_topic" default="$(arg camera_info_topic)" /> <!-- RGB-D related topics -->
<arg name="rgb_topic" default="/camera/color/image_raw" />
<arg name="depth_topic" default="/camera/aligned_depth_to_color/image_raw" />
<arg name="camera_info_topic" default="/camera/color/camera_info" />
<arg name="depth_camera_info_topic" default="$(arg camera_info_topic)" />
4、运行
#打开相机
roslaunch realsense2_camera rs_rgbd.launch
#打开rviz
roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" rviz:=true rtabmapviz:=false
roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" depth_topic:=/camera/depth/image_rect_raw rgb_topic:=/camera/color/image_raw camera_info_topic:=/camera/color/camera_info approx_sync:=false rviz:=true