当前位置:   article > 正文

Ubuntu18.04+ROS melodic +RealSense D435i的使用_d435 ros

d435 ros

一、RealSense D435i相机结构介绍

RealSense 是一款立体视觉深度相机,如下图所示,其集成了两个红外传感器(IR Stereo Camera)、一个红外激光发射器(IR Projector)和一个彩色相机(Color Camera)。立体深度相机系统主要包括两部分:视觉处理器D4和深度模块。主机处理器连接 USB 2.0 / USB 3.1 Gen 1。视觉处理器 D4 位于主处理器主板上,RGB颜色传感器数据通过主处理器主板和 D4 板上的彩色图像信号处理器(ISP)发送到视觉处理器D4。IntelRealSense D435i提供了完整的深度相机模块,集成了视觉处理器、立体深度模块、RGB 传感器以及彩色图像信号处理模块。深度模块采用立体视觉的左右成像器、可选的红外激光发射器和 RGB 色彩传感器。
图1

 图2

硬件参数信息
最高 1280×720 双目深度分辨率;
最高 1920×1080 RGB 分辨率;
最高 90 FPS 深度视频流。深度流与普通 RGB 视频流类似,只不过每个像素点的值不再是 RGB 或灰度值,而是物体相对于相机的距离;
更大的85度左右的镜头视场(FOV);
只能对相同帧率的 RGB 与深度视频流做同步设置;
双目 baseline 为 50 mm;
深度探测范围 0.2 m ~ 10 m ;
6DOF追踪功能(six degree of freedom);
深度坐标系以左侧相机为中心(上图中 centerline of 1/4-20 是指三脚架螺丝空的中心);
内含一个 6 自由度的 IMU,对应刚体在三维空间中 6 种运动方式:前后、左右、上下的平移,以及绕刚体三个轴的旋转 —— 绕前后方向轴旋转 roll, 绕左右方向轴旋转 pitch, 绕上下方向轴旋转 yaw;【亮点,该款相机具备IMU】

二、 InterRealSenseD435i SDK安装

博主使用的是命令行的安装

2.1 命令行的安装方式安装

1.注册服务器的公钥:
打开终端输入

sudo apt-key adv --keyserver keys.gnupg.net --recv-key C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C8B3A55A6F3EFCDE


2.将服务器添加到存储库列表中:


在终端里输入

sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u

3.安装库:

在终端里输入

  1. sudo apt-get install librealsense2-dkms
  2. sudo apt-get install librealsense2-utils

安装过程中遇到问题:

解决方法如图所示: 

4.安装开发者和调试包:

在终端里输入

  1. sudo apt-get install librealsense2-dev
  2. sudo apt-get install librealsense2-dbg

使用这两条命令的时候会非常的慢。可能是网络的问题

5.测试SDK2

把相机与电脑上的USB3.0口相连后(不是USB3.0口可能会出问题),打开终端输入

realsense-viewer

安装成功后的图像显示为: 

2.2 使用源码编译的方法 

手动下载地址:
github:https://github.com/IntelRealSense/librealsense

1. 下载source
 

  1. git clone https://github.com/IntelRealSense/librealsense
  2. cd librealsense


2. 安装依赖项

  1. sudo apt-get install libudev-dev pkg-config libgtk-3-dev
  2. sudo apt-get install libusb-1.0-0-dev pkg-config
  3. sudo apt-get install libglfw3-dev
  4. sudo apt-get install libssl-dev


3. 安装权限脚本

  1. sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
  2. sudo udevadm control --reload-rules && udevadm trigger 


4. 编译安装

  1. mkdir build
  2. cd build
  3. cmake ../ -DBUILD_EXAMPLES=true
  4. make
  5. sudo make install


5. 测试
进入librealsense/build/examples/capture,测试效果:

./rs-capture 

或直接使用realsense-viewer工具查看效果:

realsense-viewer

三、Realsense ROS 安装

3.1 源码编译安装

1,首先创建ROS的工作空间

  1. mkdir -p ~/catkin_ws/src
  2. cd ~/catkin_ws/src
  3. catkin_init_workspace

 这样就在src文件中创建了一个 CMakeLists.txt 的文件,目的是告诉系统,这个是ROS的工作空间。

