This is some awesome robot code

Dependencies:   mbed-rtos mbed QEI

Fork of ICRSEurobot13 by Thomas Branch

Committer:
xiaxia686
Date:
Fri Apr 12 16:24:25 2013 +0000
Revision:
43:c592bf6a6a2d
Parent:
20:70d651156779
Child:
44:555136de33e4
Colour sensors calibrated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
madcowswe 16:52250d8d8fce 1
madcowswe 20:70d651156779 2 #ifndef GLOBALS_H
madcowswe 20:70d651156779 3 #define GLOBALS_H
madcowswe 20:70d651156779 4
madcowswe 20:70d651156779 5 #include "mbed.h"
madcowswe 20:70d651156779 6
madcowswe 20:70d651156779 7 const float KALMAN_PREDICT_PERIOD = 0.05; //seconds
madcowswe 20:70d651156779 8
madcowswe 20:70d651156779 9 #define ENABLE_GLOBAL_ENCODERS
madcowswe 20:70d651156779 10
madcowswe 20:70d651156779 11 const float ENCODER_M_PER_TICK = 0.00084; //TODO: measure this!!
madcowswe 20:70d651156779 12 const float ENCODER_WHEELBASE = 0.068; //TODO: measrue this!!
madcowswe 20:70d651156779 13 const float TURRET_FWD_PLACEMENT = 0.042;
madcowswe 20:70d651156779 14
madcowswe 20:70d651156779 15 //Robot movement constants
madcowswe 20:70d651156779 16 const float fwdvarperunit = 0.01; //1 std dev = 7% //TODO: measrue this!!
madcowswe 20:70d651156779 17 const float varperang = 0.01; //around 1 degree stddev per 180 turn //TODO: measrue this!!
madcowswe 20:70d651156779 18 const float xyvarpertime = 0.0005; //(very poorly) accounts for hitting things
madcowswe 20:70d651156779 19 const float angvarpertime = 0.001;
madcowswe 20:70d651156779 20
madcowswe 20:70d651156779 21 /*
madcowswe 20:70d651156779 22 PINOUT Sensors
madcowswe 20:70d651156779 23 5: RF:SDI
madcowswe 20:70d651156779 24 6 SDO
madcowswe 20:70d651156779 25 7 SCK
madcowswe 20:70d651156779 26 8 NCS
madcowswe 20:70d651156779 27 9 NIRQ
madcowswe 20:70d651156779 28 10-15 6 echo pins
madcowswe 20:70d651156779 29 16 trig
madcowswe 20:70d651156779 30 17 IRin
madcowswe 20:70d651156779 31 18-20 unused
madcowswe 20:70d651156779 32 21 stepper step
madcowswe 20:70d651156779 33 22-27 unused
madcowswe 20:70d651156779 34 28 Serial TX
madcowswe 20:70d651156779 35 29-30 unused
madcowswe 20:70d651156779 36
madcowswe 20:70d651156779 37
madcowswe 20:70d651156779 38 PINOUT Main
madcowswe 20:70d651156779 39 5: Lower arm servo
madcowswe 20:70d651156779 40 6: Upper arm servo
madcowswe 20:70d651156779 41
madcowswe 20:70d651156779 42 14: Serial RX
madcowswe 20:70d651156779 43 15: Cake distance sensor
madcowswe 20:70d651156779 44 16: Fwd distance sensor
madcowswe 20:70d651156779 45
madcowswe 20:70d651156779 46 20: color sensor in
madcowswe 20:70d651156779 47 21-24: Motors PWM IN 1-4
madcowswe 20:70d651156779 48 25-26: Encoders
madcowswe 20:70d651156779 49 27-28: Encoders
madcowswe 20:70d651156779 50 29: Color sensor RED LED
madcowswe 20:70d651156779 51 30: Color sensor BLUE LED
madcowswe 20:70d651156779 52
madcowswe 20:70d651156779 53 */
madcowswe 20:70d651156779 54
madcowswe 20:70d651156779 55 const PinName P_SERVO_LOWER_ARM = p5;
madcowswe 20:70d651156779 56 const PinName P_SERVO_UPPER_ARM = p6;
madcowswe 20:70d651156779 57
madcowswe 20:70d651156779 58 const PinName P_SERIAL_RX = p14;
madcowswe 20:70d651156779 59 const PinName P_DISTANCE_SENSOR = p15;
madcowswe 20:70d651156779 60
xiaxia686 43:c592bf6a6a2d 61 const PinName P_COLOR_SENSOR_IN_UPPER = p20;
xiaxia686 43:c592bf6a6a2d 62 const PinName P_COLOR_SENSOR_IN_LOWER = p19;
madcowswe 20:70d651156779 63
madcowswe 20:70d651156779 64 const PinName P_MOT_RIGHT_A = p21;
madcowswe 20:70d651156779 65 const PinName P_MOT_RIGHT_B = p22;
madcowswe 20:70d651156779 66 const PinName P_MOT_LEFT_A = p23;
madcowswe 20:70d651156779 67 const PinName P_MOT_LEFT_B = p24;
madcowswe 20:70d651156779 68
madcowswe 20:70d651156779 69 const PinName P_ENC_RIGHT_A = p28;
madcowswe 20:70d651156779 70 const PinName P_ENC_RIGHT_B = p27;
madcowswe 20:70d651156779 71 const PinName P_ENC_LEFT_A = p25;
madcowswe 20:70d651156779 72 const PinName P_ENC_LEFT_B = p26;
madcowswe 20:70d651156779 73
xiaxia686 43:c592bf6a6a2d 74 const PinName P_COLOR_SENSOR_RED_UPPER = p29;
xiaxia686 43:c592bf6a6a2d 75 const PinName P_COLOR_SENSOR_BLUE_UPPER = p30;
xiaxia686 43:c592bf6a6a2d 76 const PinName P_COLOR_SENSOR_RED_LOWER = p11;
xiaxia686 43:c592bf6a6a2d 77 const PinName P_COLOR_SENSOR_BLUE_LOWER = p10;
madcowswe 20:70d651156779 78
madcowswe 20:70d651156779 79
madcowswe 20:70d651156779 80
madcowswe 20:70d651156779 81 //a type which is a pointer to a rtos thread function
madcowswe 20:70d651156779 82 typedef void (*tfuncptr_t)(void const *argument);
madcowswe 16:52250d8d8fce 83
madcowswe 16:52250d8d8fce 84 //Solving for sonar bias is done by entering the following into wolfram alpha
madcowswe 16:52250d8d8fce 85 //(a-f)^2 = x^2 + y^2; (b-f)^2 = (x-3)^2 + y^2; (c-f)^2 = (x-1.5)^2+(y-2)^2: solve for x,y,f
madcowswe 16:52250d8d8fce 86 //where a, b, c are the measured distances, and f is the bias
madcowswe 16:52250d8d8fce 87
madcowswe 19:4b993a9a156e 88 //const float sonartimebias = 0; // TODO: measure and stick in the coprocessor code
madcowswe 17:6263e90bf3ba 89
madcowswe 17:6263e90bf3ba 90 struct pos {
madcowswe 17:6263e90bf3ba 91 float x;
madcowswe 17:6263e90bf3ba 92 float y;
madcowswe 17:6263e90bf3ba 93 };
madcowswe 17:6263e90bf3ba 94
madcowswe 19:4b993a9a156e 95 extern pos beaconpos[3];
madcowswe 19:4b993a9a156e 96
madcowswe 20:70d651156779 97 const float PI = 3.14159265359;
madcowswe 20:70d651156779 98
madcowswe 20:70d651156779 99 #endif //GLOBALS_H