LoginSignup
2
2

Raspberry Pi OS (64bit, bookworm)でROS2 Ironをビルドする

Last updated at Posted at 2024-01-19

記事は2024年1月19日時点での情報です.

記事タイトルの通りですが,Raspberry Pi OS上でネイティブのROS2を使えるようにします.できるよ!って記事を残しておきたいというのが主なモチベーションです.(なので,ほぼビルドログみたいなもんです)

Raspberry Pi上でソースからビルドすると非常に長い時間がかかるので,まずは以下の利用を検討してもよいと思います.
(ただ,Raspberry Piのハードウェアに強く依存するようなパッケージを使いたい場合は,やはり手でビルドすることになるかと思います)

  1. Raspberry Pi OSではなくUbuntuを使う: https://ubuntu.com/download/raspberry-pi でOSイメージが配布されています.(試していませんが,miscroSDに焼いてセットアップしたあとは公式の手順でaptを使って容易に導入できるはずですます)
  2. Dockerを使う: Docker Hubでarm64/v8向けのイメージ(64bit系のRaspberry Pi OSで利用可能)が公開されています.
  3. ビルド済のアーカイブを直で入れる: https://github.com/Ar-Ray-code/rpi-bullseye-ros2 で配布してくれている方がいます.(リポジトリのREADMEをよく読んでください)

ではビルドしていきます.環境は以下の通りです.

Hardware: Raspberry Pi 4B 8GB
Software: Raspberry Pi OS 64bit (bookworm, 2023-12-05)

イメージを焼くだけ焼いて起動したら,とりあえずパッケージを更新しておきます.

sudo apt update && sudo apt upgrade -y

終わったら,ROSの公式手順に従ってインストールを行います.
see: https://docs.ros.org/en/iron/Installation/Alternatives/Ubuntu-Development-Setup.html

上記のページにはTier 3: Debian Linux - Bullseye (11) 64-bitと書いてありますが,実際にはbookwormのRaspberry Pi OSでも大丈夫です.
(http://packages.ros.org/ros2/ubuntu/dists/ にbookwormが用意されているため)

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

↑は行ってもupdate-localeでエラーが出るため,スキップしました.

sudo apt install software-properties-common
sudo add-apt-repository universe

↑も実行してもダメなのでスキップします.

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

↑やりました.

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

↑これは,$(. /etc/os-release && echo $UBUNTU_CODENAME)がダメなので,以下↓のように変更して実行しました.(bookwormと直で書く)

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu bookworm main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update && sudo apt install -y \
  python3-flake8-docstrings \
  python3-pip \
  python3-pytest-cov \
  python3-flake8-blind-except \
  python3-flake8-builtins \
  python3-flake8-class-newline \
  python3-flake8-comprehensions \
  python3-flake8-deprecated \
  python3-flake8-import-order \
  python3-flake8-quotes \
  python3-pytest-repeat \
  python3-pytest-rerunfailures \
  ros-dev-tools

↑やりました.途中でcolconのunpackingあたりでエラーだか警告だかが出ましたが,問題なさそうです.

(エラー内容↓)

Selecting previously unselected package python3-colcon-core.
Preparing to unpack .../16-python3-colcon-core_0.15.1-1_all.deb ...
Unpacking python3-colcon-core (0.15.1-1) ...
Selecting previously unselected package colcon.
Preparing to unpack .../17-colcon_0.12.1-1_all.deb ...
Unpacking colcon (0.12.1-1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-sCcxyI/17-colcon_0.12.1-1_all.deb (--unpack):
 trying to overwrite '/usr/bin/colcon', which is also in package python3-colcon-core 0.15.1-1
mkdir -p ~/ros2_iron/src
cd ~/ros2_iron
vcs import --input https://raw.githubusercontent.com/ros2/ros2/iron/ros2.repos src

↑やりました.

sudo apt upgrade

↑やりました.(最初にupgradeしているので特に何も起きませんでした)

sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"

↑やりました.

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

↑本チャンのビルドです.Raspberry Pi上で実行するとめ〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜ちゃくちゃ時間がかかります.(なので,特にssh接続の場合はscreenやtmuxのようなターミナルマルチプレクサを使った方がいいです)

(というか,ビルド中あまりにも暇なのでこの記事を書いています.3時間経過して359パッケージのうち271パッケージしか終わっていません)
(結局7時間半経過して終わりました.エラーがなくて良かったです)

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2