文章目录
- 基础安装
- 1. 安装ROS
- 2. 安装Realsense驱动以及依赖库
- (1)X86安装librealsense
- 更新
- (2)Arm编译安装librealsense(或者Apt无法下载的)
- 编译realsense
- 配置环境变量
- 3. ROS+Realsense环境安装
- (1)apt安装
- (2)下载本地编译Realsense ros包
- Demo
- 环境配置
- 运行
- 报错解决
- 卸载方法
基础安装
1. 安装ROS
2. 安装Realsense驱动以及依赖库
(1)X86安装librealsense
x86系统可以直接下载,不用编译。
更新
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install -y --no-install-recommends python3-setuptools python3-pip python3-dev
sudo apt-get install -y libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev
sudo apt-get install -y libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
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
python:
pip install pyrealsense2
(2)Arm编译安装librealsense(或者Apt无法下载的)
编译realsense
sudo apt install -y cmake git
sudo apt-get install -y libusb-1.0-0-dev pkg-config
sudo apt-get install -y libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev
sudo apt-get install openssl libssl-dev
# 如果apt下载失败,使用:
# sudo aptitude install libssl-dev
cd ~/librealsense
mkdir build
cd build
rm -rf *
# 这里可以自行指定自己的python解释器路径,如果你用conda,可以修改为conda对应的路径。
cmake ../ -DFORCE_RSUSB_BACKEND=ON -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_EXECUTABLE=/usr/bin/python3
##########################
make -j6
##########################
sudo make install
- librealsense编译报错:The RandR headers were not found等类似报错解决方案汇总
配置环境变量
将pyrealsense写入~/.bashrc中:
sudo vim ~/.bashrc
写入以下内容:
export PYTHONPATH=$PYTHONPATH:/usr/local/lib:/usr/local/lib/python3.6/pyrealsense2
- 需要注意的是:如果你在之后的环境中需要使用Conda,需要指定新的环境重新编译。
3. ROS+Realsense环境安装
有两种方式均可:
(1)apt安装
sudo apt-get install ros-melodic-realsense2-camera
sudo apt-get install ros-$ROS_DISTRO-realsense2-description
(2)下载本地编译Realsense ros包
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src/
在拉取源码之前首先需要确定自己realsense的版本:
我这里是2.38.1,如果拉去默认的源码,那么它的要求是:
- 如果你的符合要求,则正常编译下载:
git clone https://github.com/IntelRealSense/realsense-ros.git
cd realsense-ros/
git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1`
cd ..
- 如果源码版本大于你的realsense版本,你需要在IntelRealSense/realsense-ros找到与你的realsense固件版本一致的realsense-ros包,我这里例如v2.38.1,则下载对应版本的tar.gz压缩包,下载后解压并将其重命名为
realsense-ros
:
catkin_init_workspace
cd ..
catkin_make clean
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install
- 编译报错:
-
ModuleNotFoundError: No module named 'em'
- 解决方法:
pip install rosdep rosinstall_generator wstool rosinstall six vcstools
pip install empy
- 编译报错:
- 解决方法:找到报错位置代码,在前边加上
std::
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
roslaunch realsense2_camera rs_camera.launch
Demo
参考文章:
- Jetson TX2在ROS下使用Realsense D435i跑rtabmap、octomap、VINS-Mono和ORB-SLAM2
环境配置
sudo apt-get install -y ros-melodic-imu-filter-madgwick
sudo apt-get install -y ros-melodic-rtabmap-ros
sudo apt-get install -y ros-melodic-robot-localization
安装octomap-ros:
sudo apt-get install -y ros-melodic-octomap*
运行
roslaunch realsense2_camera opensource_tracking.launch
roslaunch realsense2_camera rs_camera.launch filters:=pointcloud
- Aligned Depth Frames
roslaunch realsense2_camera rs_camera.launch align_depth:=true
报错解决
- 下面的报错参考解决方法:ORB-SLAM3运行过程记录
卸载方法
移除所有 RealSense™ SDK相关的package:
dpkg -l | grep "realsense" | cut -d " " -f 3 | xargs sudo dpkg --purge
如果是编译安装的:
cd librealsense/build
sudo make uninstall && make clean
参考文章:
- IntelRealSense/realsense-ros
- Ubuntu16.04安装LibRealSense