
Keyglove #08 – Orientation Demo from Jeff Rowberg on Vimeo.
NOTE: For the uber-eager, the actual rotation starts at the 1:00 mark. There’s some introductory explanation of what’s happening and the hardware in use that occurs on before that.
This video is a demo of the IMU algorithm results (a.k.a. sensor fusion) achieved with SparkFun’s 6DOF motion sensor board, which uses an ADXL345 digital 3-axis accelerometer and ITG-3200 digital 3-axis gyroscope. The readings from the board are raw from each device, and combined on the Teensy++’s MCU to create a quaternion representation of the orientation.
There is a very slight delay between the physical movement and the on-screen representation, which is caused by a secondary “smoothing” filter that I hope to improve a bit. The orientation algorithm itself is very fast, but the raw data coming from the sensors is a little noisy, which is why there’s some extra filtering in place.
This data is sent over the serial connection to the InvenSense “teapot” demo (designed to be used with their MPU-6050), which I used because I knew it worked given the right input data. The MPU-6050 is capable of doing all of the complex math on the chip itself, which is way better than forcing the MCU to do it, but this is a proof of concept that shows that it can all be done right on the microcontroller. I haven’t been able to get the MPU-6050 to work perfectly yet, so I’m taking advantage of the hardware I know how to use right now—namely, the 6DOF board.
Quaternion info and the basis for the IMU filter in use came from the Madgwick report (PDF), which Fabio Varesano (@fax8) recommended to me. I don’t quite grasp all of the math involved, but I understand the basic concept of what needs to happen. That report very helpfully includes a C-optimized example program to implement both a gyro/accel IMU algorithm and a gyro/accel/compass MAGS algorithm. I’m using a slightly modified version of the IMU algorithm in this demo video. You can view the relevant Keyglove source file here.
I’m going to turn this into a simple Arduino sketch that you can use as-is with a SparkFun 6DOF board and get filtered orientation data. When that is finished, I’ll link to it from here.
With this information and a bit more math, most of which is in place, I will be able to calculate gravity-free velocity with respect to the ground, so that regardless of the orientation, the six basic directions (up, down, left, right, forward, backward) are always the same relative to a known “pointing forward” condition. As soon as that’s ready, I’ll post another video, and a follow-up post to the first one I wrote about dead reckoning.
Hey! I was wondering if you had an even semi working sketch for the teensy and MPU5060? It would be a HUGE help. 🙂
Hi Taylor!
This code library and the sketches in the /Examples folder should all work with very minimal changes (just a couple of pin assignments, maybe the LED and interrupt chosen depending on how you want to wire it up):
https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050
I don’t have anything yet that implements the Madgwick filter on the MPU-6050 using raw sensor data, but I’m sure it is possible as well.
wow! thanks for the quick reply! I actually went out and bought a Arduino uno today, and now that i see the software running i should have better luck adjusting it for the teensy.
another question though, where can I download the Teapot demo? i’ve looked around and havnt had much luck..
Hey Jeff,
So I just received the Sparkfun MPU6050 breakout board (SEN 11028). I’ve looked at the code you posted on github and I uploaded all the libraries into arduino. Right now I am playing with the IMU and trying to get the teapot demo to work but I realize I don’t even know where to start. I have the board connected to an Arduino Uno R3. I have uploaded all the libraries like your comments say and I also tried downloading processing and putting the toxiclibs library into the processing library but nothing is seeming to work. I am an amateur when it comes to electronics so any help would be appreciated.
-Josh
Hi Josh,
Basically, the Arduino example sketch should be loaded onto your board, and then you should open the Processing sketch in Processing, make sure the ToxicLibs are installed as noted in the comments in the code, and then run the Processing sketch. It will automatically use the first available COM port for communication, but if that is the wrong one, then you can modify the Processing code to use a specific port (it should match the one created by the Arduino).
You’d have to be more specific about “nothing is seeming to work” for more info…where and how does it stop behaving as expected?
Hi Jeff,
I have a problem on getting a teapot demo working. Can you explain a bit more on how to setup the teapot demo framework?
1. Win 7 64 bit, I have a problem: “serial does not run in 64 bit”
2. Win xp 32 bit, I have an error: framebuffer objects are not supported by this hardware
Your guide is appreciated.
hi Jeff,
After using processing 1.5.1 and upgrading the RXTX, it finally receiving numbers from mpu6050.
I’ve changed to COM6, which works in my laptop, it is able to receives data from my arduino 6 numbers every line.
But, the graph doesnt move and on top of the line,
“display 0 does not exist, using the default display instead”.
Would you please help me on that?
thanks in advance.