2
2

WSL2の環境下において、Open-RMFを使って複数のturtlebot3を動かしてみた 環境構築編

Last updated at Posted at 2023-12-28

はじめに

私はゲームはしない人間ですが、最近中古のゲーミングPCを入手したので、なにか計算負荷の重いことでもしてみたいなと考えていました。
そうなると可視化シミュレーションだなと考え、先日投稿したバスの動きの可視化をUnityとかでやろうかなとか、PLATEUとか使ってなにかできないかなとか考えていました。そんな中色々調査したところ、@yoshi-imaさんの記事[1]を読みロボットの群制御をするのは面白そうと思いました。そこでまずは環境構築してみたのがこの記事になります。

実行環境

  • CPU: CORE i7 7th Gen
  • メモリ: 32GB
  • GPU: GeForce RTX 2070
  • OSと構築した環境: Window11でWSL2にUbuntu20.04をインストールした環境
  • ROS: @yoshi-imaさんの記事と同じようにROS/ROS 2の混在環境にし、ROSは Noetic, ROS 2はFoxyとしました。

環境構築手順

WSL2+ubuntu 20.04LTSの環境構築

  • WSL2+ubuntu20.04LTSのインストール
    [2]の記事の「Microsoft Storeからインストールする場合」を適用してWSL2+ubuntu20.04LTSの環境を構築しました。

  • WSL2のGUI表示
    rvizやgazeboといったGUIツールを使うのでGUI表示はこの件では必須です。windows10環境下だと色々設定がいるみたいですが、私の環境下では[3]の記事の通りにやりましたら問題なくGUI表示できました。

  • GPUの有効化
    今回の件なら必要ないかもしれませんが、せっかくGPU搭載のPCなのでやってみました。[4]の記事の手順を実行したあとに
terminal
nvidia-smi

を実行してWSL2上にてGPUが認識されているか確認しました。

ROS,ROS2,Open-RMFの環境構築

最初に行った手順

[1]の記事の通りに

  • ROSとROS2のインストール
  • Free Fleet環境構築
  • Server in ROS 2 環境構築
  • Client in ROS 環境構築
  • 複数ロボットの動作確認(エラー対策)
    を行い環境構築しました。

そして別々のターミナルを開き以下のコマンドを実行しました。
[1]と同じコマンドを実行しています。)

terminal(1)
cd ~/Work/open-rmf/free_fleet/ros2
source install/setup.bash
ros2 launch ff_examples_ros2 turtlebot3_world_ff_server.launch.xml
terminal(2)
cd ~/Work/open-rmf/free_fleet/ros1
source install/setup.bash
export TURTLEBOT3_MODEL=burger; roslaunch ff_examples_ros1 multi_turtlebot3_ff.launch

そうしたところ、turtlebotからの情報が取得できず、rviz上でもGlobal Statusがerrorのままです。。

私の環境での解決方法

エラーメッセージを調査していったところ[5]の記事に行き当たりました。どうやら同じようなエラーが発生してそうということで、読み進めていき、
[1]の記事における「Client in ROS 環境構築」で実行したコマンドを以下のコマンドにすれば良さそうということがわかり、実行しました。

terminal
mkdir -p ~/Work/open-rmf/free_fleet/ros1/src
cd ~/Work/open-rmf/free_fleet/ros1/src
git clone https://github.com/open-rmf/free_fleet -b main
git clone https://github.com/eclipse-cyclonedds/cyclonedds -b releases/0.7.x
git clone https://github.com/osrf/free_fleet -b fix/focal-docs
git clone https://github.com/eclipse-cyclonedds/cyclonedds
git clone https://github.com/rhaschke/robot_state_publisher -b noetic-devel
git clone https://github.com/aaronchongth/turtlebot3 -b noetic-devel
git clone https://github.com/aaronchongth/turtlebot3_simulations -b noetic-devel
sudo apt install ros-noetic-gazebo-ros-pkgs ros-noetic-dwa-local-planner
cd ..
rosdep install --from-paths src --ignore-src --rosdistro noetic -yr
source /opt/ros/noetic/setup.bash
colcon build --symlink-install

シミュレーション結果

