This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
Sensors/CakeSensor/CakeSensor.h@71:eb1956c2d316, 2013-04-15 (annotated)
- Committer:
- madcowswe
- Date:
- Mon Apr 15 10:52:36 2013 +0000
- Revision:
- 71:eb1956c2d316
- Parent:
- 43:c592bf6a6a2d
Main start cord contraption sends signal 0x2 to ai thread when its time to go
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
twighk | 8:69bdf20cb525 | 1 | |
twighk | 8:69bdf20cb525 | 2 | // Eurobot13 CakeSensor.h |
twighk | 8:69bdf20cb525 | 3 | |
twighk | 8:69bdf20cb525 | 4 | #include "mbed.h" |
twighk | 8:69bdf20cb525 | 5 | |
twighk | 8:69bdf20cb525 | 6 | class CakeSensor{ |
twighk | 8:69bdf20cb525 | 7 | private: |
twighk | 8:69bdf20cb525 | 8 | AnalogIn ain; |
twighk | 8:69bdf20cb525 | 9 | |
twighk | 8:69bdf20cb525 | 10 | public: |
twighk | 8:69bdf20cb525 | 11 | CakeSensor(PinName analoginpin) : ain(analoginpin){} |
twighk | 8:69bdf20cb525 | 12 | |
twighk | 8:69bdf20cb525 | 13 | float Distance(){return ain;} |
twighk | 8:69bdf20cb525 | 14 | |
twighk | 8:69bdf20cb525 | 15 | float Distanceincm(){ |
twighk | 9:960410a01e6b | 16 | //float d = 5.5/(Distance()-0.13); |
twighk | 9:960410a01e6b | 17 | float d = 7.53/(Distance()-0.022); |
twighk | 8:69bdf20cb525 | 18 | d = (d < 6 || d > 30)? -1:d; |
xiaxia686 | 43:c592bf6a6a2d | 19 | |
twighk | 8:69bdf20cb525 | 20 | return d; |
twighk | 8:69bdf20cb525 | 21 | } |
twighk | 8:69bdf20cb525 | 22 | }; |
twighk | 9:960410a01e6b | 23 | /* |
twighk | 9:960410a01e6b | 24 | data = {{1/6,0.95},{1/9, 0.86}, {1/12, 0.65}, {1/15, 0.52}, {1/18, 0.44}, {1/21, 0.38}, {1/24, 0.33}, {1/27, 0.30}, {1/30, 0.28}} |
twighk | 9:960410a01e6b | 25 | Regress[data, {1, x}, x] |
twighk | 9:960410a01e6b | 26 | float d = 5.5/(Distance()-0.13); |
twighk | 9:960410a01e6b | 27 | |
twighk | 9:960410a01e6b | 28 | |
twighk | 9:960410a01e6b | 29 | data2 = {{1/9, 0.86}, {1/12, 0.65}, {1/15, 0.52}, {1/18, 0.44}, {1/21, 0.38}, {1/24, 0.33}, {1/27, 0.30}, {1/30, 0.28}} |
twighk | 9:960410a01e6b | 30 | Regress[data2, {1, x}, x] |
twighk | 9:960410a01e6b | 31 | float d = 7.53/(Distance()-0.022); |
twighk | 9:960410a01e6b | 32 | |
twighk | 9:960410a01e6b | 33 | */ |