Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
IRSensor.cpp@1:2b5f79285a3e, 2018-04-19 (annotated)
- Committer:
- Helvis
- Date:
- Thu Apr 19 06:19:43 2018 +0000
- Revision:
- 1:2b5f79285a3e
- Child:
- 3:076dd7ec7eb4
Micromouse V0.9: Tresholds + Regler noch anpassen
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Helvis | 1:2b5f79285a3e | 1 | #include <cmath> |
| Helvis | 1:2b5f79285a3e | 2 | #include "IRSensor.h" |
| Helvis | 1:2b5f79285a3e | 3 | |
| Helvis | 1:2b5f79285a3e | 4 | using namespace std; |
| Helvis | 1:2b5f79285a3e | 5 | |
| Helvis | 1:2b5f79285a3e | 6 | IRSensor::IRSensor(AnalogIn& distance) : |
| Helvis | 1:2b5f79285a3e | 7 | distance(distance){} |
| Helvis | 1:2b5f79285a3e | 8 | |
| Helvis | 1:2b5f79285a3e | 9 | IRSensor::~IRSensor() {} |
| Helvis | 1:2b5f79285a3e | 10 | |
| Helvis | 1:2b5f79285a3e | 11 | float IRSensor::readL() { |
| Helvis | 1:2b5f79285a3e | 12 | //Links B2 |
| Helvis | 1:2b5f79285a3e | 13 | float a1 = -4.474f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 14 | float a2 = 8.415f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 15 | float a3 = -6.279f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 16 | float a4 = 2.36f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 17 | float a5 = -4670.0f; |
| Helvis | 1:2b5f79285a3e | 18 | float a6 = 445.1f; |
| Helvis | 1:2b5f79285a3e | 19 | |
| Helvis | 1:2b5f79285a3e | 20 | |
| Helvis | 1:2b5f79285a3e | 21 | float d2 = a1*pow(distance,5) + a2*pow(distance,4) + a3*pow(distance,3) + a4*pow(distance,2) + a5*distance + a6; |
| Helvis | 1:2b5f79285a3e | 22 | |
| Helvis | 1:2b5f79285a3e | 23 | return d2; |
| Helvis | 1:2b5f79285a3e | 24 | |
| Helvis | 1:2b5f79285a3e | 25 | } |
| Helvis | 1:2b5f79285a3e | 26 | |
| Helvis | 1:2b5f79285a3e | 27 | float IRSensor::readR(){ |
| Helvis | 1:2b5f79285a3e | 28 | //Rechts B1 |
| Helvis | 1:2b5f79285a3e | 29 | float b1 = -1.079f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 30 | float b2 = 2.404f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 31 | float b3 = -2.179f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 32 | float b4 = 1.012f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 33 | float b5 = -2519.0f; |
| Helvis | 1:2b5f79285a3e | 34 | float b6 = 310.8f; |
| Helvis | 1:2b5f79285a3e | 35 | |
| Helvis | 1:2b5f79285a3e | 36 | float d1 = b1*pow(distance,5) + b2*pow(distance,4) + b3*pow(distance,3) + b4*pow(distance,2) + b5*distance + b6; |
| Helvis | 1:2b5f79285a3e | 37 | |
| Helvis | 1:2b5f79285a3e | 38 | return d1; |
| Helvis | 1:2b5f79285a3e | 39 | } |
| Helvis | 1:2b5f79285a3e | 40 | |
| Helvis | 1:2b5f79285a3e | 41 | float IRSensor::readC(){ |
| Helvis | 1:2b5f79285a3e | 42 | //Vorne B4 |
| Helvis | 1:2b5f79285a3e | 43 | float c1 = -2.681f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 44 | float c2 = 6.007f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 45 | float c3 = -5.32f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 46 | float c4 = 2.377f*pow(10.0f,4.0f); |
| Helvis | 1:2b5f79285a3e | 47 | float c5 = -5686.0f; |
| Helvis | 1:2b5f79285a3e | 48 | float c6 = 697.8f; |
| Helvis | 1:2b5f79285a3e | 49 | |
| Helvis | 1:2b5f79285a3e | 50 | float d4 = c1*pow(distance,5) + c2*pow(distance,4) + c3*pow(distance,3) + c4*pow(distance,2) + c5*distance + c6; |
| Helvis | 1:2b5f79285a3e | 51 | |
| Helvis | 1:2b5f79285a3e | 52 | return d4; |
| Helvis | 1:2b5f79285a3e | 53 | } |
| Helvis | 1:2b5f79285a3e | 54 | |
| Helvis | 1:2b5f79285a3e | 55 | //float IRSensor::readB(){} |
