Simple example to show how to get an estimation of the attitude with a 9DOF IMU and the Kalman filter

Dependencies:   L3GD20 LSM303DLHC mbed-dsp mbed

Fork of minimu-9v2 by brian claus

Committer:
bclaus
Date:
Thu Feb 21 00:24:06 2013 +0000
Revision:
0:4b3d36de811a
Child:
1:ba2d31e3112d
Project for testing the minimu-9 v2 by Pololu;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bclaus 0:4b3d36de811a 1 #include "mbed.h"
bclaus 0:4b3d36de811a 2 #include "L3GD20.h"
bclaus 0:4b3d36de811a 3 #include "LSM303DLHC.h"
bclaus 0:4b3d36de811a 4
bclaus 0:4b3d36de811a 5 L3GD20 gyro(p28, p27);
bclaus 0:4b3d36de811a 6 Serial debug(USBTX,USBRX);
bclaus 0:4b3d36de811a 7 LSM303DLHC compass(p28, p27);
bclaus 0:4b3d36de811a 8
bclaus 0:4b3d36de811a 9
bclaus 0:4b3d36de811a 10
bclaus 0:4b3d36de811a 11 int main() {
bclaus 0:4b3d36de811a 12 float ax, ay, az;
bclaus 0:4b3d36de811a 13 float mx, my, mz;
bclaus 0:4b3d36de811a 14 float gx, gy, gz;
bclaus 0:4b3d36de811a 15 debug.format(8,Serial::None,1);
bclaus 0:4b3d36de811a 16 debug.baud(115200);
bclaus 0:4b3d36de811a 17 debug.printf("miniimu-9 v2 Test");
bclaus 0:4b3d36de811a 18
bclaus 0:4b3d36de811a 19 while(1) {
bclaus 0:4b3d36de811a 20
bclaus 0:4b3d36de811a 21 compass.read(&ax, &ay, &az, &mx, &my, &mz);
bclaus 0:4b3d36de811a 22 gyro.read(&gx, &gy, &gz);
bclaus 0:4b3d36de811a 23 debug.printf("a %.4f %.4f %.4f m %.4f %.4f %.4f m %.4f %.4f %.4f\n\r",ax,ay,az,mx,my,mz,gx,gy,gz);
bclaus 0:4b3d36de811a 24 wait(0.05);
bclaus 0:4b3d36de811a 25 }
bclaus 0:4b3d36de811a 26 }