Installing ROS 2 on Ubuntu20.04 Linux

Installing ROS 2 on Ubuntu20.04 Linux

1. Binary packages

We provide ROS 2 binary packages for the following platforms:

  • Ubuntu Linux - Focal Fossa (20.04)

    • Debian packages

    • “fat” archive

  • macOS

  • Windows

2. Building from source

We support building ROS 2 from source on the following platforms:

3. System requirements

The current Debian-based target platforms for Foxy Fitzroy are:

  • Tier 1: Ubuntu Linux - Focal Fossa (20.04) 64-bit

  • Tier 3: Debian Linux - Buster (10) 64-bit

Other Linux platforms with varying support levels include:

  • Arch Linux, see alternate instructions

  • Fedora Linux, see alternate instructions

  • OpenEmbedded / webOS OSE, see alternate instructions

4. System setup

4.1 Set locale

Make sure you have a locale which supports UTF-8. If you are in a minimal environment (such as a docker container), the locale may be something minimal like POSIX. We test with the following settings. However, it should be fine if you’re using a different UTF-8 supported locale.

locale  # check for UTF-8

sudo apt update && sudo apt install locales
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

locale  # verify settings

一次不成功,建议重复多次

4.2 Add the ROS 2 apt repository

You will need to add the ROS 2 apt repositories to your system. To do so, first authorize our GPG key with apt like this:

sudo apt update && sudo apt install curl gnupg2 lsb-release

# 下面这条语句,我的输出错误: gpg: no valid OpenPGP data found,可能你们还会有其他问题
# sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key  -o /usr/share/keyrings/ros-archive-keyring.gpg

# 解决上面的问题,可以换成下面这条语句:
curl http://repo.ros2.org/repos.key | sudo apt-key add -

And then add the repository to your sources list:

# 我添加的源

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

# 官方源
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'

4.3 Install ROS 2 packages

(1)更新源
# 执行更新后,出现问题了
sudo apt update

N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'http://packages.ros.org/ros2/ubuntu focal InRelease' doesn't support architecture 'i386'

参照 ROS 2 安装后BUG,解决方法是:

$ cd /etc/apt/sources.list.d
$ sudo gedit ros2-latest.list

# 打开文本后出现:
deb http://packages.ros.org/ros2/ubuntu bionic main

# 在deb后插入[arch=amd64]变成:
deb [arch=amd64] http://packages.ros.org/ros2/ubuntu bionic main

# 保存并关闭

# 再次更新即可
sudo apt update

如果更新出现问题,多试几次

(2)安装ROS2

推荐安装ROS2桌面版本(包括ROS、RViz、demos、tutorials)

sudo apt install ros-foxy-desktop

如果出现问题,重复试几次

4.4 Environment setup

(1)使用脚本来设置

如果你的 SHELL 是用 bash,就是:

source /opt/ros/foxy/setup.bash

如果你的 SHELL 是用 zsh 的,就是:

source /opt/ros/foxy/setup.zsh

以后每次打开终端都需要输入一次上面的语句,比较麻烦。以 zsh 为例,解决方法:

echo "source /opt/ros/foxy/setup.zsh" >> ~/.zshrc 
source ~/.zshrc

这样,以后每次新打开终端,就不需要输入这条语句了 source /opt/ros/foxy/setup.zsh,终端会自动帮你加载这条语句,设置好 ROS2 的环境变量。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值