2
1
記事投稿キャンペーン 「2024年!初アウトプットをしよう」

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

Last updated at Posted at 2024-01-14

1. はじめに

先日の投稿では、[1]の記事を参考に、Free Fleet ServerとOpen-RMFを接続し、turtlebot3の制御を試み、現在地の取得まで成功しました。しかし、その際は移動の指示を与えてもturtlebot3が反応しませんでした。その後、Open-RMFを介してturtlebot3を動かすことに焦点を当て、問題の原因を調査しましたところ、原因を特定でき、解決することができました。この記事では、その具体的な手順や解決方法について紹介していきます。

2. 実行環境

  • CPU: CORE i7 7th Gen
  • メモリ: 32GB
  • GPU: GeForce RTX 2070
  • OSと構築した環境: Window11でWSL2にUbuntu20.04をインストールした環境
  • ROS: ROS/ROS 2の混在環境で、ROSは Noetic, ROS 2はFoxy

3. どのように解決したか

3.1 house.launch.xmlについて

先日の投稿の4章実行のところで、以下のように実行しますhouse.launch.xmlについてです。

terminal(4)
cd ~/Work/open-rmf/free_fleet/ros2
source install/setup.bash
ros2 launch rmf_demos house.launch.xml

house.launch.xmlはoffice.launch.xml[2]をベースに以下のように作成しました。office.launch.xmlの内容から修正したところや重要だと思うところにはコメントを入れています。なお、先日の投稿でturtlebot3が動かなかった一番大きな原因はuse_sim_timeがfalseのままになっていたことでした!!ここをtrueにする必要がありました。

作成したhouse.launch.xml
<?xml version='1.0' ?>

<launch>
  <arg name="use_sim_time" default="true"/> <!--ここがoffice.launchではfalseになっているのでtrueにする -->
  <arg name="failover_mode" default="false"/>

  <!-- Common launch -->
  <include file="$(find-pkg-share rmf_demos)/common.launch.xml">
    <arg name="use_sim_time" value="$(var use_sim_time)"/>
    <arg name="viz_config_file" value ="$(find-pkg-share rmf_demos)/include/house/house.rviz"/><!--ここは今回の環境用に後述するrvizファイルを作成したので反映 -->
    <arg name="config_file" value="$(find-pkg-share rmf_demos_maps)/house/house.building.yaml"/><!--traffic editorで作成したhouse.building.yamlの保存先を反映 -->
    <arg name="dashboard_config_file" value="$(find-pkg-share rmf_demos_dashboard_resources)/office/dashboard_config.json"/><!--ここはそのまま流用しました -->
  </include>

  <group>
    <let name="fleet_name" value="turtlebot3"/><!--fleet_nameは turtlebot3に設定-->
    <include file="$(find-pkg-share rmf_demos)/include/adapters/turtlebot3_adapter.launch.xml"><!--ここは今回の環境用に後述するadapter.launch.xmlファイルを作成したので反映 -->
      <arg name="fleet_name" value="$(var fleet_name)"/>
      <arg name="use_sim_time" value="$(var use_sim_time)"/>
      <arg name="nav_graph_file" value="$(find-pkg-share rmf_demos_maps)/maps/house/nav_graphs/0.yaml" /><!--buildしたら生成されるnav_graphs/0.yamlの保存先を反映 -->
    </include>
    <include file="$(find-pkg-share rmf_fleet_adapter)/robot_state_aggregator.launch.xml">
      <arg name="robot_prefix" value="tb3_"/><!--frobot_prefixは tb3_に設定-->
      <arg name="fleet_name" value="$(var fleet_name)"/>
      <arg name="use_sim_time" value="$(var use_sim_time)"/>
      <arg name="failover_mode" value="$(var failover_mode)"/>
    </include>
  </group>

</launch>

3.2 house.rvizについて

house.launch.xmlで読み込まれるhouse.rvizについてはoffice.rviz[3]をベースに作成しました。修正をしたところにはコメントを入れています。Map名を今回の環境に合わせてhouseとしただけで、office.rvizをほぼそのまま流用しました。

