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@1:798db5deb8b9, 2013-08-27 (annotated)
- Committer:
- maetugr
- Date:
- Tue Aug 27 22:01:10 2013 +0000
- Revision:
- 1:798db5deb8b9
- Child:
- 4:f62337b907e5
All in an IMU_10DOF class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 1:798db5deb8b9 | 1 | #include "IMU_10DOF.h" |
maetugr | 1:798db5deb8b9 | 2 | |
maetugr | 1:798db5deb8b9 | 3 | IMU_10DOF::IMU_10DOF(PinName sda, PinName scl) : Gyro(sda, scl), Acc(sda, scl), Comp(sda, scl) |
maetugr | 1:798db5deb8b9 | 4 | { |
maetugr | 1:798db5deb8b9 | 5 | dt = 0; |
maetugr | 1:798db5deb8b9 | 6 | dt_sensors = 0; |
maetugr | 1:798db5deb8b9 | 7 | time_for_dt = 0; |
maetugr | 1:798db5deb8b9 | 8 | time_for_dt_sensors = 0; |
maetugr | 1:798db5deb8b9 | 9 | angle = Filter.angle; |
maetugr | 1:798db5deb8b9 | 10 | |
maetugr | 1:798db5deb8b9 | 11 | LocalTimer.start(); |
maetugr | 1:798db5deb8b9 | 12 | } |
maetugr | 1:798db5deb8b9 | 13 | |
maetugr | 1:798db5deb8b9 | 14 | void IMU_10DOF::read() |
maetugr | 1:798db5deb8b9 | 15 | { |
maetugr | 1:798db5deb8b9 | 16 | time_for_dt_sensors = LocalTimer.read(); // start time for measuring sensors |
maetugr | 1:798db5deb8b9 | 17 | Gyro.read(); // reading sensor data |
maetugr | 1:798db5deb8b9 | 18 | Acc.read(); |
maetugr | 1:798db5deb8b9 | 19 | Comp.read(); |
maetugr | 1:798db5deb8b9 | 20 | dt_sensors = LocalTimer.read() - time_for_dt_sensors; // stop time for measuring sensors |
maetugr | 1:798db5deb8b9 | 21 | |
maetugr | 1:798db5deb8b9 | 22 | // meassure dt for the filter |
maetugr | 1:798db5deb8b9 | 23 | dt = LocalTimer.read() - time_for_dt; // time in s since last loop |
maetugr | 1:798db5deb8b9 | 24 | time_for_dt = LocalTimer.read(); // set new time for next measurement |
maetugr | 1:798db5deb8b9 | 25 | |
maetugr | 1:798db5deb8b9 | 26 | Filter.compute(dt, Gyro.data, Acc.data, Comp.data); |
maetugr | 1:798db5deb8b9 | 27 | } |