Raspberry Pi 4 + Ubuntu 24.04 + ROS 2 Jazzy (May, 2024)
Raspberry Pi 4(RAM 2GB)にUbuntu 24.04 + ROS 2 JazzyをインストールしてTurtleBot3 Burgerを動かすまで
-
ubuntu-24.04-preinstalled-server-arm64+raspi.img.xz
ではSSHのパスワード認証が初期状態で無効化されていたので、セットアップの途中まではモニタとキーボード接続が必須 - メモリ2GBのRaspberry Piだとcolcon build時にメモリが不足するためswapを用意しておくか、メモリ4GB以上のRaspberry Piを使うことを推奨
OS書き込み
https://cdimage.ubuntu.com/releases/24.04/release/ からubuntu-24.04-preinstalled-server-arm64+raspi.img.xz
をダウンロードし、balenaEtherでmicroSDにイメージを書き込む
OS初期設定
モニタとキーボードを接続した状態で操作する
無線LAN
vimは入っていたので、netplanを設定し、最初から無線LANに接続する
sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/51-wifi.yaml
-
sudo vim /etc/netplan/51-wifi.yaml
- https://github.com/canonical/netplan/blob/main/examples/wireless.yaml を参考にしながらとりあえずDHCPでIPアドレスを取得するように設定する
network:
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: true
optional: true
access-points:
"SSID":
password: "WIFI-PASSWORD"
SSHのパスワード認証を有効化する
パスワード認証が無効化されているので有効化する
-
sudo vi /etc/ssh/sshd_config.d/50-cloud-init.conf
-
PasswordAuthentication no
をyes
にする
-
sudo systemctl reload ssh
Gitのインストール
sudo apt update && sudo apt install git
いったんここで再起動しておく
ROSのインストール
インストーラ( https://github.com/Tiryoh/ros2_setup_scripts_ubuntu )を使用してROS 2 Jazzyのros-testingのリポジトリをupstreamとしてインストールする
git clone https://github.com/Tiryoh/ros2_setup_scripts_ubuntu.git
-
cd ros2_setup_scripts_ubuntu && git switch feature/add-ros2-jazzy
- このブランチは作業用ブランチなので下記のPull Requestをマージしたあとは
main
ブランチのままでよい
- このブランチは作業用ブランチなので下記のPull Requestをマージしたあとは
./ros2-jazzy-ros-base-testing.sh
ros-testingとmainの違いは下記資料参照
チュートリアルROSパッケージのインストール
-
cd ~/ros2_setup_scripts_ubuntu && ./tutorial.sh
- パッケージ不足のエラーが出たので下記を追加でインストールして
tutorial.sh
をやり直しsudo apt install ros-jazzy-example-interfaces
- メモリが不足してcolcon buildに相当時間かかるので途中で停止してswapを増やす
-
curl -SsfL git.io/create_2gbswapfile | bash
- メモリとswapあわせて3GBぐらいは必要そうなので4GBモデルを使った方がよさそう
-
- パッケージ不足のエラーが出たので下記を追加でインストールして
setup.py周りでめっちゃワーニング出てる……
Starting >>> examples_rclpy_minimal_action_server
--- stderr: examples_rclpy_minimal_action_server
/usr/lib/python3/dist-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
easy_install.initialize_options(self)
---
Finished <<< examples_rclpy_minimal_action_server [5.46s]
Starting >>> examples_rclpy_minimal_client
--- stderr: examples_rclpy_minimal_client
/usr/lib/python3/dist-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
easy_install.initialize_options(self)
---
Finished <<< examples_rclpy_minimal_client [7.90s]
Starting >>> examples_rclpy_minimal_publisher
--- stderr: examples_rclpy_minimal_publisher
/usr/lib/python3/dist-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
easy_install.initialize_options(self)
---
Finished <<< examples_rclpy_minimal_publisher [5.50s]
Starting >>> examples_rclpy_minimal_service
--- stderr: examples_rclpy_minimal_service
/usr/lib/python3/dist-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
easy_install.initialize_options(self)
---
Finished <<< examples_rclpy_minimal_service [5.41s]
Starting >>> examples_rclpy_minimal_subscriber
--- stderr: examples_rclpy_minimal_subscriber
/usr/lib/python3/dist-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
easy_install.initialize_options(self)
---
Finished <<< examples_rclpy_minimal_subscriber [8.32s]
Starting >>> examples_rclpy_pointcloud_publisher
--- stderr: examples_rclpy_pointcloud_publisher
/usr/lib/python3/dist-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
easy_install.initialize_options(self)
---
Finished <<< examples_rclpy_pointcloud_publisher [6.99s]
Starting >>> launch_testing_examples
--- stderr: launch_testing_examples
/usr/lib/python3/dist-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
easy_install.initialize_options(self)
---
Finished <<< launch_testing_examples [5.37s]
colconではワーニングを消す方向で準備を進めているらしい……
colcon-coreの0.16.0で上記がリリースされている。現状のROS 2 Jazzyでは0.16.1がインストールされていた
関連issue
export PYTHONWARNINGS="ignore:easy_install command is deprecated::setuptools.command.develop"
と書いたらワーニングが表示されなくなった
(これでよいのか?と言う気はするがいったんこれで乗り切る)
ドキュメントはまだリリースされていないが、colcon workspaceにYAMLをおくだけでcolconのデフォルトオプションを設定できるようになっているらしい。colcon-defautlsの0.2.7からの機能で、現状のROS 2 Jazzyでは0.2.8がインストールされていた。
~/ros2_ws/colcon_defaults.yaml
として下記の内容を貼り付け。
build:
symlink-install: true
executor: sequential
event-handlers:
- console_stderr+
test:
executor: sequential
event-handlers:
- console_cohesion+
- desktop_notification+
return-code-on-test-failure: true
※colcon-defaults自体は、2018年頃から存在するプロジェクトでROS 2 Humbleの頃から使えていた(その前も存在したはずだが試していないので不明)
colcon-defautlsの0.2.7からはROSのワークスペースごとに切り替えができるようになっている。いままでは$HOME/.colcon/defualts.yaml
に配置するなど使用している環境(≠ワークスペース)で共通だった。
TurtleBot3用ROSパッケージのインストール(Raspberry Pi)
上記資料を参照してROSパッケージのインストールを実施
※もしもLDS-01を使っている場合はld08_driverの代わりにhls_lfcd_lds_driver( https://github.com/ROBOTIS-GIT/hls_lfcd_lds_driver )を指定する
mkdir -p ~/.colcon
vim ~/.colcon/defaults.yaml
mkdir -p ~/ros2_ws/src
git clone -b ros2-devel https://github.com/ROBOTIS-GIT/ld08_driver.git
sudo apt install libudev-dev # https://github.com/ROBOTIS-GIT/ld08_driver/pull/9
git clone -b ros2-devel https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone -b ros2-devel https://github.com/ROBOTIS-GIT/turtlebot3.git
touch turtlebot3/turtlebot3_cartographer/COLCON_IGNORE
touch turtlebot3/turtlebot3_navigation2/COLCON_IGNORE
rosdep install -riy --from-paths .
cd ~/ros2_ws
colcon build
source install/setup.bash
~/.colcon/defaults.yaml
の中身は下記の通り最小限だけ記載
build:
executor: sequential
test:
executor: sequential
return-code-on-test-failure: true
追加でUSBデバイス用のudev rulesの設定とROS_DOMAIN_ID
の設定
sudo cp `ros2 pkg prefix turtlebot3_bringup`/share/turtlebot3_bringup/script/99-turtlebot3-cdc.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger
echo 'export ROS_DOMAIN_ID=30 #TURTLEBOT3' >> ~/.bashrc
echo 'export LDS_MODEL=LDS-02' >> ~/.bashrc
echo 'export OPENCR_PORT=/dev/ttyACM0' >> ~/.bashrc
echo 'export OPENCR_MODEL=burger' >> ~/.bashrc
echo 'export TURTLEBOT3_MODEL=burger' >> ~/.bashrc
こちらのステップは、Raspberry でなく、Remote PCでのUbuntu Jazzyをおこなったのか?
Raspberry Piです。ここまでの流れでRemote PCは登場しません。
ご返事ありがとうございます!!では、Remote PCの設定も教えていただけますか。現在Jazzyを使っていますが、TurtleBot 3のパッケージはHumbleまでです。どうすればいいですか?
Raspberry Piでソースコードからビルドしたのと同じように、PCでもソースコードからビルドしてみてください。
OpenCRの更新
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install libc6:armhf
mkdir -p ~/Downloads && cd ~/Downloads
wget https://github.com/ROBOTIS-GIT/OpenCR-Binaries/raw/master/turtlebot3/ROS2/latest/opencr_update.tar.bz2 -O opencr_update_ros2.tar.bz2
tar -xvf ./opencr_update_ros2.tar.bz2
cd opencr_update
source ~/.bashrc
./update.sh $OPENCR_PORT $OPENCR_MODEL.opencr
Bringup(Turtlebot3 Only)
起動できるところまで確認する
cd ~/ros2_ws
source install/setup.bash
ros2 launch turtlebot3_bringup robot.launch.py
PCでSSHでログインして下記を実行してモータが回ることを確認する(モータが回転するので、機体を浮かせる。不要であれば省略。)
ros2 topic pub -1 /cmd_vel geometry_msgs/msg/Twist '{linear:{x: 0.05,y: 0.0,z: 0.0},angular:{x: 0.0,y: 0.0,z: 0.0}}'
ros2 topic pub -1 /cmd_vel geometry_msgs/msg/Twist '{linear:{x: 0.0,y: 0.0,z: 0.0},angular:{x: 0.0,y: 0.0,z: 0.0}}'
I also install ros2 jazzy in burger,but the navigation2 can't work.