This is some awesome robot code

Dependencies:   mbed-rtos mbed QEI

Fork of ICRSEurobot13 by Thomas Branch

Committer:
madcowswe
Date:
Wed Apr 17 23:16:25 2013 +0000
Revision:
90:e4164bb8c60e
Parent:
43:c592bf6a6a2d
final state at end of competition. Includes avoid wooden team hack

Who changed what in which revision?

UserRevisionLine numberNew 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 */