ROS系统——ROS、realsense-ros的安装配置流程

1 系统要求

  • Ubuntu 18.04
  • Linux内核版本不超过5.4

2 ROS安装方法(melodic版)

1、添加ROS软件源(TX2使用自带源即可,该步可省去)

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

2、添加公钥

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

3、更新

确保包索引是最新的:

sudo apt update

检查cmake的版本,尽量升级到最新版本:https://blog.csdn.net/RNG_uzi_/article/details/107016899

4、安装ros

这里介绍桌面完整版(推荐): 包含 ROS、rqt、rviz、机器人通用库、2D/3D 模拟器、导航以及 2D/3D 感知包, 其他参考官方网站。

sudo apt install ros-melodic-desktop-full

5、初始化 rosdep

sudo rosdep init

rosdep update

备注:上述两条命名可能报错:

sudo rosdep init错误

ERROR:cannot download default sources list from:

https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list

Website may be down

解决办法1

  1. 打开hosts文件
  2. sudo gedit /etc/hosts
  3. #在文件末尾添加
  4. 151.101.84.133 raw.githubusercontent.com
  5. #保存后退出再尝试

备注:raw.githubusercontent.com的其他IP访问地址,可以通过http://tool.chinaz.com/dns网站查询,选择ping最小值那个IP地址。

解决办法2

  1. sudo c_rehash /etc/ssl/certs
  2. sudo -E rosdep init
  3. rosdep update

如果还是提示错误,请将源更更换为清华源,然后sudo apt update
(请将网络换成手机热点)

rosdep update出错

reading in sources list data from /etc/ros/rosdep/sources.list.d

ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:

(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)

Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml

ERROR: error loading sources list:

The read operation timed out

运行:(网络换成手机热点,如果是time out,那就多尝试几次)

  1. sudo apt-get update
  2. sudo apt-get install python-rosdep

6、设置环境

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

source ~/.bashrc

7、安装rosinstall,便利的工具

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

使用下面命令安装ROS插件(包括3D包围框)

sudo apt install ros-melodic-jsk-rviz-plugins

8、检验安装

打开终端,输入roscore命令,可以看到ROS已经成功在ubuntu上运行起来。

卸载melodic的方法

sudo apt-get remove ros-melodic-*

ROS安装主要参考:https://www.guyuehome.com/10082

其他可能遇到的问题及其解决方案:

  • 18.04 安装ros 出现 ERROR: cannot download default sources list from: https://raw.githubusercontent.com/......:https://blog.csdn.net/qq_35822136/article/details/106320587

  • Ubuntu18.04 ROS填坑之 roscore Command ‘roscore‘ not found:     https://blog.csdn.net/jdx130/article/details/107647324

  • Resource not found: rgbd_launch 解决方案:https://blog.csdn.net/Hacker_MAI/article/details/108009916

3 realsense-ros安装

安装方法参照官网:https://github.com/IntelRealSense/realsense-ros  中方法1(使用apt-get直接安装)

3. 1 apt install 安装方式

#18.04 直接安装

$export ROS_VER=melodic 

#16.04

$export ROS_VER=kinetic 
安装realsense2-camera
$sudo apt-get install ros-$ROS_VER-realsense2-camera

(This will install both realsense2_camera and its dependents, including librealsense2 library.)

  • The version of librealsense2 is almost always behind the one availeable in RealSense™ official repository.
  • librealsense2 is not built to use native v4l2 driver but the less stable RS-USB protocol. That is because the last is more general and operational on a larger variety of platforms.
  • realsense2_description is available as a separate debian package of ROS distribution. It includes the 3D-models of the devices and is necessary for running launch files that include these models (i.e. rs_d435_camera_with_model.launch). It can be installed by typing: sudo apt-get install ros-$ROS_VER-realsense2-description

3. 2 源码下载的安装方式

3.2.1 需要先安装 SDK

https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md#installing-the-packages

3.2.2 源码下载

$mkdir -p ~/catkin_ws/src

$cd ~/catkin_ws/src/

$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 ..

$catkin_init_workspace

$cd ..

$catkin_make clean

$catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release

$catkin_make install

3.3 测试:

  1.     将realsense相机插入主机
  2.     新建终端,并执行:roslaunch realsense2_camera rs_camera.launch
  3.     再新建一个终端,并执行:rviz
  4.     在弹出的rviz软件中,左下角有个‘Add’,然后在弹框中选择‘By topic’,如果能看到camera数据源,表示成功安装。

你可能感兴趣的:(ROS机器人&自动驾驶)