一、安装librealsense
1、依赖库安装
sudo apt-get install libudev-dev pkg-config libgtk-3-dev
sudo apt-get install libusb-1.0-0-dev pkg-config
sudo apt-get install libglfw3-dev
sudo apt-get install libssl-dev
安装libgtk-3-dev的时候可能会报错
2、下载安装SDK
git clone https://github.com/jetsonhacks/installRealSenseSDK.git
在文件夹下运行 ./installLibrealsense.sh
出现无权限错误:运行 chmod 777 ./installLibrealsense.sh
在运行 ./installLibrealsense.sh,完成安装
连接相机,在终端运行 realsense-viewer
二、在Ubuntu18.04下安装Ros-melodic
参考连接:官网连接
ROS包:https://github.com/IntelRealSense/realsense-ros
Ros-melodic安装: http://wiki.ros.org/melodic/Installation/Ubuntu
1.1配置Ubuntu存储库
1.2设置sources.list
sudo sh -c'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc)main"> /etc/apt/sources.list.d/ros-latest.list'
1.3 set up your keys:添加密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
1.4 Installation更新
sudo apt update
1.5 桌面完整安装
a: Desktop-Full Install: (Recommended) : ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators and 2D/3D perception:
sudo apt install ros-melodic-desktop-full
若此时运行出错: Unmet dependencies. Try ‘apt --fix-broken install’ with no packages (or specify a solution).
sudo apt --fix-broken install
b: Desktop Install: ROS, rqt, rviz, and robot-generic libraries
sudo apt install ros-melodic-desktop
c: ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.
sudo apt install ros-melodic-ros-base
d: Individual Package: You can also install a specific ROS package (replace underscores with dashes of the package name):
sudo apt install ros-melodic-PACKAGE
e.g.
sudo apt install ros-melodic-slam-gmapping
1.6 Environment setup:环境变量
a: If you have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version you are currently using.
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
b: If you just want to change the environment of your current shell, instead of the above you can type:
source /opt/ros/melodic/setup.bash
c: If you use zsh instead of bash you need to run the following commands to set up your shell:
echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc
source ~/.zshrc
1.7 Dependencies for building packages:
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
1.8 Initialize rosdep:
sudo apt install python-rosdep
sudo rosdep init
rosdep update
运行出错sudo rosdep init
解决:
#打开hosts文件
sudo gedit /etc/hosts
#在文件末尾添加
151.101.84.133 raw.githubusercontent.com
1.9 测试
在终端运行
roscore
三、安装realsense-ros
realsenseV2.35.2 对应realsense-ros 2.2.14
官网:https://github.com/IntelRealSense/realsense-ros
下载安装:下载realsense相对应的realsense-ros版本,连接:https://github.com/IntelRealSense/realsense-ros/releases
git clone https://github.com/IntelRealSense/realsense-ros.git
git clone https://github.com/pal-robotics/ddynamic_reconfigure.git
a: Create a catkin workspace Ubuntu
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src/
b:
'catkin_ws/src/'
git clone https://github.com/IntelRealSense/realsense-ros.git
git clone https://github.com/pal-robotics/ddynamic_reconfigure.git
#
c:编译
cd ~/catkin_ws
catkin_make clean
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install
编译出错:catkin_ws/src/realsense-ros/realsense2_camera/src/base_realsense_node.cpp:363:14: error: ‘using element_type = class ddynamic_reconfigure::DDynamicReconfigure {aka class ddynamic_reconfigure::DDynamicReconfigure}’ has no member named ‘registerVariable’
ddynrec->registerVariable(
原因:IntelRealSense-Ros上缺少DDynamic_reconfigure(被intel删掉了),因此需要安装DDynamic_reconfigure
解决办法:
sudo apt-get install ros-kinetic-ddynamic_reconfigure
(没有效果)
下载源码ddynamic_reconfigure,将源码放到catkin_ws/src/下重新catkin_make
d:Ubuntu
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
e:启动相机节点
roslaunch realsense2_camera rs_camera.launch
f:查看节点
rostopic list
e: rviz查看結果
rviz
没有安装的话就安装一下
sudo apt-get install rviz
四、验证
b: 打开2个终端,输入
#终端1
roslaunch realsense2_camera rs_camera.launch
#终端2
rostopic list
rviz
此时并不能看到什么结果.
左上角 Displays 中 Fixed Frame 选项中,下拉菜单选择 camera_link
这是主要到Global Status变成了绿色
点击该框中的Add -> 上方点击 By topic -> /depth_registered 下的 /points 下的/PointCloud2
点击该框中的Add -> 上方点击 By topic -> /color 下的 /image_raw 下的image
1.http://wiki.ros.org/melodic/Installation/Ubuntu
2.https://github.com/IntelRealSense/realsense-ros
3.https://my.oschina.net/u/4412486/blog/4685555
4.https://github.com/jetsonhacks/installRealSenseSDK.git
5.git clone https://github.com/pal-robotics/ddynamic_reconfigure.git