turtlebot3 cartographer issue resolved
===
**2018.06.04**
#### issue
```txt=
cartographer_node is not publishing 'map' tf frame. Fixed frame map does not exist.
```
and the rviz show :confused:

and thanks **Pyo** patiently help [here](https://github.com/ROBOTIS-GIT/turtlebot3/issues/217).
#### how I resolve it
I am not quite sure the precise cause, this is what I did.
* update burger firmware to 1.2.0
https://discourse.ros.org/t/turtlebot3-software-and-firmware-update-and-waffle-pi/3729
Open Arduino -> Toos -> Board: -> Board Manager… -> Update (v 1.2.0)
* get the latest 1.0.0 turtlebot3_msgs, turtlebot3 both on Pi3 and Remote PC
* update my ROS tf, tf2 dependency both on Pi3 and remote PC
`sudo apt install ros-kinetic-tf ros-kinetic-tf2-ros ros-kinetic-tf2-eigen ros-kinetic-tf2-geometry-msgs ros-kinetic-tf2-msgs ros-kinetic-tf2-py`
(no ros-kinetic-tf2-kdl)

the left side is my Remote PC, right side is pi3
and it might get the error issue, use Pyo's trick
`sudo apt autoremove`
* clone latest cartographer cartographer_ros
mine is 2018.05.30
```bash=
# Install wstool and rosdep.
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
# Create a new workspace in 'catkin_ws'.
mkdir catkin_ws
cd catkin_ws
wstool init src
# Install deb dependencies.
rosdep init
rosdep update
git clone https://github.com/googlecartographer/cartographer.git
git clone https://github.com/googlecartographer/cartographer_ros.git
# Build and install.
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash
```
And it did the magic:tada::tada::tada:

### how to fly
[RemotePC] roscore
[SBC] roslaunch turtlebot3_bringup turtlebot3_robot.launch
[RemotePC] roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer
:smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley:
### However, I found a further interesting things
#### issue2
after running 5 minutes cartographer just stuck


the error not always shows the same
ordered_multi_queue.cc:112
pose_extrapolator.cc:229
```txt=
[FATAL] [1507223671.436118945, 1973.952602303]: F1005 13:14:31.000000 14212 ordered_multi_queue.cc:112] Check failed: last_dispatched_time_ <= next_data->GetTime() (621355987737883506 vs. 621355987737746267) Non-sorted data added to queue: '(0, scan)'
[FATAL]F0603 21:13:46.346758 10430 pose_extrapolator.cc:229] Check failed: time >= imu_tracker->time() (636636284263617193 vs. 636636284263622433)
```
After dig into cartographer discussion group
https://groups.google.com/forum/#!topic/google-cartographer/6v_I6nxTozQ
https://groups.google.com/forum/m/#!topic/google-cartographer/V55Ss5UNzog
### It is because sensor delivered data out of order
firstly see rqt_graph from Pyo, /scan /odom /flat_imu may cause this

several test, I believe it's IMU data time reverse
And found someone with tb3 has same issue
https://github.com/googlecartographer/cartographer/issues/1120
one way is to downsample IMU rate
~/cartographer/catkin_ws/src/turtlebot3/turtlebot3_slam/config/turtlebot3_lds_2d.lua
`imu_sample_rate value to 0.1`
[ref2](https://github.com/googlecartographer/cartographer/issues/579)
It is not desired
And I don't know the way to check arduino turtlebot3_core IMU published is in the order(I think it is, I cannot figure out other way to write it.)
The intersting things is I found out why need **flat_world_imu node**
### It is a filter to make IMU data follow time sequence
you can see the comment here
https://github.com/googlecartographer/cartographer_turtlebot/blob/master/cartographer_turtlebot/cartographer_turtlebot/flat_world_imu_node_main.cc#L41

inside turtlebot3 code
### wrap up
use `flat_node_imu` to drop the out of order time sequence IMU message, because cartographer would check the sequence.(gmmaping do not check this)
but I still get an error after running 5~10min cartographer.
For Issue one (original) It may happen to user that get TB3 2017 june-july, and not yet update the firmware and tf dependency.(Thanks for the tb3!)
One way is to have a launch file without IMU may do the trick. (cartographer with imu or without imu the performance benchmark)
I would like to have further test.
###### tags: `turtlebot3` `cartographer`