作成したhouse.rviz
Panels:
  - Class: rviz_common/Displays
    Help Height: 138
    Name: Displays
    Property Tree Widget:
      Expanded:
        - /MarkerArray3/Topic1
        - /MarkerArray4/Topic1
      Splitter Ratio: 0.5
    Tree Height: 270
  - Class: rviz_common/Selection
    Name: Selection
  - Class: rviz_common/Tool Properties
    Expanded:
      - /2D Goal Pose1
      - /Publish Point1
    Name: Tool Properties
    Splitter Ratio: 0.5886790156364441
  - Class: rviz_common/Views
    Expanded:
      - /Current View1
    Name: Views
    Splitter Ratio: 0.5
  - Class: rmf_visualization_rviz2_plugins/SchedulePanel
    Finish: 600
    Map: house (ここだけ修正!!)
    Name: SchedulePanel
    Topic: /rmf_visualization/parameters
  - Class: rmf_visualization_rviz2_plugins/DoorPanel
    Name: DoorPanel
Visualization Manager:
  Class: ""
  Displays:
    - Alpha: 0.5
      Cell Size: 1
      Class: rviz_default_plugins/Grid
      Color: 160; 160; 164
      Enabled: false
      Line Style:
        Line Width: 0.029999999329447746
        Value: Lines
      Name: Grid
      Normal Cell Count: 0
      Offset:
        X: 0
        Y: 0
        Z: 0
      Plane: XY
      Plane Cell Count: 10
      Reference Frame: <Fixed Frame>
      Value: false
    - Class: rviz_default_plugins/MarkerArray
      Enabled: true
      Name: MarkerArray
      Namespaces:
        fleet_markers: true
      Topic:
        Depth: 5
        Durability Policy: Volatile
        History Policy: Keep Last
        Reliability Policy: Reliable
        Value: /fleet_markers
      Value: true
    - Class: rviz_default_plugins/MarkerArray
      Enabled: true
      Name: MarkerArray
      Namespaces:
        participant 0: true
        participant location 0: true
      Topic:
        Depth: 5
        Durability Policy: Volatile
        History Policy: Keep Last
        Reliability Policy: Reliable
        Value: /schedule_markers
      Value: true
    - Class: rviz_default_plugins/MarkerArray
      Enabled: true
      Name: MarkerArray
      Namespaces:
        labels: true
        map: true
      Topic:
        Depth: 5
        Durability Policy: Transient Local
        History Policy: Keep Last
        Reliability Policy: Reliable
        Value: /map_markers
      Value: true
    - Class: rviz_default_plugins/MarkerArray
      Enabled: true
      Name: MarkerArray
      Namespaces:
        coe_door: true
        coe_door_text: true
        hardware_door: true
        hardware_door_text: true
        main_door: true
        main_door_text: true
      Topic:
        Depth: 5
        Durability Policy: Transient Local
        History Policy: Keep Last
        Reliability Policy: Reliable
        Value: /building_systems_markers
      Value: true
    - Alpha: 0.7
      Class: rviz_default_plugins/Map
      Color Scheme: map
      Draw Behind: true
      Enabled: true
      Name: Map
      Topic:
        Depth: 5
        Durability Policy: Transient Local
        History Policy: Keep Last
        Reliability Policy: Reliable
        Value: /floorplan
      Update Topic:
        Depth: 5
        Durability Policy: Transient Local
        History Policy: Keep Last
        Reliability Policy: Reliable
        Value: /floorplan_updates
      Use Timestamp: false
      Value: true      
  Enabled: true
  Global Options:
    Background Color: 48; 48; 48
    Fixed Frame: map
    Frame Rate: 30
  Name: root
  Tools:
    - Class: rviz_default_plugins/Interact
      Hide Inactive Objects: true
    - Class: rviz_default_plugins/MoveCamera
    - Class: rviz_default_plugins/Select
    - Class: rviz_default_plugins/FocusCamera
    - Class: rviz_default_plugins/Measure
      Line color: 128; 128; 0
    - Class: rviz_default_plugins/SetInitialPose
      Topic:
        Depth: 5
        Durability Policy: Volatile
        History Policy: Keep Last
        Reliability Policy: Reliable
        Value: /initialpose
    - Class: rviz_default_plugins/SetGoal
      Topic:
        Depth: 5
        Durability Policy: Volatile
        History Policy: Keep Last
        Reliability Policy: Reliable
        Value: /goal_pose
    - Class: rviz_default_plugins/PublishPoint
      Single click: true
      Topic:
        Depth: 5
        Durability Policy: Volatile
        History Policy: Keep Last
        Reliability Policy: Reliable
        Value: /clicked_point
  Transformation:
    Current:
      Class: rviz_default_plugins/TF
  Value: true
  Views:
    Current:
      Angle: 0
      Class: rviz_default_plugins/TopDownOrtho
      Enable Stereo Rendering:
        Stereo Eye Separation: 0.05999999865889549
        Stereo Focal Distance: 1
        Swap Stereo Eyes: false
        Value: false
      Invert Z Axis: false
      Name: Current View
      Near Clip Distance: 0.009999999776482582
      Scale: 95.94175720214844
      Target Frame: <Fixed Frame>
      Value: TopDownOrtho (rviz_default_plugins)
      X: 14.163299560546875
      Y: -7.102552890777588
    Saved: ~
