目录
前言
安装要求
一、安装使用 InterRealSenseD435i SDK2
1.注册服务器的公钥:
2.将服务器添加到存储库列表中:
3.安装库:
4.安装开发者和调试包:
5.测试SDK2
二、安装RealSense-ROS
1.创建ROS工作空间
2.下载realsense-ros安装包和ddynamic_reconfigure包放在src文件夹下,采用源码下载
3.编译
4.测试
三、查看相机内参
本文写于2022年4月7日,在经历了两天的配置环境,心里从最初拿到相机的高兴,逐渐烦躁,碰到种种问题,再到最后终于解决了种种问题后,决定写博客记录下来,话不多说,开始吧。
1.Ubuntu版本为18.04
2.安装了ROS melodic
本人ubuntu小白一枚,不知道在安装 RealSense-ROS 之前要安装 Ubuntu18.04 对应的ROS melodic,在没装ROS之前安装 RealSense-ROS 总会出现一个报错
-- Could not find the required component 'ddynamic_reconfigure'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by
"ddynamic_reconfigure" with any of the following names:
ddynamic_reconfigureConfig.cmake
ddynamic_reconfigure-config.cmake
Add the installation prefix of "ddynamic_reconfigure" to CMAKE_PREFIX_PATH
or set "ddynamic_reconfigure_DIR" to a directory containing one of the
above files. If "ddynamic_reconfigure" provides a separate development
package or SDK, be sure it has been installed.
Call Stack (most recent call first):
realsense/realsense2_camera/CMakeLists.txt:8 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/bruce/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/bruce/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:1536: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed
我是已经下载了ddynamic_reconfigure的package,放在了指定文件夹下,依然会报上述错误,此时我意识到了,我没有安装ROS,开始安装ROS,安装ROS的详细步骤请看我的这篇博客Ubuntu18.04安装Ros Melodic,接下来,开始安装。
在这里我是采用命令行的安装方式安装,参考官方安装教程
打开终端输入
sudo apt-key adv --keyserver keys.gnupg.net --recv-key C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C8B3A55A6F3EFCDE
在终端里输入
sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
在终端里输入
sudo apt-get install librealsense2-dkms
sudo apt-get install librealsense2-utils
在终端里输入
sudo apt-get install librealsense2-dev
sudo apt-get install librealsense2-dbg
把相机与电脑上的USB3.0口相连后(不是USB3.0口可能会出问题),打开终端输入
realsense-viewer
左侧三个开关从上到下依次是深度,RGB以及IMU,都能打开后出现以上图片,说明SDK2安装成功了。(之前安装过一次,第三个IMU按钮打不开,然后重新安装了一遍,IMU就可以打开了)
参考官方教程
参考此篇博客
1.创建catkin_ws
1)创建src文件夹,放置功能包源码
打开终端输入
mkdir -p ~/catkin_ws/src
如果之前已经创建好了此文件夹,可以从以下步骤开始
2)进入src文件夹
打开终端输入
cd ~/catkin_ws/src
3)初始化文件夹
在终端里输入
catkin_init_workspace
这样就在src文件中创建了一个 CMakeLists.txt 的文件,目的是告诉系统,这个是ROS的工作空间。
两个包都下载到 ~/catkin_ws/src 文件夹下
1下载realsense-ros安装包
在终端里输入
git clone https://github.com/IntelRealSense/realsense-ros.git
2下载ddynamic_reconfigure包
在终端里输入
git clone https://github.com/pal-robotics/ddynamic_reconfigure.git
如果缺少ddynamic_reconfigure包,将会在编译阶段报以下错误
-- Could not find the required component 'ddynamic_reconfigure'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by
"ddynamic_reconfigure" with any of the following names:
ddynamic_reconfigureConfig.cmake
ddynamic_reconfigure-config.cmake
Add the installation prefix of "ddynamic_reconfigure" to CMAKE_PREFIX_PATH
or set "ddynamic_reconfigure_DIR" to a directory containing one of the
above files. If "ddynamic_reconfigure" provides a separate development
package or SDK, be sure it has been installed.
Call Stack (most recent call first):
realsense/realsense2_camera/CMakeLists.txt:8 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/bruce/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/bruce/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:1536: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed
所有编译工作都要在 ~/catkin_ws 文件夹下编译
在终端里输入
cd ~/catkin_ws
catkin_make clean
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
注:把我们工作空间的环境变量设置到bash中
source ~/.bashrc
注:让上面的配置在当前的终端生效
1.测试相机发布的话题
运行相机节点,打开终端输入
roslaunch realsense2_camera rs_camera.launch
报出错误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
再次运行相机节点,打开终端输入
roslaunch realsense2_camera rs_camera.launch
报出错误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 参考博客2
解决办法
(我在执行以下步骤之前曾安装了一个依赖项 sudo apt-get install ros-melodic-realsense2-camera ,但是并没有解决掉此问题,强烈建议先不要安装,下述步骤执行完了没用再安装这个依赖项试试)
1)在你的 realsense-ros的功能包文件夹下 realsense2_camera 文件夹下的 CmakeLists.txt文件中添加一些内容
打开终端输入
cd ~/catkin_ws/src/realsense-ros/realsense2_camera
打开CmakeLists.txt文件,在终端输入
gedit CMakeLists.txt
首先输入
locate OpenCVConfig.cmake
然后在CmakeLists.txt文件中添加如下两处,1处的路径改成上面搜到的
set(OpenCV_DIR /usr/local/share/OpenCV/)
OpenCV REQUIRED
还要在CmakeLists.txt文件中添加 ${OpenCV_LIBS}
${OpenCV_LIBS}
按照 二、安装RealSense-ROS -> 3.编译 重新编译RealSense-ROS
2)运行相机节点,打开终端输入
roslaunch realsense2_camera rs_camera.launch
不报错了
再打开一个终端输入
rostopic list
可以查看当前发布的话题
2.在rviz中测试相机
运行相机节点,打开终端输入
roslaunch realsense2_camera rs_camera.launch
再打开一个终端输入
rviz
在rviz界面中选择 Fixed Frame -> camera_link
之后点击左下角 Add 按钮,双击 Camera , Camera 出现在了左侧列表,点击下拉按钮,选择Image Topic -> /camera/color/image_raw ,左下角的相机有画面了。
若是相机依然没有画面,安装一个依赖项试试,我在解决掉错误2之前安装了这个
sudo apt-get install ros-melodic-realsense2-camera
至此,InterRealSenseD435i SDK2和RealSense-ROS安装测试完毕。
1.运行相机节点
打开终端输入
roslaunch realsense2_camera rs_camera.launch
2.查看相机内参
再打开一个终端输入
rostopic echo /camera/color/camera_info
相机内参查看完成