< >
Home » ROS2入门教程 » ROS2入门教程-在ubuntu16.04源码安装ros2的crystal版本

ROS2入门教程-在ubuntu16.04源码安装ros2的crystal版本

ROS2入门教程-在ubuntu16.04安装ros2的crystal版本

说明:

  • 介绍如何在ubuntu16.04源码安装ros2的crystal版本

步骤:

  • 增加utf8支持
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
  • 增加ros2仓库
  • 这一步需要能正常访问raw.githubusercontent.com
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
  • 下载ros2源码
mkdir -p ~/ros2_crystal/src
cd ~/ros2_crystal
wget https://raw.githubusercontent.com/ros2/ros2/crystal/ros2.repos
vcs import src < ros2.repos
  • 安装相关依赖
sudo rosdep init
rosdep update
# [Ubuntu 16.04]
rosdep install --from-paths src --ignore-src --rosdistro crystal -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 libopensplice69 python3-lark-parser rti-connext-dds-5.3.1 urdfdom_headers"
python3 -m pip install -U lark-parser
  • 编译ros2
cd ~/ros2_crystal/
# On Ubuntu Linux Xenial Xerus 16.04
colcon build --symlink-install --packages-ignore qt_gui_cpp rqt_gui_cpp
  • 加载ros2环境
source ~/ros2_crystal/install/setup.bash
  • 安装自动补全
sudo apt install python3-argcomplete

测试:

  • 启动话题发布
. ~/ros2_crystal/install/local_setup.bash
ros2 run demo_nodes_cpp talker
  • 启动话题接受
. ~/ros2_crystal/install/local_setup.bash
ros2 run demo_nodes_py listener
  • 成功则显示如下:

参考:

  • https://index.ros.org/doc/ros2/Installation/Crystal/Linux-Development-Setup/

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

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


标签: ros2入门教程