2, 下载realsense-ros安装包和ddynamic_reconfigure包

  1. git clone https://github.com/IntelRealSense/realsense-ros.git
  2. git clone https://github.com/pal-robotics/ddynamic_reconfigure.git

   两个包都下载到 ~/catkin_ws/src 文件夹下

3,编译两个包

  1. cd ~/catkin_ws
  2. catkin_make clean
  3. catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
  4. catkin_make install
  5. echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
  6. 切记执行
  7. source ~/.bashrc

在执行到catkin_make的时候出现错误

error: ‘find_if’ was not declared in this scope
texture_frame_itr = find_if(frameset.begin(), frameset.end(), [&texture_source_id, &available_formats] (rs2::frame f)

解决方法:是源码的问题,更改错误cpp中的内容即可

 4.测试

1)测试 rs_camera.launch

终端执行

roslaunch realsense2_camera rs_camera.launch

执行该命令出现如下的错误的话

解决方法为:

正常执行后,可以使用ros话题查看

rostopic list

 会发现没有imu的话题。进行下面的处理进行更改

  1. //打开imu
  2. <arg name="enable_gyro" default="true"/>
  3. <arg name="enable_accel" default="true"/>
  4. //联合方式copy或linear_interpolation
  5. <arg name="unite_imu_method" default="linear_interpolation"/>
  6. //时间戳同步
  7. <arg name="enable_sync" default="true"/>

更改后执行命令

  1. roslaunch realsense2_camera rs_camera.launch
  2. rostopic list

展现的话题中出现imu相关的话题

  1. /camera/accel/imu_info
  2. /camera/accel/sample
  3. /camera/color/camera_info
  4. /camera/color/image_raw
  5. /camera/color/image_raw/compressed
  6. /camera/color/image_raw/compressed/parameter_descriptions
  7. /camera/color/image_raw/compressed/parameter_updates
  8. /camera/color/image_raw/compressedDepth
  9. /camera/color/image_raw/compressedDepth/parameter_descriptions
  10. /camera/color/image_raw/compressedDepth/parameter_updates
  11. /camera/color/image_raw/theora
  12. /camera/color/image_raw/theora/parameter_descriptions
  13. /camera/color/image_raw/theora/parameter_updates
  14. /camera/depth/camera_info
  15. /camera/depth/image_rect_raw
  16. /camera/depth/image_rect_raw/compressed
  17. /camera/depth/image_rect_raw/compressed/parameter_descriptions
  18. /camera/depth/image_rect_raw/compressed/parameter_updates
  19. /camera/depth/image_rect_raw/compressedDepth
  20. /camera/depth/image_rect_raw/compressedDepth/parameter_descriptions
  21. /camera/depth/image_rect_raw/compressedDepth/parameter_updates
  22. /camera/depth/image_rect_raw/theora
  23. /camera/depth/image_rect_raw/theora/parameter_descriptions
  24. /camera/depth/image_rect_raw/theora/parameter_updates
  25. /camera/extrinsics/depth_to_color
  26. /camera/extrinsics/depth_to_infra1
  27. /camera/extrinsics/depth_to_infra2
  28. /camera/infra1/camera_info
  29. /camera/infra1/image_rect_raw
  30. /camera/infra1/image_rect_raw/compressed
  31. /camera/infra1/image_rect_raw/compressed/parameter_descriptions
  32. /camera/infra1/image_rect_raw/compressed/parameter_updates
  33. /camera/infra1/image_rect_raw/compressedDepth
  34. /camera/infra1/image_rect_raw/compressedDepth/parameter_descriptions
  35. /camera/infra1/image_rect_raw/compressedDepth/parameter_updates
  36. /camera/infra1/image_rect_raw/theora
  37. /camera/infra1/image_rect_raw/theora/parameter_descriptions
  38. /camera/infra1/image_rect_raw/theora/parameter_updates
  39. /camera/infra2/camera_info
  40. /camera/infra2/image_rect_raw
  41. /camera/infra2/image_rect_raw/compressed
  42. /camera/infra2/image_rect_raw/compressed/parameter_descriptions
  43. /camera/infra2/image_rect_raw/compressed/parameter_updates
  44. /camera/infra2/image_rect_raw/compressedDepth
  45. /camera/infra2/image_rect_raw/compressedDepth/parameter_descriptions
  46. /camera/infra2/image_rect_raw/compressedDepth/parameter_updates
  47. /camera/infra2/image_rect_raw/theora
  48. /camera/infra2/image_rect_raw/theora/parameter_descriptions
  49. /camera/infra2/image_rect_raw/theora/parameter_updates
  50. /camera/motion_module/parameter_descriptions
  51. /camera/motion_module/parameter_updates
  52. /camera/realsense2_camera_manager/bond
  53. /camera/rgb_camera/auto_exposure_roi/parameter_descriptions
  54. /camera/rgb_camera/auto_exposure_roi/parameter_updates
  55. /camera/rgb_camera/parameter_descriptions
  56. /camera/rgb_camera/parameter_updates
  57. /camera/stereo_module/auto_exposure_roi/parameter_descriptions
  58. /camera/stereo_module/auto_exposure_roi/parameter_updates
  59. /camera/stereo_module/parameter_descriptions
  60. /camera/stereo_module/parameter_updates
  61. /diagnostics
  62. /rosout
  63. /rosout_agg
  64. /tf
  65. /tf_static

