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
Diff: IMU/IMU_10DOF.cpp
- Revision:
- 4:f62337b907e5
- Parent:
- 1:798db5deb8b9
diff -r 6dbefedce7fe -r f62337b907e5 IMU/IMU_10DOF.cpp --- a/IMU/IMU_10DOF.cpp Tue Aug 27 22:18:25 2013 +0000 +++ b/IMU/IMU_10DOF.cpp Thu Aug 29 13:52:30 2013 +0000 @@ -1,17 +1,18 @@ #include "IMU_10DOF.h" -IMU_10DOF::IMU_10DOF(PinName sda, PinName scl) : Gyro(sda, scl), Acc(sda, scl), Comp(sda, scl) +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; + + angle = Filter.angle; // initialize array pointer LocalTimer.start(); } -void IMU_10DOF::read() +void IMU_10DOF::readAngles() { time_for_dt_sensors = LocalTimer.read(); // start time for measuring sensors Gyro.read(); // reading sensor data @@ -24,4 +25,12 @@ 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; } \ No newline at end of file