本文主要是介绍【无人机自主导航5 SLAM】Intel Realsense T265C双目相机实现ORB-SLAM3,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
转载自:https://dgzc.ganahe.top/ganahe/2021/wrjzzdhsjirtsmxj.html
【无人机自主导航5 SLAM】Intel Realsense T265C双目相机实现ORB-SLAM3
C/C++ GanAHE 4个月前 (03-21) 32次浏览 已收录 5个评论 扫描二维码
文章目录[隐藏]
- 一、ORB-SLAM3依赖
- 二、ORB-SLAM3配置编译
- 三、编译ORB-SLAM3的ROS接口
- 四、运行ORB-SLAM3
- 补充
深度相机的SDK驱动安装、ROS功能包编译等内容在本站文章:
【无人机自主导航4-1 视觉传感器】通过ROS发布、订阅话题连接视觉相机已有说明,未配置环境的先进行驱动配置。
一、ORB-SLAM3依赖
(一)Pangolin
#安装依赖
sudo apt install libglew-dev
sudo apt install cmake
sudo apt install libpython2.7-dev
#可选依赖见github,我没装所以就不贴出来啦
#下载并编译
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
cmake --build .
#最后不要忘了安装
sudo make install
(二)其他
根据Github仓库自行安装其他缺少的库。
二、ORB-SLAM3配置编译
cd ~/catkin_ws/src
git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git ORB_SLAM3
#编译
cd ORB_SLAM3
chmod +x build.sh
./build.sh
cd ..
catkin_make
source devel/setup.bash
三、编译ORB-SLAM3的ROS接口
chmod +x build_ros.sh
./build_ros.sh
3.1 修正相机 launch
根据下方路径自行修改launch文件,包括相机内外参数、启动的镜头、fps等,启动相机时,启动更改后相应的文件即可:
ganahe@ganahe-Nitro-AN515-51:~/catkin_ws/src/realsense-ros/realsense2_camera/launch$ pwd
/home/ganahe/catkin_ws/src/realsense-ros/realsense2_camera/launch
ganahe@ganahe-Nitro-AN515-51:~/catkin_ws/src/realsense-ros/realsense2_camera/launch$ tree
.
├── demo_pointcloud.launch
├── demo_t265.launch
├── includes
│ └── nodelet.launch.xml
├── opensource_tracking.launch
├── rs_aligned_depth.launch
├── rs_camera.launch
├── rs_d400_and_t265.launch
├── rs_d435_camera_with_model.launch
├── rs_from_file.launch
├── rs_multiple_devices.launch
├── rs_rgbd.launch
├── rs_rtabmap.launch
└── rs_t265.launch
本机的参数文件如下:
<!--
Important Notice: For wheeled robots, odometer input is a requirement for robust
and accurate tracking. The relevant APIs will be added to librealsense and
ROS/realsense in upcoming releases. Currently, the API is available in the
https://github.com/IntelRealSense/librealsense/blob/master/third-party/libtm/libtm/include/TrackingDevice.h#L508-L515.
-->
<launch>
<arg name="serial_no" default=""/>
<arg name="usb_port_id" default=""/>
<arg name="device_type" default="t265"/>
<arg name="json_file_path" default=""/>
<arg name="camera" default="camera"/>
<arg name="tf_prefix" default="$(arg camera)"/>
<arg name="fisheye_width" default="848"/>
<arg name="fisheye_height" default="800"/>
<arg name="enable_fisheye1" default="true"/>
<arg name="enable_fisheye2" default="true"/>
<arg name="fisheye_fps" default="30"/>
<arg name="gyro_fps" default="200"/>
<arg name="accel_fps" default="62"/>
<arg name="enable_gyro" default="true"/>
<arg name="enable_accel" default="true"/>
<arg name="enable_pose" default="true"/>
<arg name="enable_sync" default="false"/>
<arg name="linear_accel_cov" default="0.01"/>
<arg name="initial_reset" default="false"/>
<arg name="unite_imu_method" default=""/>
<arg name="publish_odom_tf" default="true"/>
<group ns="$(arg camera)">
<include file="$(find realsense2_camera)/launch/includes/nodelet.launch.xml">
<arg name="tf_prefix" value="$(arg tf_prefix)"/>
<arg name="serial_no" value="$(arg serial_no)"/>
<arg name="usb_port_id" value="$(arg usb_port_id)"/>
<arg name="device_type" value="$(arg device_type)"/>
<arg name="json_file_path" value="$(arg json_file_path)"/>
<arg name="enable_sync" value="$(arg enable_sync)"/>
<arg name="fisheye_width" value="$(arg fisheye_width)"/>
<arg name="fisheye_height" value="$(arg fisheye_height)"/>
<arg name="enable_fisheye1" value="$(arg enable_fisheye1)"/>
<arg name="enable_fisheye2" value="$(arg enable_fisheye2)"/>
<arg name="fisheye_fps" value="$(arg fisheye_fps)"/>
<arg name="gyro_fps" value="$(arg gyro_fps)"/>
<arg name="accel_fps" value="$(arg accel_fps)"/>
<arg name="enable_gyro" value="$(arg enable_gyro)"/>
<arg name="enable_accel" value="$(arg enable_accel)"/>
<arg name="enable_pose" value="$(arg enable_pose)"/>
<arg name="linear_accel_cov" value="$(arg linear_accel_cov)"/>
<arg name="initial_reset" value="$(arg initial_reset)"/>
<arg name="unite_imu_method" value="$(arg unite_imu_method)"/>
<arg name="publish_odom_tf" value="$(arg publish_odom_tf)"/>
</include>
</group>
</launch>
启动指令如下:
roscore
打开新的终端,启动T265C:
# 注意在此之前必须在 rs_t265.launch中设定相机的参数,比如是否开启相机
roslaunch realsense2_camera rs_t265.launch
3.2 修改Topic
打开相机节点实现通讯:
# 注意在此之前必须在 rs_t265.launch中设定相机的参数,比如是否开启相机
roslaunch realsense2_camera rs_t265.launch
查看相机镜头对应的话题信息:
rostopic list
根据显示的信息修改ros_stereo.cc
文件,比如本文中的数据修正为:
message_filters::Subscriber<sensor_msgs::Image> left_sub(nh, "/camera/fisheye1/image_raw", 1);
message_filters::Subscriber<sensor_msgs::Image> right_sub(nh, "/camera/fisheye2/image_raw", 1);
再次编译./build_ros.sh
3.3 再次编译功能包
随后执行:
cd ~/catkin_ws
catkin_make
source devel/setup.bash
四、运行ORB-SLAM3
三个终端
- 首先执行:
roscore
- 运行相机:
roslaunch realsense2_camera rs_t265.launch
- 运行SLAM:
rosrun ORB_SLAM3 Stereo ~/catkin_ws/src/ORB_SLAM3/Vocabulary/ORBvoc.txt
~/catkin_ws/src/ORB_SLAM3/Examples/ROS/ORB_SLAM3/T265.yaml false
补充
根据大家的反馈,下面补充本文实验所用的T265.yaml文件,基本采用官方的改动较小:
%YAML:1.0
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
Camera.type: "PinHole"
# Camera calibration and distortion parameters (OpenCV)
Camera.fx: 286.419189453125
Camera.fy: 286.384307861328
Camera.cx: 101.355010986328
Camera.cy: 102.183197021484
Camera.k1: 0.0
Camera.k2: 0.0
Camera.p1: 0.0
Camera.p2: 0.0
Camera.width: 848
Camera.height: 800
# Camera frames per second
Camera.fps: 30.0
# IR projector baseline times fx (aprox.)
Camera.bf: 40.0
# 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: 1.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
GanAHE 的小创元世纪, 版权所有丨如未注明 , 均为原创丨本网站采用@BY-NC-SA协议进行授权
转载请注明原文链接:【无人机自主导航5 SLAM】Intel Realsense T265C双目相机实现ORB-SLAM3
这篇关于【无人机自主导航5 SLAM】Intel Realsense T265C双目相机实现ORB-SLAM3的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!