2)测试 rs_rgbd.launch

roslaunch realsense2_camera rs_rgbd.launch

sudo apt-get install ros-melodic-rgbd-launch

对应的话题有: 

  1. /camera/aligned_depth_to_color/camera_info
  2. /camera/aligned_depth_to_color/image_raw
  3. /camera/aligned_depth_to_color/image_raw/compressed
  4. /camera/aligned_depth_to_color/image_raw/compressed/parameter_descriptions
  5. /camera/aligned_depth_to_color/image_raw/compressed/parameter_updates
  6. /camera/aligned_depth_to_color/image_raw/compressedDepth
  7. /camera/aligned_depth_to_color/image_raw/compressedDepth/parameter_descriptions
  8. /camera/aligned_depth_to_color/image_raw/compressedDepth/parameter_updates
  9. /camera/aligned_depth_to_color/image_raw/theora
  10. /camera/aligned_depth_to_color/image_raw/theora/parameter_descriptions
  11. /camera/aligned_depth_to_color/image_raw/theora/parameter_updates
  12. /camera/color/camera_info
  13. /camera/color/image_raw
  14. /camera/color/image_raw/compressed
  15. /camera/color/image_raw/compressed/parameter_descriptions
  16. /camera/color/image_raw/compressed/parameter_updates
  17. /camera/color/image_raw/compressedDepth
  18. /camera/color/image_raw/compressedDepth/parameter_descriptions
  19. /camera/color/image_raw/compressedDepth/parameter_updates
  20. /camera/color/image_raw/theora
  21. /camera/color/image_raw/theora/parameter_descriptions
  22. /camera/color/image_raw/theora/parameter_updates
  23. /camera/color/image_rect_color
  24. /camera/color/image_rect_color/compressed
  25. /camera/color/image_rect_color/compressed/parameter_descriptions
  26. /camera/color/image_rect_color/compressed/parameter_updates
  27. /camera/color/image_rect_color/compressedDepth
  28. /camera/color/image_rect_color/compressedDepth/parameter_descriptions
  29. /camera/color/image_rect_color/compressedDepth/parameter_updates
  30. /camera/color/image_rect_color/theora
  31. /camera/color/image_rect_color/theora/parameter_descriptions
  32. /camera/color/image_rect_color/theora/parameter_updates
  33. /camera/color_rectify_color/parameter_descriptions
  34. /camera/color_rectify_color/parameter_updates
  35. /camera/depth/camera_info
  36. /camera/depth/image_rect_raw
  37. /camera/depth/image_rect_raw/compressed
  38. /camera/depth/image_rect_raw/compressed/parameter_descriptions
  39. /camera/depth/image_rect_raw/compressed/parameter_updates
  40. /camera/depth/image_rect_raw/compressedDepth
  41. /camera/depth/image_rect_raw/compressedDepth/parameter_descriptions
  42. /camera/depth/image_rect_raw/compressedDepth/parameter_updates
  43. /camera/depth/image_rect_raw/theora
  44. /camera/depth/image_rect_raw/theora/parameter_descriptions
  45. /camera/depth/image_rect_raw/theora/parameter_updates
  46. /camera/depth_registered/points
  47. /camera/extrinsics/depth_to_color
  48. /camera/motion_module/parameter_descriptions
  49. /camera/motion_module/parameter_updates
  50. /camera/realsense2_camera_manager/bond
  51. /camera/rgb_camera/auto_exposure_roi/parameter_descriptions
  52. /camera/rgb_camera/auto_exposure_roi/parameter_updates
  53. /camera/rgb_camera/parameter_descriptions
  54. /camera/rgb_camera/parameter_updates
  55. /camera/stereo_module/auto_exposure_roi/parameter_descriptions
  56. /camera/stereo_module/auto_exposure_roi/parameter_updates
  57. /camera/stereo_module/parameter_descriptions
  58. /camera/stereo_module/parameter_updates
  59. /diagnostics
  60. /rosout
  61. /rosout_agg
  62. /tf
  63. /tf_static

