Realsense-Ros安装配置介绍与问题解决
本文主要讲述在如何进行Realsense-Ros的安装与配置,以及提出在安装配置过程中遇到相关问题的解决方案。
Realsense-Ros安装配置
Realsense-Ros的配置主要涉及两个功能包,realsense-ros以及ddynamic_reconfigure
https://github.com/IntelRealSense/realsense-ros.git
https://github.com/pal-robotics/ddynamic_reconfigure.git
功能包克隆与编译
如果你已经新建了ROS工作空间,或者已经建好了ROS工作空间,则可以直接在工作空间的src目录下克隆相关功能包,然后进行编译,具体命令参考下方:
#已建好工作空间
cd catkin_ws/src/
git clone https://github.com/IntelRealSense/realsense-ros.git
git clone https://github.com/pal-robotics/ddynamic_reconfigure.git
cd ~/catkin_ws && catkin_make
#未建立工作空间
mkdir -p ~/catkin_ws/src
catkin_init_workspace
cd ..
catkin_make
cd src/
git clone https://github.com/IntelRealSense/realsense-ros.git
git clone https://github.com/pal-robotics/ddynamic_reconfigure.git
cd ~/catkin_ws && catkin_make
编译错误与问题分析
在执行上述功能包克隆与编译的最后一部catkin_make时,你可能得到如下图所示的终端错误提示:
阅读终端反馈的错误提示我们可以看到其提及在克隆的realsense_ros功能包目录下realsense2_camera的CMakelist.txt文件中出现了错误,该文件的第43行需要寻找realsense2的功能包,且要求realsense2的版本号为2.37.0,但在安装realsense的相机驱动时,相机驱动的版本为2.36.0,故在编译时,无法找到2.37.0版本导致错误发生。
#catkin_ws/realsense-ros/realsense2_camera/CMakelist.txt
cmake_minimum_required(VERSION 2.8.3)
project(realsense2_camera)
add_compile_options(-std=c++11)
option(BUILD_WITH_OPENMP "Use OpenMP" OFF)
option(SET_USER_BREAK_AT_STARTUP "Set user wait point in startup (for debug)" OFF)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
find_package(catkin REQUIRED COMPONENTS
message_generation
nav_msgs
roscpp
sensor_msgs
std_msgs
nodelet
cv_bridge
image_transport
tf
ddynamic_reconfigure
diagnostic_updater
)
if(BUILD_WITH_OPENMP)
find_package(OpenMP)
if(NOT OpenMP_FOUND)
message(FATAL_ERROR "\n\n OpenMP is missing!\n\n")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -fopenmp")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
endif()
if(SET_USER_BREAK_AT_STARTUP)
message("GOT FLAG IN CmakeLists.txt")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBPDEBUG")
endif()
if (WIN32)
find_package(realsense2 CONFIG REQUIRED)
else()
find_package(realsense2 2.37.0)
endif()
if(NOT realsense2_FOUND)
message(FATAL_ERROR "\n\n Intel RealSense SDK 2.0 is missing, please install it from https://github.com/IntelRealSense/librealsense/releases\n\n")
endif()
解决方案
针对终端反馈的错误信息修改realsense-ros/realsense2_camera/CMakeLists.txt:43,参考下面给出的实例对其进行修改,主要更改版本号为2.36.0。
if (WIN32)
find_package(realsense2 CONFIG REQUIRED)
else()
find_package(realsense2 2.36.0) #修改为2.36.0
endif()
结束语
本文主要讲述了笔者在安装玩Realsense D435i驱动后,安装Realsense的ROS支持功能包的介绍以及给出遇到问题的解决方案,希望本文能够对你解决你遇到的问题起到一定的帮助。