An fully working IMU-Filter and Sensor drivers for the 10DOF-Board over I2C. All in one simple class. Include, calibrate sensors, call read, get angles. (3D Visualisation code for Python also included) Sensors: L3G4200D, ADXL345, HMC5883, BMP085
IMU/IMU_10DOF.cpp
- Committer:
- maetugr
- Date:
- 2013-08-29
- Revision:
- 4:f62337b907e5
- Parent:
- 1:798db5deb8b9
File content as of revision 4:f62337b907e5:
#include "IMU_10DOF.h" IMU_10DOF::IMU_10DOF(PinName sda, PinName scl) : Gyro(sda, scl), Acc(sda, scl), Comp(sda, scl), Alt(sda,scl) { dt = 0; dt_sensors = 0; time_for_dt = 0; time_for_dt_sensors = 0; angle = Filter.angle; // initialize array pointer LocalTimer.start(); } void IMU_10DOF::readAngles() { time_for_dt_sensors = LocalTimer.read(); // start time for measuring sensors Gyro.read(); // reading sensor data Acc.read(); Comp.read(); dt_sensors = LocalTimer.read() - time_for_dt_sensors; // stop time for measuring sensors // meassure dt for the filter dt = LocalTimer.read() - time_for_dt; // time in s since last loop time_for_dt = LocalTimer.read(); // set new time for next measurement Filter.compute(dt, Gyro.data, Acc.data, Comp.data); } void IMU_10DOF::readAltitude() { Alt.read(); temperature = Alt.Temperature; // copy all resulting measurements pressure = Alt.Pressure; altitude = Alt.Altitude; }