Debian 13 (trixie) に ROS 2 Jazzy をインストールする手順【Raspberry Pi / arm64】
はじめに
久しぶりにロボットを作りたくなったので、Raspberry Pi に ROS 2 Jazzy を入れることにしました。
環境を確認すると Debian 13 trixie / arm64 だったため、今回は Debian / Raspberry Pi OS Trixie 向けの非公式APTリポジトリである rospian を使ってインストールします。
この記事では、その手順をまとめます。
環境
cat /etc/os-release
出力例:
PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
NAME="Debian GNU/Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.4
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
アーキテクチャも確認します。
uname -m
aarch64 と表示されれば 64bit ARM 環境です。
APT上のアーキテクチャも確認します。
dpkg --print-architecture
arm64 と表示されればOKです。
必要なパッケージをインストール
sudo apt update
sudo apt install -y curl gnupg lsb-release locales
locale の設定
ROS 2 を使う前に locale を設定しておきます。
sudo sed -i 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
sudo locale-gen
sudo update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
反映のため、一度再起動します。
sudo reboot
再ログイン後、確認します。
locale
rospian の署名鍵を追加
rospian の署名鍵を追加します。
curl -fsSL https://rospian.github.io/rospian-repo/public/rospian-archive-keyring.asc \
| gpg --dearmor \
| sudo tee /usr/share/keyrings/rospian-archive-keyring.gpg >/dev/null
APTリポジトリを追加
echo "deb [arch=arm64 signed-by=/usr/share/keyrings/rospian-archive-keyring.gpg] https://rospian.github.io/rospian-repo trixie-jazzy main" \
| sudo tee /etc/apt/sources.list.d/rospian.list
パッケージ一覧を更新します。
sudo apt update
ROS 2 Jazzy をインストール
今回は最小構成に近い ros-base をインストールしました。
sudo apt install -y ros-jazzy-ros-base
GUIツールやRVizなども必要な場合は、代わりに以下を入れます。
sudo apt install -y ros-jazzy-desktop
すでに ros-jazzy-ros-base を入れている状態で、あとから ros-jazzy-desktop を入れても問題ありません。
追加分だけインストールされます。
環境設定
毎回ROS 2の環境を読み込むため、.bashrc に追記します。
echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc
source ~/.bashrc
インストール確認
ros2 --help
以下のように ros2 コマンドのヘルプが表示されれば成功です。
usage: ros2 [-h] [--use-python-default-buffering] Call `ros2 <command> -h` for more detailed usage. ...
ros2 is an extensible command-line tool for ROS 2.
options:
-h, --help show this help message and exit
--use-python-default-buffering
Do not force line buffering in stdout and instead use the python default buffering, which
might be affected by PYTHONUNBUFFERED/-u and depends on whatever stdout is interactive or not
Commands:
action Various action related sub-commands
bag Various rosbag related sub-commands
component Various component related sub-commands
daemon Various daemon related sub-commands
doctor Check ROS setup and other potential issues
interface Show information about ROS interfaces
launch Run a launch file
lifecycle Various lifecycle related sub-commands
multicast Various multicast related sub-commands
node Various node related sub-commands
param Various param related sub-commands
pkg Various package related sub-commands
plugin Various plugin related sub-commands
run Run a package specific executable
security Various security related sub-commands
service Various service related sub-commands
topic Various topic related sub-commands
wtf Use `wtf` as alias to `doctor`
Call `ros2 <command> -h` for more detailed usage.
デモノードで動作確認
デモノードが入っていない場合は追加でインストールします。
sudo apt install -y ros-jazzy-demo-nodes-cpp ros-jazzy-demo-nodes-py
ターミナルを2つ開きます。
ターミナル1
ros2 run demo_nodes_cpp talker
ターミナル2
ros2 run demo_nodes_py listener
listener 側で以下のような出力が出れば、ROS 2 の通信確認は成功です。
I heard: [Hello World: ...]
locale 警告が出た場合
.bashrc を読み込んだときに、以下のような警告が出ることがあります。
-bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
この場合は locale が生成されていないため、以下を実行します。
sudo apt update
sudo apt install -y locales
sudo sed -i 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
sudo locale-gen
sudo update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
その後、再起動します。
sudo reboot
まとめ
今回は、Debian 13 trixie 環境に、 ROS 2 Jazzy を導入しました。
ポイントは以下の通りです。
- OSは Debian 13
trixie - アーキテクチャは
arm64 -
rospianの非公式APTリポジトリを使用 -
ros2 --helpが表示されればインストール成功 -
talker/listenerで通信確認できる