【无人机自主导航5 SLAM】Intel Realsense T265C双目相机实现ORB-SLAM3

2023-05-16

转载自: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


  
  1. #安装依赖
  2. sudo apt install libglew-dev
  3. sudo apt install cmake
  4. sudo apt install libpython2.7-dev
  5. #可选依赖见github,我没装所以就不贴出来啦
  6. #下载并编译
  7. git clone https://github.com/stevenlovegrove/Pangolin.git
  8. cd Pangolin
  9. mkdir build
  10. cd build
  11. cmake ..
  12. cmake --build .
  13. #最后不要忘了安装
  14. sudo make install

(二)其他

根据Github仓库自行安装其他缺少的库。

二、ORB-SLAM3配置编译


  
  1. cd ~/catkin_ws/src
  2. git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git ORB_SLAM3
  3. #编译
  4. cd ORB_SLAM3
  5. chmod +x build.sh
  6. ./build.sh
  7. cd ..
  8. catkin_make
  9. source devel/setup.bash

三、编译ORB-SLAM3的ROS接口


  
  1. chmod +x build_ros.sh
  2. ./build_ros.sh

3.1 修正相机 launch

根据下方路径自行修改launch文件,包括相机内外参数、启动的镜头、fps等,启动相机时,启动更改后相应的文件即可:


  
  1. ganahe@ganahe-Nitro-AN515-51:~/catkin_ws/src/realsense-ros/realsense2_camera/launch$ pwd
  2. /home/ganahe/catkin_ws/src/realsense-ros/realsense2_camera/launch
  3. ganahe@ganahe-Nitro-AN515-51:~/catkin_ws/src/realsense-ros/realsense2_camera/launch$ tree
  4. .
  5. ├── demo_pointcloud.launch
  6. ├── demo_t265.launch
  7. ├── includes
  8. │   └── nodelet.launch.xml
  9. ├── opensource_tracking.launch
  10. ├── rs_aligned_depth.launch
  11. ├── rs_camera.launch
  12. ├── rs_d400_and_t265.launch
  13. ├── rs_d435_camera_with_model.launch
  14. ├── rs_from_file.launch
  15. ├── rs_multiple_devices.launch
  16. ├── rs_rgbd.launch
  17. ├── rs_rtabmap.launch
  18. └── rs_t265.launch

本机的参数文件如下:


  
  1. <!--
  2. Important Notice: For wheeled robots, odometer input is a requirement for robust
  3. and accurate tracking. The relevant APIs will be added to librealsense and
  4. ROS/realsense in upcoming releases. Currently, the API is available in the
  5. https://github.com/IntelRealSense/librealsense/blob/master/third-party/libtm/libtm/include/TrackingDevice.h#L508-L515.
  6. -->
  7. <launch>
  8. <arg name="serial_no" default=""/>
  9. <arg name="usb_port_id" default=""/>
  10. <arg name="device_type" default="t265"/>
  11. <arg name="json_file_path" default=""/>
  12. <arg name="camera" default="camera"/>
  13. <arg name="tf_prefix" default="$(arg camera)"/>
  14. <arg name="fisheye_width" default="848"/>
  15. <arg name="fisheye_height" default="800"/>
  16. <arg name="enable_fisheye1" default="true"/>
  17. <arg name="enable_fisheye2" default="true"/>
  18. <arg name="fisheye_fps" default="30"/>
  19. <arg name="gyro_fps" default="200"/>
  20. <arg name="accel_fps" default="62"/>
  21. <arg name="enable_gyro" default="true"/>
  22. <arg name="enable_accel" default="true"/>
  23. <arg name="enable_pose" default="true"/>
  24. <arg name="enable_sync" default="false"/>
  25. <arg name="linear_accel_cov" default="0.01"/>
  26. <arg name="initial_reset" default="false"/>
  27. <arg name="unite_imu_method" default=""/>
  28. <arg name="publish_odom_tf" default="true"/>
  29. <group ns="$(arg camera)">
  30. <include file="$(find realsense2_camera)/launch/includes/nodelet.launch.xml">
  31. <arg name="tf_prefix" value="$(arg tf_prefix)"/>
  32. <arg name="serial_no" value="$(arg serial_no)"/>
  33. <arg name="usb_port_id" value="$(arg usb_port_id)"/>
  34. <arg name="device_type" value="$(arg device_type)"/>
  35. <arg name="json_file_path" value="$(arg json_file_path)"/>
  36. <arg name="enable_sync" value="$(arg enable_sync)"/>
  37. <arg name="fisheye_width" value="$(arg fisheye_width)"/>
  38. <arg name="fisheye_height" value="$(arg fisheye_height)"/>
  39. <arg name="enable_fisheye1" value="$(arg enable_fisheye1)"/>
  40. <arg name="enable_fisheye2" value="$(arg enable_fisheye2)"/>
  41. <arg name="fisheye_fps" value="$(arg fisheye_fps)"/>
  42. <arg name="gyro_fps" value="$(arg gyro_fps)"/>
  43. <arg name="accel_fps" value="$(arg accel_fps)"/>
  44. <arg name="enable_gyro" value="$(arg enable_gyro)"/>
  45. <arg name="enable_accel" value="$(arg enable_accel)"/>
  46. <arg name="enable_pose" value="$(arg enable_pose)"/>
  47. <arg name="linear_accel_cov" value="$(arg linear_accel_cov)"/>
  48. <arg name="initial_reset" value="$(arg initial_reset)"/>
  49. <arg name="unite_imu_method" value="$(arg unite_imu_method)"/>
  50. <arg name="publish_odom_tf" value="$(arg publish_odom_tf)"/>
  51. </include>
  52. </group>
  53. </launch>

