背景
硬件设备:Jetson Nano B01 ,SanDisk Ultra 128G, Intel® RealSense™D405
1. 安装Intel RealSense SDK 2.0
在终端中输入以下命令以下载 Intel RealSense SDK 2.0 的公共 GPG 密钥:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C8B3A55A6F3EFCDE
运行添加软件源的命令:
sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo bionic main"
上面的命令经常因为网络原因出错,建议的网络设置如下(翻墙反而不好用,不知道为啥):
更新软件包列表:
sudo apt-get update
尝试安装 librealsense2-dev
包:
sudo apt-get install librealsense2-dev
2. 安装realsense-ros
创建工作空间站,
mkdir -p ~/fairlee_ws/src
cd ~/fairlee_ws/src/
然后下载realsense-ros安装
git clone https://github.com/IntelRealSense/realsense-ros.git
上面的realsense-ros因为网络的原因一般是直接下载不下来的,给出网盘下载连接:
百度网盘下载连接
链接:https://pan.baidu.com/s/15yeYxVXSm6Zjquypx1sNzA
提取码:vp1z
--来自百度网盘超级会员V4的分享
天翼网盘下载连接
https://cloud.189.cn/t/V7nQjabe6Zru (访问码:6zss)
cd realsense-ros/
git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1`
出现下面的显示就说明成功了
然后,更改下面路径下的文件
realsense-ros/realsense2 camera/include/realsense2_camera/include/constants.h文件中的
const uint16_t RS405_PID = 0x0B5B; // DS5U
cd ~/fairlee_ws/src/
catkin_init_workspace
cd ..
catkin_make clean
会因为OpenCV 头文件的问题报错(jetson-nano-jp441-sd-card-image 自带opencv4.1.1)
解决方案如下:
打开 /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake
sudo gedit /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake
cv_bridgeConfig.cmake
文件中的以下行:
if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
set(cv_bridge_INCLUDE_DIRS "")
set(_include_dirs "include;/usr/include;/usr/include/opencv")
替换为:
if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
set(cv_bridge_INCLUDE_DIRS "")
set(_include_dirs "include;/usr/include;/usr/include/opencv4")
然后重新运行 catkin_make
。这应该可以解决找不到 OpenCV 的头文件的问题。
catkin_make
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
进行catkin_make编译时卡住,大概可以确定不是程序的问题,而是电脑算力的问题。
解决方法,在catkin_make后加-j2或者-j1,减少并行的线程。
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release -j1
或者在bashrc文件中直接改为-j2或者-j1
export ROS_PARALLEL_JOBS=-j1
waitting for a long time.......
安装
catkin_make install
3. 启动相机
source devel/setup.bash
roslaunch realsense2_camera rs_camera.launch