Turtlebot3のロボット/SLAM/ナビゲーション起動コマンドまとめ

スポンサーリンク

ロボット/SLAM/ナビゲーションの起動コマンドを簡単にまとめたページがほしかったので、自分でまとめてみました。

とくに注釈がなければ、各コマンドはRemotePC上で実行。
それぞれのroscore、roslaunchは別ターミナルで実行。
環境変数 TURTLEBOT3_MODEL、ROS_MASTER_URI、ROS_HOSTNAMEは設定済みという前提。

セットアップ方法

セットアップ方法は過去記事参照 www.sato-susumu.com

ロボットの起動のみ(実機)

$ roscore
[TurtleBot]実機上で実行
$ roslaunch turtlebot3_bringup turtlebot3_robot.launch

ロボットの起動のみ(シミュレーション)

$ roslaunch turtlebot3_gazebo turtlebot3_world.launch

turtlebot3_world.launchの代わりに他の内容でもOK。(後述)

rvizも立ち上げたいなら下記内容。

$ roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch

ロボットの起動のみ(RVizのみ)

Fakeノードによるロボットの起動。
RViz上にロボットが表示される。
物理シミレーションは無いので、センサーなどの内容は起動できない。

$ roslaunch turtlebot3_fake turtlebot3_fake.launch

SLAM(実機)

[TurtleBot]実機上で実行
$ roslaunch turtlebot3_bringup turtlebot3_robot.launch
$ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping

slam_methodsは、gmapping以外にもcartographer, frontier_exploration, hector, kartoなどが指定できる。
上記だけではロボットが移動しないので、移動するためには別のコマンドの実行が必要。

RViz上である程度地図ができたら、新しいターミナルで次の内容を実行。地図が保存される。

$ rosrun map_server map_saver -f ~/map

SLAM(シミュレーション)

$ roslaunch turtlebot3_gazebo turtlebot3_world.launch
$ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping

turtlebot3_world.launchの代わりに他の内容でもOK。(後述)
slam_methodsは、gmapping以外にもcartographer, frontier_exploration, hector, kartoなどが指定できる。
上記だけではロボットが移動しないので、移動するためには別のコマンドの実行が必要。

RViz上である程度地図ができたら、新しいターミナルで次の内容を実行。地図が保存される。

$ rosrun map_server map_saver -f ~/map

ナビゲーション(実機)

あらかじめ地図が「$HOME/map.yaml」に作成されている前提。

$ roscore
[TurtleBot]実機上で実行
$ roslaunch turtlebot3_bringup turtlebot3_robot.launch
$ roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/map.yaml

上記だけではロボットが移動しないので、移動するためには別のコマンドの実行するか、rviz上でゴールを設定する。

ナビゲーション(シミュレーション)

あらかじめ地図が「$HOME/map.yaml」に作成されている前提。

$ roslaunch turtlebot3_gazebo turtlebot3_world.launch
$ roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/map.yaml

turtlebot3_world.launchの代わりに他の内容でもOK。(後述)
上記だけではロボットが移動しないので、移動するためには別のコマンドの実行するか、RViz上でゴールを設定する。

移動

どんな方法で移動するかによって変わる。各コマンドは全てRemotePCで実行

キーボードで移動

$ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

USBコントローラーで移動

USBコントローラーが「/dev/input/js1」の場合の例

$ ls /dev/input/js*
$ rosrun joy joy_node _dev:=/dev/input/js1
$ roslaunch teleop_twist_joy teleop.launch

適当に移動

$ roslaunch turtlebot3_gazebo turtlebot3_simulation.launch

シミュレーション用

RVizで操作

RVizを立ち上げていればRVizでも操作できる。

  1. Panels > Add New Panelを選択
  2. rviz_plugin_tutorials > Teleopを選択し、OK
  3. Output Topicに「/cmd_vel」を入力し、リターン
  4. 操作エリアが白くなるので、マウスでドラッグ

シミュレーションの種類

turtlebot3_world.launchの代わりに次の内容でもOK。

  • turtlebot3_empty_world.launch
  • turtlebot3_house.launch
  • turtlebot3_stage_1.launch
  • turtlebot3_stage_2.launch
  • turtlebot3_stage_3.launch
  • turtlebot3_stage_4.launch
  • turtlebot3_autorace.launch

実行例:

$ roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch