Sensor Fusion

Last week I worked on the 3D representation of the sailboat, there are still some issues to iron out. Below is a video of the sensor fusion in action (this is from an earlier model I worked on):

The boat has a 3-axis accelerometer, 3-axis gyroscope and 3-axis compass. It's all contained in one chip, the MPU9250.

The Accelerometer

The 3-axis accelerometer gives you information about which way gravity points, in 3-dimensions. This means that it's possible to know which way is up and how much of a lean the boat is on. The accelerometer will also let you know if the boat is speeding up or slowing down, how it's bobbing in the water, etc. However, the accelerometer is very noisy, which means that the values it gives changes a lot and it is hard to make sense of it. It can change a few degrees a few times a second. It is possible to average out these values and get the mean value, but there are better ways (read on).

The Gyroscope

The 3-axis gyroscope lets you know which way the boat is turning, in 3 dimensions. Is it turning around the vertical axis (turning around) or around the forward/back horizontal axis (leaning over). When the gyroscope produces zero values it means there is no rotation happening.

The Magnetometer

The 3-axis magnetometer is a magnetic flux meter, or better known as a compass. It lets us know which direction magnetic north lies, however, magnetic north is not true north. The magnetic poles of Earth are not at the exact geographic north and south. To make things more complicated, magnetic north changes over time, but slowly. We need to know the magnetic declination, this is the difference between true north and magnetic north, and then we can calculate true north. The declination depends on your position too. We use a package call geomagnetism to do this, it allows for a changing magnetic field.

GPS

The GPS is not part of the MPU9250 chip, but we use the SIM28 chip which provides GPS information, at up to 10 position values per second. This gives us position, velocity and direction information.

Sensor Fusion

All these sensors mentioned above are very noisy, so the values they produce fluctuate a lot, some more than others. They also provide 13 points of information, 9 points from the MPU9250 and position, velocity and heading (4 points) from the GPS unit. However, we only want attitude, position, heading and velocity.

  • Attitude: This describes the orientation, up/down, left/right and back/forward lean, and direction. 4 points of information, which is representation in one 4 dimensional object called a quaternion.
  • Position, heading and velocity: provided by the GPS, but we need to smooth the data points.

Putting all this information together is called Sensor Fusion, in this case it's often referred to INS/GPS sensor fusion. A popular algorithm to use is the Madgick AHRS algorithm, which is what I have used, but is currently giving funny results.

Next

I hope to fix the sensor fusion information and provide a clear representation in CesiumJS. I will publish screenshots of this next week.