1. 概要
「ROS」は、多くの「Liunx」へインストールできるようです。
「Robot Operating System - Wikipedia」によれば、「Ubuntu」「Liunx Mint」が中心とのことです。
多くの日本人であれば、「Ubuntu」を使うのでしょうが、わたしは、いささかへそ曲がりなので、「Linux Mint」を使いたいのですが・・・。
ちと事情がありまして、「Ubuntu」へとインストールします。
本ページは、下記のサイトを参考にさせていただきました。
「Ubuntu (source) — ROS 2 Documentation: Jazzy documentation」
環境としては、2024年11月26日時点で「LTS(Long-Term Support)」が最新であるものが、「Ubuntu 24.04」向けの「ROS2 Jazzy Jalisco」というもののようですので。
「Ubuntu 24.04 Cinnamon」へ「ROS2 Jazzy Jalisco」をインストールしてみます。
「GNOME」より「Cinnamon」の方が、親しめるのだ。
2. 準備
「Ubuntu 24.04 Cinnamon」は、「VirtualBox 7.1.4」上へインストールし、わたしが使うツールの類は、インストールした状態です。
そのあたりは、「Linux - Ubuntu - 24.04 - 共通事項」をご参照ください。
パッケージも改めてすべて、最新へしておきます。
ロケールを「en_US」にせねばならぬと書いているわ。
やるならば。
「root」ユーザ権限で。
apt update && sudo apt install locales
locale-gen en_US en_US.UTF-8
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
ログインユーザで。
export LANG=en_US.UTF-8
locale
最後のコマンドは、確認のみだな。
しかし、これは、にっちもさっちもいかなくなるまで日本語環境のままで行ってみようと思います。
3. リポジトリ追加
「root」ユーザ権限で。
リポジトリの有効化。
apt install software-properties-common
add-apt-repository universe
「GPG」キーを追加。
apt install curl -y
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
4. 開発ツールインストール
apt update
apt install -y \
python3-flake8-blind-except \
python3-flake8-class-newline \
python3-flake8-deprecated \
python3-mypy \
python3-pip \
python3-pytest \
python3-pytest-cov \
python3-pytest-mock \
python3-pytest-repeat \
python3-pytest-rerunfailures \
python3-pytest-runner \
python3-pytest-timeout \
ros-dev-tools
5. ROS2 ビルド
下記で、「ROS2」をビルドするらしい。
これは、ログインユーザで。
mkdir -p ~/ros2_jazzy/src
cd ~/ros2_jazzy
vcs import --input https://raw.githubusercontent.com/ros2/ros2/jazzy/ros2.repos src
6. インストール
ここからが、本体のインストール?
このまま、ログインユーザで(「root」ユーザ権限の必要なところは「sudo」を使います)。
sudo apt upgrade -y
sudo rosdep init
rosdep update
ここで、下記が表示されまして。
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Skip end-of-life distro "foxy"
Skip end-of-life distro "galactic"
Skip end-of-life distro "groovy"
Add distro "humble"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Add distro "iron"
Skip end-of-life distro "jade"
Add distro "jazzy"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Skip end-of-life distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/hogehoge/.ros/rosdep/sources.cache
終わったディストリビューションは、スキップしているのね?
次に。
rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"
なんかインストールされたようです。
次に。
cd ~/ros2_jazzy/
colcon build --symlink-install
ここまでもある程度時間がかかりましたが、ここのコマンドは、結構時間がかかります。
ところどころ、時間がかかってそうなログを掲載しておきます。
Finished <<< fastrtps [1h 44min 44s]
Finished <<< rmw_fastrtps_shared_cpp [16min 56s]
Finished <<< sensor_msgs [20min 0s]
Finished <<< rviz_ogre_vendor [2h 7min 49s]
Finished <<< rclcpp [1h 21min 50s]
Finished <<< rviz_default_plugins [1h 55min 27s]
Summary: 364 packages finished [8h 18min 33s]
トータルで、8時間以上かかります。
(別のマシンでは、45分程度でした、なんだろうこの差は?)
ここまでで、一応、インストールは完了かしら。
結構な量があるようです。
$ du -hs ros2_jazzy
11G ros2_jazzy
7. 環境設定
シェルが「bash」の場合、下記で環境設定を行うようです。
. ~/ros2_jazzy/install/local_setup.bash
これは、環境を使う場合、毎回使うようなので、「~/.bashrc」へ取り込んでおきます。
vi ~/.bashrc
末尾に下記の行を加えます。
. ~/ros2_jazzy/install/local_setup.bash
他に、「sh」「zsh」用として、「setup.sh」「setup.zsh」中のがあるようです。
いくつか、サンプルを試しで、動かせるようです。
「C++」で、「talker」ちゅうのを動かす場合。
ros2 run demo_nodes_cpp talker
「Python」で、「listener」中のを動かす場合。
ros2 run demo_nodes_py listener
他の言語も動かせるようで、「Clang」を使う場合は、下記の一連のコマンドを使うようです。
sudo apt install clang
export CC=clang
export CXX=clang++
colcon build --cmake-force-configure
参考サイトに、アンインストール手順も、書かれていました。
rm -rf ~/ros2_jazzy
なんだ削除するだけね。