【精华】ROS学习(二):Realsense ROS驱动安装

文章目录

        • Realsense ROS驱动安装
          • 1 系统环境及安装准备
          • 2 安装Realsense SDK
          • 3 安装Realsense ROS
          • 4 异常问题
            • (1) 异常问题1
            • (2) 异常问题2

Realsense ROS驱动安装

1 系统环境及安装准备
  • 系统:Ubuntu18.04
  • ROS:Melodic
  • 视觉传感器:Intel RealSense D435i

需要安装两个文件:

  • librealsense(官方sdk)
  • librealsense-ros(基于sdk打包成ros的包)
2 安装Realsense SDK
# 下载安装包
git clone https://github.com/IntelRealSense/librealsense.git
cd librealsense

# 更新依赖库
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade

# 安装依赖库
sudo apt-get install libudev-dev pkg-config libgtk-3-dev
sudo apt-get install libusb-1.0-0-dev pkg-config
sudo apt-get install libglfw3-dev
sudo apt-get install libssl-dev

# 运行Intel Realsense许可脚本
./scripts/setup_udev_rules.sh

# 下载并编译内核模块
./scripts/patch-realsense-ubuntu-lts.sh

# 编译SDK2.0
cd librealsense
mkdir build
cd build
cmake ../ -DBUILD_EXAMPLES=true
make
sudo make install

# 测试
cd examples/capture
./rs-capture

# 打开realsense-viewer
realsense-viewer
3 安装Realsense ROS
# 建立workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src/
catkin_init_workspace 
cd ..
catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

# 在catkin_ws/src/下载源程序
cd src
git clone https://github.com/IntelRealSense/realsense-ros.git
git clone https://github.com/pal-robotics/ddynamic_reconfigure.git

# catkin_make编译
cd ~/catkin_ws && catkin_make

# 测试
roslaunch realsense2_camera demo_pointcloud.launch

# 其他测试
## 查看发布的topic
rostopic list

## 查看相机内参
# 方法一
rostopic echo /camera/color/camera_info 
rostopic echo /camera/aligned_depth_to_color/camera_info
注:aligned_depth_to_color是指已经将深度信息通过相机到RGBD的外参映射到彩色图像上
# 方法二
rs-sensor-control
4 异常问题
(1) 异常问题1

【精华】ROS学习(二):Realsense ROS驱动安装_第1张图片

问题描述

Resource not found: rgbd_launch
ROS path [0]=/opt/ros/melodic/share/ros
ROS path [1]=/home/gipsy/catkin_ws/src
ROS path [2]=/opt/ros/melodic/share
The traceback for the exception was written to the log file

报错原因

进行该launch命令时,找不到rgbd_launch相关的功能包依赖。

解决方案

# 安装依赖
sudo apt-get install ros-melodic-rgbd-launch
(2) 异常问题2

【精华】ROS学习(二):Realsense ROS驱动安装_第2张图片

问题描述

/opt/ros/melodic/lib/nodelet/nodelet: symbol lookup error: /home/d/catkin_ws/devel/lib//librealsense2_camera.so: undefined symbol: _ZN2cv3MatC1EiiiRKNS_7Scalar_IdEE
[camera/realsense2_camera_manager-2] process has died [pid 32532, exit code 127, cmd /opt/ros/melodic/lib/nodelet/nodelet manager __name:=realsense2_camera_manager __log:=/home/d/.ros/log/c8668552-b555-11ec-bd7d-38f3abe767d2/camera-realsense2_camera_manager-2.log].
log file: /home/d/.ros/log/c8668552-b555-11ec-bd7d-38f3abe767d2/camera-realsense2_camera_manager-2*.log

报错原因

找不到功能包依赖

解决方案

(1)方案一

# 在CMakeLists.txt中添加依赖
vim ~/catkin_ws/src/realsense-ros/realsense2_camera/CMakeLists.txt

在CmakeLists.txt文件中添加 ${OpenCV_LIBS}

${OpenCV_LIBS}

【精华】ROS学习(二):Realsense ROS驱动安装_第3张图片

(2)方案二

# 安装依赖包
sudo apt-get install ros-melodic-realsense2-camera

你可能感兴趣的:(ROS,ubuntu,自动驾驶,linux)