< >
Home » ROS2入门教程 » ROS2入门教程-在ubuntu18.04下源码安装ROS2 Dashing

ROS2入门教程-在ubuntu18.04下源码安装ROS2 Dashing

ROS2入门教程-在ubuntu18.04下源码安装ROS2 Dashing

说明

  • 介绍如何Linux系统上源码安装ROS2

  • 测试环境:Ubuntu 18.04 LTS + ROS2 Dashing

安装步骤

  • 确保有一个支持UTF-8的locale设置。locale设置例子如下:
$ 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 apt update && sudo apt install curl gnupg2 lsb-release
$ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
$ sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
  • 安装相关的工具包和依赖
$ sudo apt update && sudo apt install -y \
  build-essential \
  cmake \
  git \
  python3-colcon-common-extensions \
  python3-lark-parser \
  python3-pip \
  python-rosdep \
  python3-vcstool \
  wget

# install some pip packages needed for testing
$ python3 -m pip install -U \
  argcomplete \
  flake8 \
  flake8-blind-except \
  flake8-builtins \
  flake8-class-newline \
  flake8-comprehensions \
  flake8-deprecated \
  flake8-docstrings \
  flake8-import-order \
  flake8-quotes \
  pytest-repeat \
  pytest-rerunfailures \
  pytest \
  pytest-cov \
  pytest-runner \
  setuptools

# install Fast-RTPS dependencies
$ sudo apt install --no-install-recommends -y \
  libasio-dev \
  libtinyxml2-dev
    
  • 创建工作空间并进行下载源码
$ mkdir -p ~/ros2_ws/src
$ cd ~/ros2_ws
$ wget https://raw.githubusercontent.com/ros2/ros2/dashing/ros2.repos
$ vcs import src < ros2.repos
  • 用rosdep安装依赖项
$ sudo rosdep init
$ rosdep update
$ rosdep install --from-paths src --ignore-src --rosdistro dashing -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 libopensplice69 rti-connext-dds-5.3.1 urdfdom_headers"
  • 编译所有包
$ cd ~/ros2_ws/
$ colcon build --symlink-install

测试使用

  • 运行talker-listener例子测试是否成功安装

  • 新终端,执行以下命令:

    $ . ~/ros2_ws/install/local_setup.bash
    $ ros2 run demo_nodes_cpp talker

  • 新终端,执行以下命令:

    $ . ~/ros2_ws/install/local_setup.bash
    $ ros2 run demo_nodes_cpp listener

  • 测试成功截图

请输入图片描述


参考资料

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: ros2入门教程