Window Geometry:
  Displays:
    collapsed: false
  DoorPanel:
    collapsed: false
  Height: 1726
  Hide Left Dock: false
  Hide Right Dock: true
  QMainWindow State: 000000ff00000000fd00000004000000000000033400000622fc0200000009fb0000001200530065006c0065006300740069006f006e00000001e10000009b000000b000fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073000000006e000001910000018200fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fc0000006e000006220000062201000039fa000000020100000003fb0000001a005300630068006500640075006c006500500061006e0065006c0100000000ffffffff0000028300fffffffb000000120044006f006f007200500061006e0065006c0100000000ffffffff0000029300fffffffb000000120052004d0046002000500061006e0065006c0100000000000003340000033400ffffff000000010000015f00000765fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000006e000007650000013200fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000006440000062200000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
  SchedulePanel:
    collapsed: false
  Selection:
    collapsed: false
  Tool Properties:
    collapsed: false
  Views:
    collapsed: true
  Width: 2436
  X: 4064
  Y: 116

3.3 turtlebot3_adapter.launch.xmlについて

house.launch.xmlで読み込まれるturtlebot3_adapter.launch.xmlについてはtinyRobot_adapter.launch.xml[4]をベースにTurtleBot3のHPを参考に以下のように作成しました。
今回の目的はOpen-RMFを介してturtlebot3を動かしてみるということだったので、turtlebot3のスペックを私はあまり反映しませんでした(悪く言うと適当です)。 とりあえず私が修正した中で重要だと思う部分についてはコメントを入れました。特に、tinyRobot_adapter.launch.xmlではuse_sim_timeがfalseになっていましたので、ここをtrueにする必要がありました。

作成したturtlebot3_adapter.launch.xml
<?xml version='1.0' ?>

<launch>

  <arg name="fleet_name" default="turtlebot3" description="Name of this fleet of turtlebot3 robots"/><!--fleet_nameをturtlebot3に修正-->
  <arg name="use_sim_time" default="true" description="Use the /clock topic for time to sync with simulation"/><!--use_sim_timeをtrueに修正-->
  <arg name="nav_graph_file" description="Nav graph required by fleet adapter"/>

  <group>
    <include file="$(find-pkg-share rmf_fleet_adapter)/fleet_adapter.launch.xml">

      <!-- The name and control type of the fleet -->
      <arg name="fleet_name" value="$(var fleet_name)"/>
      <arg name="control_type" value="full_control"/>

      <!-- The graph that this fleet should use for navigation -->
      <arg name="nav_graph_file" value="$(var nav_graph_file)" />

      <!-- The nominal linear and angular velocity of this fleet's vehicles -->
      <arg name="linear_velocity" value="0.15"/>
      <arg name="angular_velocity" value="0.75"/>

      <!-- The nominal linear and angular acceleration of this fleet's vehicles -->
      <arg name="linear_acceleration" value="0.1"/>
      <arg name="angular_acceleration" value="0.1"/>

      <!-- The radius of the circular footprint of this fleet's vehicles -->
      <arg name="footprint_radius" value="0.105"/>
      <!-- Other robots are not allowed within this radius --> 
      <arg name="vicinity_radius" value="0.15"/>

      <!-- Whether to use sim time -->
      <arg name="use_sim_time" value="$(var use_sim_time)"/>

      <!-- How long it can be delayed before we give up and start over -->
      <arg name="delay_threshold" value="15.0"/>

      <!-- Don't make the tinyRobot wait long to retry -->
      <arg name="retry_wait" value="10.0"/>

      <!-- Give everything time to discover -->
      <arg name="discovery_timeout" value="60.0"/>

      <!-- Can the robot drive backwards -->
      <arg name="reversible" value="true"/>

      <!-- Whether it can perform deliveries -->
      <arg name="perform_deliveries" value="false"/>
      <!-- Whether it can perform loop -->
      <arg name="perform_loop" value="true"/>
      <!-- Whether it can perform cleaning -->
      <arg name="perform_cleaning" value="false"/>
      <!-- What the robot should do once it finishes its tasks -->
      <arg name="finishing_request" value="nothing"/>

      <!-- TODO Update these values with actual specs -->
      <!-- Battery parameters -->
      <arg name="battery_voltage" value="11.1"/>
      <arg name="battery_capacity" value="19.98"/>
      <arg name="battery_charging_current" value="1.0"/>

      <!-- Physical parameters -->
      <arg name="mass" value="1.0"/>
      <arg name="inertia" value="0.0055"/>
      <arg name="friction_coefficient" value="0.22"/>
      
      <!-- Power systems -->
      <arg name="ambient_power_drain" value="20.0"/>
      <arg name="tool_power_drain" value="0.0"/>
      
      <!-- Whether to consider battery drain for task planning -->
      <arg name="drain_battery" value="false"/>

      <!-- Battery level at which the robot ceases to operate -->
      <arg name="recharge_threshold" value="0.1"/>
      
    </include>
  </group>
