Ubuntu ROS2.0安装使用教程

一、二进制安装

安装依赖

  1. Install runtime dependencies and wget:
sudo apt-get update && sudo apt-get install -q -y \
     libopencv-core2.4v5 \
     libhighgui2.4 \
     libopencv-imgproc2.4v5 \
     libasio-dev \
     libeigen3-dev \
     libtinyxml-dev \
     libtinyxml2-dev \
     libcurl4-openssl-dev \
     libqt5core5a \
     libqt5gui5 \
     libqt5opengl5 \
     libqt5widgets5 \
     libxaw7-dev \
     libgles2-mesa-dev \
     libglu1-mesa-dev \
     python3-pip \
     python3-setuptools \
     python3-yaml \
     wget
  1. Install argcomplete from pip for argument completion. Note that the version available through apt-get in Ubuntu 16.04 (Xenial) will not work due to a bug in argcomplete:

    sudo pip3 install argcomplete

    下载ROS 2

  2. Go the releases page: https://github.com/ros2/ros2/releases

  3. Unpack it:
mkdir -p ~/ros2_install
cd ~/ros2_install
tar xf ~/Downloads/ros2-package-linux-x86_64.tar.bz2

运行实例

source ~/ros2_install/ros2-linux/setup.bash
#In one terminal
ros2 run demo_nodes_cpp talker
#In another terminal
ros2 run demo_nodes_cpp listener

你将看到发布并收听到了hello word,说明安装成功

ROS 1 bridge

如果你已经安装了ROS1,先source ros1的安装文件,假设它在/opt/ros/kinetic/setup.bash.然后开启roscore

source /opt/ros/kinetic/setup.bash
roscore

在另一个终端开启桥接

source /opt/ros/kinetic/setup.bash
source ~/ros2_install/ros2-linux/setup.bash
ros2 run ros1_bridge dynamic_bridge

二、源码安装

系统要求

sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

添加仓库

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 421C365BD9FF1F717815A3895523BAEEB01FA116

安装GCC,G ++ CMake,Python 3 EmPy包(custom packages which don’t collide)和setuptools:

sudo apt-get update
sudo apt-get install git wget
sudo apt-get install build-essential cppcheck cmake libopencv-dev python-empy python3-dev python3-empy python3-nose python3-pip python3-pyparsing python3-setuptools python3-vcstool python3-yaml libtinyxml-dev libeigen3-dev
# dependencies for testing
sudo apt-get install clang-format pydocstyle pyflakes python3-coverage python3-mock python3-pep8 uncrustify
# Install argcomplete for command-line tab completion from the ROS2 tools.
# Install from pip rather than from apt-get because of a bug in the Ubuntu 16.04 version of argcomplete:
sudo pip3 install argcomplete
# additional testing dependencies from pip (because not available on ubuntu 16.04)
sudo pip3 install flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes pytest pytest-cov pytest-runner
# dependencies for FastRTPS
sudo apt-get install libasio-dev libtinyxml2-dev

创建工作区并克隆all repos

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
vcs-import src < ros2.repos

安装一个或多个DDS实现
PrismTech OpenSplice Debian Packages built by OSRF

sudo apt update && sudo apt install curl
curl http://repo.ros2.org/repos.key | sudo apt-key add -
sudo sh -c 'echo "deb http://repo.ros2.org/ubuntu/main xenial main" > /etc/apt/sources.list.d/ros2-latest.list'
sudo apt-get update
sudo apt-get install libopensplice67  # from repo.ros2.org

使用ament_tools的引导脚本构建原型

build the ROS 1 bridge

src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install --skip-packages ros1_bridge

然后设置ros1的环境变量ros2的环境变量

source /opt/ros/kinetic/setup.bash
source ~/ros2_ws/install/local_setup.bash

然后建立一个 ROS 1 桥:

src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install --only ros1_bridge --force-cmake-configure

Example 1: run the bridge and the example talker and listener

# Shell A:
source /opt/ros/kinetic/setup.bash
roscore

# Shell B:
source /opt/ros/kinetic/setup.bash
source ~/ros2_ws/install/setup.bash
export ROS_MASTER_URI=http://localhost:11311
ros2 run ros1_bridge dynamic_bridge

# Shell C:
source /opt/ros/kinetic/setup.bash
rosrun rospy_tutorials talker

# Shell D:
source ~/ros2_ws/install/setup.bash
ros2 run demo_nodes_cpp listener

当查看shell B中的输出时,将会有一行指出已经创建了该主题的桥梁:

该屏幕截图显示了所有的shell窗口及其预期内容:
这里写图片描述

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值