参考:
- https://blog.csdn.net/qq_43265072/article/details/106437287
- https://blog.csdn.net/zhangfenger/article/details/84998082
- https://blog.csdn.net/sinat_23853639/article/details/88044019?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param
以下步骤基本是官方教程的翻译,更多细节请移步官方教程。
uname -r
查看内核版本以下采用source code方式进行安装
(!!!注意:驱动安装过程中不要连接相机!!!)
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
git clone https://github.com/IntelRealSense/librealsense.git
sudo apt-get install git libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev
sudo apt-get install libglfw3-dev
./scripts/setup_udev_rules.sh
./scripts/patch-realsense-ubuntu-lts.sh
这里可能会遇到一些问题:
(1)g++需要升级,按照提示依次运行以下命令即可:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update -y
sudo apt-get install g++-7 -y
(2)Applying the patched module … modprobe: ERROR: could not insert ‘videodev’: Required key not available
Failed to insert the patched module. Operation is aborted, the original module is restored
Verify that the current kernel version is aligned to the patched module version
出现此问题的原因是,Ubuntu Kernel 使用 EFI_SECURE_BOOT_SIG_ENFORCE 内核配置,这样会阻止内核载入第三方模块。解决方法如下:
sudo apt install mokutil
sudo mokutil --disable-validation
- Continue boot
- Change Secure Boot state
- Enroll key from disk
- Enroll hash from disk
./scripts/patch-realsense-ubuntu-lts.sh
,成功。echo 'hid_sensor_custom' | sudo tee -a /etc/modules
cd librealsense
mkdir build && cd build
cmake ..
# The default build is set to produce the core shared object and unit-tests binaries in Debug mode. Use -DCMAKE_BUILD_TYPE=Release to build with optimizations.
下面两个步骤可酌情跳过:
cmake ../ -DBUILD_EXAMPLES=true # - Builds librealsense along with the demos and tutorials
cmake ../ -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=false # - For systems without OpenGL or X11 build only textual examples
sudo make uninstall && make clean && make && sudo make install
说明:The shared object will be installed in /usr/local/lib, header files in /usr/local/include.
The binary demos, tutorials and test files will be copied into /usr/local/bin.
连接相机,新开一个终端,输入:realsense-viewer
启动即可:
看到类似画面就说明OK啦!
官方提供的RealSense ROS包安装有两种方式,这里先介绍第一种方式。
sudo apt-get install ros-kinetic-realsense2-camera
sudo apt-get install ros-kinetic-realsense2-description
It includes the 3D-models of the devices and is necessary for running launch files that include these models (i.e. roslaunch realsense2_camera rs_d435_camera_with_model.launch
)
roslaunch realsense2_camera rs_camera.launch