Saturday, June 15, 2013

Arduino based Inertial Navigation System - first steps


So, this weekend I've started working on a simple, Arduino-based Inertial Navigation System.
Using accelerometers and gyroscopes it is possible to calculate the traveled distance and the direction, from a known startpoint. The main problem of this method is that to get these distances, you have to perform integrations of the accelerations. Integration means that also every little error in measurement will be integrated, so they add up over time and the accuracy gets worse and worse. Therefore you need very good sensors and smart algorithms, being the reason why professional systems are expensive.

A constant error ...
integrated over time twice ...
leads to an increasing error.
For this cheap and easy project I use cheap sensors and easy algorithms, so the whole system will be very inaccurate. Nevertheless, I think it will be useful for me to learn, and for others running into similar  problems that I will have to solve. Also, the functions can be expanded, adding logging, additional sensors and a GPS-module, making it a combined navigation system.
These are my first steps and far from a finished project. Right now I'm basically just reading the sensor data.


Parts on breadboard.
My desk is actually white.
  1. Arduino Uno [info@arduino]
  2. MPU6050 Breakout Board [info@sainsmart]
  3. LEDs, resistors, switches, etc.
There are different MPU6050 Breakout Boards and I guess you could use all of them the same way. It combines a 3-axis accelerometer and a 3-axis gyroscope, so it provides all neccessary data for 3D-navigation.

First breadboard test

Breadboard drawn with fritzing.
I used this how-to to learn how to hook up the MPU6050.
      • MPU6050 / Arduino Uno
      • VCC / 3V3
      • GND / GND
      • SCL / A5
      • SDA / A4

Arduino sketch

To read the sensor data, I used i2cdevlib from jrowberg and the SainSmart tutorial, where you can find the MPU6050 library.
The first sketch just reads the sensor data and stores the acceleration in x-direction it in the EEPROM. The EEPROM can store 1024 bytes. That means it can store 1024 numbers between 0 and 255. The sensor data come as integers, ranging from −32,768 to 32,767, so the value has to be divided and shifted. After the button is pressed, data is logged for 10 seconds with 100Hz.
The second sketch reads the data from the EEPROM and prints it to the serial monitor. From there I copied the data into a .txt-file, which I processed and visualized using a simple Python-script.
At first, the sensor was upside down, resulting in -1g, then turned around, 1g, and then yanked around a little.

Next steps

  • find a algorithm to integrate the sensor values
  • add a micro-SD card reader for data logging
  • add a magnetic sensor to find north
  • add a barometric sensor to get the heigth
I will host the whole project on github and post what's going on here.