3.2 命令安装

1.前提是先安装好realsense SDK
也就是终端输入:
realsense-viewer
可以打开相机的图像。


2.安装RGBD包:

sudo apt-get install ros-melodic-rgbd-launch

3.之后输入apt search melodic-realsense2

在这里插入图片描述

然后将找到的3个库都安装了就好了

  1. sudo aptitude install ros-melodic-realsense2-camera
  2. sudo aptitude install ros-melodic-realsense2-description
  3. sudo aptitude install ros-melodic-realsense2-camera-dbgsym

 在这里插入图片描述

全部安装后,在终端打开相机并查看图像: 

  1. roslaunch realsense2_camera rs_camera.launch
  2. rosrun rqt_image_view rqt_image_view

在这里插入图片描述

卸载realsense-ros命令使用:sudo apt-get remove ros-melodic-librealsense2
 

四、相机内参查看

  1. roslaunch realsense2_camera rs_camera.launch
  2. rostopic echo /camera/color/camera_info

注意内参的查看需要使用为更换的launch文件 

但是更换了的launch文件是可以获取imu的数据的

 使用rviz查看的方法为随着相机的移动,粉色的箭头也会进行移动:

下面的博文数可以一次性成功,但是博主由于网的原因,没有办法执行,有条件的可以尝试:

下面的博文指定的版本为:SDK 2.48.0   ros 2.3.1  

[解决方法]realsence D455 在jetson nano 无法正常读取imu数据(/camera/imu、/camera/accel/sample)_fikimi的博客-CSDN博客

1)SDK的安装

  1. # Uninstall all realsense packages
  2. sudo apt remove librealsense2 ros-melodic-realsense2-camera librealsense2-udev-rules ros-melodic-librealsense2 librealsense2-dev
  3. # Reinstall librealsense2 at version 2.48.0 and place those packages on hold (to prevent
  4. # automatic upgrades)
  5. sudo apt install \
  6. librealsense2=2.48.0-5ubuntu5~1.gbp156c1b \
  7. librealsense2-udev-rules=2.48.0-5ubuntu5~1.gbp156c1b \
  8. librealsense2-utils=2.48.0-5ubuntu5~1.gbp156c1b \
  9. librealsense2-gl=2.48.0-5ubuntu5~1.gbp156c1b \
  10. librealsense2-net=2.48.0-5ubuntu5~1.gbp156c1b \
  11. librealsense2-dev=2.48.0-5ubuntu5~1.gbp156c1b
  12. sudo apt-mark hold \
  13. librealsense2 \
  14. librealsense2-udev-rules \
  15. librealsense2-utils \
  16. librealsense2-gl \
  17. librealsense2-net \
  18. librealsense2-dev
  19. # To remove the hold on the package versions, just run `sudo apt-mark unhold <package name>`

 2)ROS的安装

  1. mkdir -p ~/catkin_ws/src
  2. cd ~/catkin_ws/src/
  3. git clone https://github.com/IntelRealSense/realsense-ros.git
  4. cd realsense-ros/
  5. git checkout 2.3.1
  6. cd ..
  7. catkin_init_workspace
  8. cd ..
  9. catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
  10. catkin_make install
  11. echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
  12. source ~/.bashrc

五、数据的记录与播放

5.1 录制自己需要的数据

下面的例程是录制了两个话题包

 5.2 找到存放的位置并播放

在Linux 的主目录下,按ctrl+h。可以将影藏的文件夹显现出来,找到上面的bag文件

 

如果想将对应的数据保存为txt使用以下的命令 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/59717
推荐阅读
相关标签
  

闽ICP备14008679号