</launch>

4. 実行

実行の手順は[1]の記事の「実行手順」と同じように以下のコマンドを順次実行しました。

terminal(1)
cd ~/Work/open-rmf/free_fleet/ros1
source install/setup.bash
export TURTLEBOT3_MODEL=burger; roslaunch ff_examples_ros1 multi_turtlebot3_ff.launch
terminal(2)
cd ~/Work/open-rmf/free_fleet/ros2
source install/setup.bash
ros2 launch ff_examples_ros2 turtlebot3_world_ff_server.launch.xml
terminal(3)
cd ~/Work/open-rmf/free_fleet/ros1_bridge_ws
source /opt/ros/noetic/setup.bash
source /opt/ros/foxy/setup.bash
source install/setup.bash
ros2 run ros1_bridge dynamic_bridge
terminal(4)
cd ~/Work/open-rmf/free_fleet/ros2
source install/setup.bash
ros2 launch rmf_demos house.launch.xml

これらのコマンドを実行した後に以下のコマンドで「Loop」タスクをOpen-RMFを介してturtlebot3に出しました。なお、tb3_0_start、goal8、tb3_1_start、goal13、tb3_2_start、goal7 はtraffic editorで設定したゴール地点名です。

terminal(5)
cd ~/Work/open-rmf/free_fleet/ros2
source install/setup.bash
ros2 run rmf_demos_tasks dispatch_loop -s tb3_0_start -f goal8 --use_sim_time
ros2 run rmf_demos_tasks dispatch_loop -s tb3_1_start -f goal13 --use_sim_time
ros2 run rmf_demos_tasks dispatch_loop -s tb3_2_start -f goal7 --use_sim_time

指示を出したところ今回は以下のようにturtlebot3が動き始めました。

スクリーンショット_openrmf.png

[1]の記事で「黄色の印が先行しすぎて、ピンクの印との距離が離れすぎてエラーになることがありました。」と述べられていましたが、私の方でもその事象は見られました。

5. まとめと課題

WSL2の環境でもFree Fleet ServerとOpen-RMFを接続し、複数のturtlebot3を動かすことができたと考えれらます。しかし、私の方ではまだ適切に障害物を避ける経路設定ができていないため、turtlebot3がすぐに停止してしまうという問題が起きています。また、以前の投稿で挙げた「rviz上で元の地図データが表示され、経路とのずれが目立ち見た目があまり良くない」という問題も未だに残っています。次回以降はこれらの課題に対応しつつ、より発展的なことにも挑戦できたらと考えています。

👆本件に関連してブラウザ経由でturtlebot3を制御した件を、WSL2の環境下において、Open-RMFを使って複数のturtlebot3を動かしてみた ブラウザから指示編にまとめました。

参考サイト

[1]ロボット群制御:実践編 ~ ROS/ROS 2混在環境でOpen-RMFを使って複数のturtlebot3を動かしてみた
[2]foxyのブランチのrmf_demos/rmf_demos/launch/office.launch.xml
[3]foxyのブランチのrmf_demos/launch/include/office/office.rviz
[4]foxyのブランチのrmf_demos/launch/include/adapters/tinyRobot_adapter.launch.xml

2
1
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
1