ROS2安装(armhf篇)


ROS2安装 (armhf篇)

文章源链接:https://xie-peiquan.gitee.io/categories/ROS2%E5%9F%BA%E7%A1%80/

由于ROS官方并没有提供armhf CPU架构的ROS2二进制安装文件,本篇整理了从ROS2源码编译安装的方法。本篇安装环境如下:

CPU架构:armv7l
操作系统:ubuntu20.04

1 更换镜像源(可选)

更换镜像源可以加速各种依赖库下载速度,这里提供常用的 ubuntu镜像源 和 pip源。

1.1 更换ubuntu镜像源

这里采用清华源,同学们可到该网站 https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/ 寻找自己系统版本对应的源。需要注意的是,大部分高校提供的源都是X86架构的,对于arm设备需要在源加上‘-ports’ 。armv7l / ubuntu20.04的源如下:

mv /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

1.2 更换 PIP 源

这里同样采用清华的pip源,可加速python第三方库的下载(后面需要),命令行输入以下命令即可。

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.trusted-host https://pypi.tuna.tsinghua.edu.cn

2 设置 locale

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

3 添加ROS2 存储库

# 1 确保启用universe存储库
sudo apt install software-properties-common
sudo add-apt-repository universe

# 2 添加ROS2 GPG 密钥
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

# 3 添加存储库到 sources list
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

# 4 更新apt
sudo apt apdate

4 安装编译工具

sudo apt update && sudo apt install -y \
  libbullet-dev \
  python3-pip \
  python3-pytest-cov \
  ros-dev-tools

# install some pip packages needed for testing
python3 -m pip install -U \
  argcomplete \
  flake8-blind-except \
  flake8-builtins \
  flake8-class-newline \
  flake8-comprehensions \
  flake8-deprecated \
  flake8-docstrings \
  flake8-import-order \
  flake8-quotes \
  pytest-repeat \
  pytest-rerunfailures \
  pytest
# install Fast-RTPS dependencies
sudo apt install --no-install-recommends -y \
  libasio-dev \
  libtinyxml2-dev
# install Cyclone DDS dependencies
sudo apt install --no-install-recommends -y \
  libcunit1-dev

5 获取ROS2源码

mkdir -p ~/ros2_foxy/src
cd ~/ros2_foxy
wget https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos --no-check-certificate
## github下载不稳定,可自行修改repos文件,添加代理前缀 https://ghproxy.com/
vcs import --input ./ros2.repos src

6 使用Rosdep安装依赖

sudo apt upgrade
cd /etc/ros/rosdep/sources.list.d && wget https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
rosdep update
rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-5.3.1 urdfdom_headers"

7 编译ROS2源码

cd ~/ros2_foxy/
colcon build --symlink-install

8 设置环境变量

. ~/ros2_foxy/install/local_setup.bash

9 测试

## 运行talker
. ~/ros2_foxy/install/local_setup.bash
ros2 run demo_nodes_cpp talker

## 新起另一个终端,运行listener
. ~/ros2_foxy/install/local_setup.bash
ros2 run demo_nodes_py listener

~~欢迎到我个人博客 https://xie-peiquan.gitee.io/ 查看更多关于ROS2的文章,嘿嘿!

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

>_ XPQ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值