启动指令如下:


  
  1. roscore

打开新的终端,启动T265C:


  
  1. # 注意在此之前必须在 rs_t265.launch中设定相机的参数,比如是否开启相机
  2. roslaunch realsense2_camera rs_t265.launch

3.2 修改Topic

打开相机节点实现通讯:


  
  1. # 注意在此之前必须在 rs_t265.launch中设定相机的参数,比如是否开启相机
  2. roslaunch realsense2_camera rs_t265.launch

查看相机镜头对应的话题信息:


  
  1. rostopic list

根据显示的信息修改ros_stereo.cc文件,比如本文中的数据修正为:


  
  1. message_filters::Subscriber<sensor_msgs::Image> left_sub(nh, "/camera/fisheye1/image_raw", 1);
  2. message_filters::Subscriber<sensor_msgs::Image> right_sub(nh, "/camera/fisheye2/image_raw", 1);

再次编译./build_ros.sh

3.3 再次编译功能包

随后执行:


  
  1. cd ~/catkin_ws
  2. catkin_make
  3. source devel/setup.bash

四、运行ORB-SLAM3

三个终端

  • 首先执行:
    
      
    1. roscore
  • 运行相机:

  
  1. roslaunch realsense2_camera rs_t265.launch
  • 运行SLAM:

  
  1. rosrun ORB_SLAM3 Stereo ~/catkin_ws/src/ORB_SLAM3/Vocabulary/ORBvoc.txt
  2. ~/catkin_ws/src/ORB_SLAM3/Examples/ROS/ORB_SLAM3/T265.yaml false

补充

根据大家的反馈,下面补充本文实验所用的T265.yaml文件,基本采用官方的改动较小:


  
  1. %YAML:1.0
  2. #--------------------------------------------------------------------------------------------
  3. # Camera Parameters. Adjust them!
  4. #--------------------------------------------------------------------------------------------
  5. Camera.type: "PinHole"
  6. # Camera calibration and distortion parameters (OpenCV)
  7. Camera.fx: 286.419189453125
  8. Camera.fy: 286.384307861328
  9. Camera.cx: 101.355010986328
  10. Camera.cy: 102.183197021484
  11. Camera.k1: 0.0
  12. Camera.k2: 0.0
  13. Camera.p1: 0.0
  14. Camera.p2: 0.0
  15. Camera.width: 848
  16. Camera.height: 800
  17. # Camera frames per second
  18. Camera.fps: 30.0
  19. # IR projector baseline times fx (aprox.)
  20. Camera.bf: 40.0
  21. # Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
  22. Camera.RGB: 1
  23. # Close/Far threshold. Baseline times.
  24. ThDepth: 40.0
  25. # Deptmap values factor
  26. DepthMapFactor: 1.0
  27. #--------------------------------------------------------------------------------------------
  28. # ORB Parameters
  29. #--------------------------------------------------------------------------------------------
  30. # ORB Extractor: Number of features per image
  31. ORBextractor.nFeatures: 1000
  32. # ORB Extractor: Scale factor between levels in the scale pyramid
  33. ORBextractor.scaleFactor: 1.2
  34. # ORB Extractor: Number of levels in the scale pyramid
  35. ORBextractor.nLevels: 8
  36. # ORB Extractor: Fast threshold
  37. # Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
  38. # Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
  39. # You can lower these values if your images have low contrast
  40. ORBextractor.iniThFAST: 20
  41. ORBextractor.minThFAST: 7
  42. #--------------------------------------------------------------------------------------------
  43. # Viewer Parameters
  44. #--------------------------------------------------------------------------------------------
  45. Viewer.KeyFrameSize: 0.05
  46. Viewer.KeyFrameLineWidth: 1
  47. Viewer.GraphLineWidth: 0.9
  48. Viewer.PointSize:2
  49. Viewer.CameraSize: 0.08
  50. Viewer.CameraLineWidth: 3
  51. Viewer.ViewpointX: 0
  52. Viewer.ViewpointY: -0.7
  53. Viewer.ViewpointZ: -1.8
  54. Viewer.ViewpointF: 500

GanAHE 的小创元世纪, 版权所有丨如未注明 , 均为原创丨本网站采用@BY-NC-SA协议进行授权
转载请注明原文链接:【无人机自主导航5 SLAM】Intel Realsense T265C双目相机实现ORB-SLAM3

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【无人机自主导航5 SLAM】Intel Realsense T265C双目相机实现ORB-SLAM3 的相关文章

随机推荐