バージョンはMelodic
基本はgmappingでこれは簡単に動かせる。
以下が見やすい。
あ、geometry2をそのまま持ってくるとrvizが起動できなくなりました。
以下のようなエラーがでる。
$ rviz [ INFO] [1590325929.898961066]: rviz version 1.13.9 [ INFO] [1590325929.899033435]: compiled against Qt version 5.9.5 [ INFO] [1590325929.899054071]: compiled against OGRE version 1.9.0 (Ghadamon) [ INFO] [1590325929.903039046]: Forcing OpenGl version 0. [ INFO] [1590325930.000721555]: Stereo is NOT SUPPORTED [ INFO] [1590325930.000795105]: OpenGl version: 3 (GLSL 1.3). rviz: symbol lookup error: /opt/ros/melodic/lib/libtf.so: undefined symbol: _ZN7tf2_ros17TransformListenerC1ERN3tf210BufferCoreERKN3ros10NodeHandleEb
ブランチを指定します。
$ git clone -b melodic-devel https://github.com/ros/geometry2.git
あとは必要なパッケージをインストールします。
$ sudo apt install ros-melodic-cartographer ros-melodic-cartographer-ros ros-melodic-cartographer-ros-msgs ros-melodic-cartographer-rviz
gazeboで動かす
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch $ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
gmappingでなくcartographerで動かしたいときは以下のように実行すればいいのですが、そのまま実行するとエラーがでる。
$ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer [ INFO] [1588424028.931538240, 483.493000000]: I0502 21:53:48.000000 3089 map_builder_bridge.cc:130] Added trajectory with ID '0'. F0502 21:53:49.179692 3089 sensor_bridge.cc:126] Check failed: sensor_to_tracking->translation().norm() < 1e-5 The IMU frame must be colocated with the tracking frame. Transforming linear acceleration into the tracking frame will otherwise be imprecise. [FATAL] [1588424029.180452373, 483.544000000]: F0502 21:53:49.000000 3089 sensor_bridge.cc:126] Check failed: sensor_to_tracking->translation().norm() < 1e-5 The IMU frame must be colocated with the tracking frame. Transforming linear acceleration into the tracking frame will otherwise be imprecise.
turtlebot3_lds_2d.luaを編集する。
$ roscd turtlebot3_slam $ gedit config/turtlebot3_lds_2d.lua
tracking_frameをbase_footprintにする。
turtlebot3_lds_2d.lua
-- tracking_frame = "imu_link", tracking_frame = "base_footprint",
これで再度実行すればcartographerができる。
参考
http://emanual.robotis.com/docs/en/platform/turtlebot3/slam/
https://github.com/cartographer-project/cartographer_ros/issues/278