再度別々のターミナルを開き以下のコマンドを打ち、turtlebot3が制御できるかの確認をしてみました。

terminal(1)
cd ~/Work/open-rmf/free_fleet/ros2
source install/setup.bash
ros2 launch ff_examples_ros2 turtlebot3_world_ff_server.launch.xml
terminal(2)
cd ~/Work/open-rmf/free_fleet/ros1
source install/setup.bash
export TURTLEBOT3_MODEL=burger; roslaunch ff_examples_ros1 multi_turtlebot3_ff.launch

以下の図のようにrviz上で3台のturtlebot3がGlobal Statusもerrorになることなく表示されていることが確認できました。
initial_rviz.png

そして、また別のターミナルを開き、以下のコマンド(数字は適当です)を打つと

terminal(3)
cd ~/Work/open-rmf/free_fleet/ros2
source install/setup.bash
ros2 run ff_examples_ros2 send_destination_request.py -f turtlebot3 -r tb3_0 -x 1.0 -y -0.39 --yaw 0.0 -i 001

次に示す図のようにturtlebot3が移動し始めることが確認できました。また"tb3_0"のところを"tb3_1"や"tb3_2"として別のturtlebot3を指定すれば、同時に複数のturtlrbot3を動かせることも確認できました。
移動.png

まとめ

 WSL2の環境下においてもOpen-RMFを使って複数のturtlebot3を動かす環境を構築することができたと考えられます。
 ただ、[1]の記事に記載のあるrvizにおいて「fleet名に"turtelbot3"として、robot名に'tb3_0'、'tb3_1'、'tb3_2'のいずれかを記載して、2D NavGoalを設定します。「Send Nav Goal」ボタンを押下すると、指定したロボットが動き出します。」ということは私の環境ではできず、turtlebot3を動かすことができるのは先ほどのコマンド実行だけでした。

2024/1/1 追記

その後、WSL2+Ubuntu20.04の中で色々やろうとしたところ、中身がめちゃくちゃになってしまったので、Ubuntu20.04を再インストールして再度この環境構築をしようとしました。そうしたところ新たな知見が得られましたので、ここに記載します。

Server in ROS 2 環境構築方法について

参考にさせていただいている[1]の記事の「Server in ROS 2 環境構築手順」の以下のコマンドを実行しましたところ、3つほどエラーがでましたので、どのように対処したか示します。

mkdir -p ~/Work/open-rmf/free_fleet/ros2/src
cd ~/Work/open-rmf/free_fleet/ros2
wget https://raw.githubusercontent.com/open-rmf/rmf/release/21.09/rmf.repos
vcs import src < rmf.repos
cd src
git clone https://github.com/open-rmf/free_fleet -b main
rm -rf ./free_fleet/free_fleet_client_ros2
cd ..
source /opt/ros/foxy/setup.bash
rosdep install --from-paths src --ignore-src --rosdistro foxy -yr
chmod a+x ~/Work/open-rmf/free_fleet/ros2/src/free_fleet/ff_examples_ros2/scripts/*.py
colcon build --symlink-install

Server in ROS 2 環境構築におけるエラー1

まず以下のエラーが出ました。

エラー1
--- stderr: free_fleet
CMake Error at CMakeLists.txt:15 (find_package):
  By not providing "FindCycloneDDS.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "CycloneDDS", but CMake did not find one.

  Could not find a package configuration file provided by "CycloneDDS" with
  any of the following names:

    CycloneDDSConfig.cmake
    cyclonedds-config.cmake

  Add the installation prefix of "CycloneDDS" to CMAKE_PREFIX_PATH or set
  "CycloneDDS_DIR" to a directory containing one of the above files.  If
  "CycloneDDS" provides a separate development package or SDK, be sure it has
  been installed.

[6]の記事の「Troubleshooting_1」より以下のコマンドを実行することで解決できました。

sudo apt install ros-foxy-rmw-cyclonedds-cpp

Server in ROS 2 環境構築におけるエラー2

上記の「Server in ROS 2 環境構築におけるエラー1」の解決をした後に再度colcon build --symlink-installを実行したところ以下のエラーが出ました。

エラー2
--- stderr: rmf_building_sim_gazebo_plugins
CMake Error at CMakeLists.txt:25 (find_package):
  By not providing "Findgazebo_dev.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "gazebo_dev", but CMake did not find one.

  Could not find a package configuration file provided by "gazebo_dev" with
  any of the following names:

    gazebo_devConfig.cmake
    gazebo_dev-config.cmake

  Add the installation prefix of "gazebo_dev" to CMAKE_PREFIX_PATH or set
  "gazebo_dev_DIR" to a directory containing one of the above files.  If
  "gazebo_dev" provides a separate development package or SDK, be sure it has
  been installed.

[7]を参考に以下のコマンドを実行することで解決できました。(ただ、参考にした記事の中では解決できなかったようです。。)

sudo apt install ros-foxy-gazebo-ros-pkgs

Server in ROS 2 環境構築におけるエラー3

上記の「Server in ROS 2 環境構築におけるエラー2」の解決をした後に再度colcon build --symlink-installを実行したところ以下のエラーが出ました。

エラー3
--- stderr: rmf_fleet_adapter_python
CMake Error at CMakeLists.txt:32 (find_package):
  By not providing "Findpybind11_vendor.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "pybind11_vendor", but CMake did not find one.

  Could not find a package configuration file provided by "pybind11_vendor"
  with any of the following names:

    pybind11_vendorConfig.cmake
    pybind11_vendor-config.cmake

  Add the installation prefix of "pybind11_vendor" to CMAKE_PREFIX_PATH or
  set "pybind11_vendor_DIR" to a directory containing one of the above files.
  If "pybind11_vendor" provides a separate development package or SDK, be
  sure it has been installed.

[8]の記事より以下のコマンドを実行することで解決できました。

sudo apt-get install ros-foxy-pybind11-vendor

これを実行した後に再度colcon build --symlink-installしたところ、エラーなくbuildを終えることができました。

Client in ROS 環境構築の構築方法

Client in ROS 環境構築については上記の「私の環境での解決方法」において示した。以下のコマンドを実行することでエラーなく終了できました。

mkdir -p ~/Work/open-rmf/free_fleet/ros1/src
cd ~/Work/open-rmf/free_fleet/ros1/src
git clone https://github.com/open-rmf/free_fleet -b main
git clone https://github.com/eclipse-cyclonedds/cyclonedds -b releases/0.7.x
git clone https://github.com/osrf/free_fleet -b fix/focal-docs
git clone https://github.com/eclipse-cyclonedds/cyclonedds
git clone https://github.com/rhaschke/robot_state_publisher -b noetic-devel
git clone https://github.com/aaronchongth/turtlebot3 -b noetic-devel
git clone https://github.com/aaronchongth/turtlebot3_simulations -b noetic-devel
sudo apt install ros-noetic-gazebo-ros-pkgs ros-noetic-dwa-local-planner
cd ..
rosdep install --from-paths src --ignore-src --rosdistro noetic -yr
source /opt/ros/noetic/setup.bash
colcon build --symlink-install

再構築におけるまとめ

上記の方法で環境構築し、シミュレーションを実行したところ、問題なくFree Fleet経由でturtlebot3が制御できることを確認できました。また最初の構築の際はできなかったrvizを介して「fleet名に"turtelbot3"として、robot名に'tb3_0'、'tb3_1'、'tb3_2'のいずれかを記載して、2D NavGoalを設定します。「Send Nav Goal」ボタンを押下すると、指定したロボットが動き出します。」ということもできるようになりました。

参考記事やサイト

[1]ロボット群制御:環境構築 〜 ROS/ROS 2混在環境で、Open-RMFを使って複数のturtlebot3を動かしてみた
[2]WSL2のインストールを分かりやすく解説【Windows10/11】
[3]Windows11ではWSL2のGUI表示にXサーバー使わなくていいってほんまか!?
[4]WSL 2上のUbuntuでNVIDIAのGPUを有効にする方法
[5]Multi Turtlebot3 Simulation error #60
[6]Open-RMFを使って群制御をやってみる
[7]Error colcon build ROS2 (HELP)
[8]Can't find pybind11_vendor package #33

関連記事

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