asdf
Dependencies: L3GD20 LSM303DLHC mbed
Headers/Sensors.h@4:ecfe2115e9a4, 2014-04-03 (annotated)
- Committer:
- goy5022
- Date:
- Thu Apr 03 17:34:00 2014 +0000
- Revision:
- 4:ecfe2115e9a4
- Parent:
- 3:1a8a7cc709cc
- Child:
- 5:9e504a5a1f48
pid works great and it's not messed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
goy5022 | 0:c2ec30f28676 | 1 | #ifndef SENSORS_H |
goy5022 | 0:c2ec30f28676 | 2 | #define SENSORS_H |
goy5022 | 0:c2ec30f28676 | 3 | |
goy5022 | 2:997f57aee3b7 | 4 | //#include "Core.h" |
goy5022 | 2:997f57aee3b7 | 5 | |
goy5022 | 2:997f57aee3b7 | 6 | #include "ExponentialAverage.h" |
goy5022 | 0:c2ec30f28676 | 7 | #include "L3GD20.h" |
goy5022 | 0:c2ec30f28676 | 8 | #include "LSM303DLHC.h" |
goy5022 | 0:c2ec30f28676 | 9 | |
goy5022 | 2:997f57aee3b7 | 10 | |
goy5022 | 2:997f57aee3b7 | 11 | float ax, ay, az; |
goy5022 | 2:997f57aee3b7 | 12 | float mx, my, mz; |
goy5022 | 2:997f57aee3b7 | 13 | float gx, gy, gz; |
goy5022 | 2:997f57aee3b7 | 14 | |
goy5022 | 0:c2ec30f28676 | 15 | L3GD20 gyro(p9, p10); |
goy5022 | 0:c2ec30f28676 | 16 | LSM303DLHC compass(p9, p10); |
goy5022 | 1:cfe6a6ad8dca | 17 | PwmOut ledF(p23); |
goy5022 | 1:cfe6a6ad8dca | 18 | PwmOut ledR(p21); |
goy5022 | 1:cfe6a6ad8dca | 19 | PwmOut ledL(p22); |
goy5022 | 1:cfe6a6ad8dca | 20 | AnalogIn SenseR(p15); |
goy5022 | 1:cfe6a6ad8dca | 21 | AnalogIn SenseL(p16); |
goy5022 | 1:cfe6a6ad8dca | 22 | AnalogIn SenseF(p17); |
goy5022 | 3:1a8a7cc709cc | 23 | bool wallfront = false; |
goy5022 | 3:1a8a7cc709cc | 24 | bool wallright = false; |
goy5022 | 3:1a8a7cc709cc | 25 | bool wallleft = false; |
goy5022 | 4:ecfe2115e9a4 | 26 | float cal_R =0, cal_L =0, cal_F =0; |
goy5022 | 2:997f57aee3b7 | 27 | |
goy5022 | 2:997f57aee3b7 | 28 | |
goy5022 | 2:997f57aee3b7 | 29 | bool wallFront() |
goy5022 | 2:997f57aee3b7 | 30 | { |
goy5022 | 2:997f57aee3b7 | 31 | return frontExpAvg.average() > .90; |
goy5022 | 2:997f57aee3b7 | 32 | } |
goy5022 | 2:997f57aee3b7 | 33 | bool wallLeft() |
goy5022 | 1:cfe6a6ad8dca | 34 | { |
goy5022 | 4:ecfe2115e9a4 | 35 | return abs(log(1-SenseL.read())) < 5; |
goy5022 | 1:cfe6a6ad8dca | 36 | } |
goy5022 | 2:997f57aee3b7 | 37 | bool wallRight() |
goy5022 | 2:997f57aee3b7 | 38 | { |
goy5022 | 4:ecfe2115e9a4 | 39 | return abs(log(1-SenseR.read())) < 5; |
goy5022 | 2:997f57aee3b7 | 40 | } |
goy5022 | 4:ecfe2115e9a4 | 41 | void check_walls() |
goy5022 | 4:ecfe2115e9a4 | 42 | { |
goy5022 | 4:ecfe2115e9a4 | 43 | wallLeft(); |
goy5022 | 4:ecfe2115e9a4 | 44 | wallRight(); |
goy5022 | 4:ecfe2115e9a4 | 45 | wallFront(); |
goy5022 | 4:ecfe2115e9a4 | 46 | |
goy5022 | 4:ecfe2115e9a4 | 47 | } |
goy5022 | 0:c2ec30f28676 | 48 | #endif |