ICRS Eurobot 2013

Dependencies:   mbed mbed-rtos Servo QEI

Committer:
madcowswe
Date:
Tue Apr 09 15:33:36 2013 +0000
Revision:
20:70d651156779
Parent:
19:4b993a9a156e
Predict loop running, update loop not done.

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
madcowswe 20:70d651156779 61 const PinName P_COLOR_SENSOR_IN = p20;
madcowswe 20:70d651156779 62
madcowswe 20:70d651156779 63 const PinName P_MOT_RIGHT_A = p21;
madcowswe 20:70d651156779 64 const PinName P_MOT_RIGHT_B = p22;
madcowswe 20:70d651156779 65 const PinName P_MOT_LEFT_A = p23;
madcowswe 20:70d651156779 66 const PinName P_MOT_LEFT_B = p24;
madcowswe 20:70d651156779 67
madcowswe 20:70d651156779 68 const PinName P_ENC_RIGHT_A = p28;
madcowswe 20:70d651156779 69 const PinName P_ENC_RIGHT_B = p27;
madcowswe 20:70d651156779 70 const PinName P_ENC_LEFT_A = p25;
madcowswe 20:70d651156779 71 const PinName P_ENC_LEFT_B = p26;
madcowswe 20:70d651156779 72
madcowswe 20:70d651156779 73 const PinName P_COLOR_SENSOR_RED = p29;
madcowswe 20:70d651156779 74 const PinName P_COLOR_SENSOR_BLUE = p30;
madcowswe 20:70d651156779 75
madcowswe 20:70d651156779 76
madcowswe 20:70d651156779 77
madcowswe 20:70d651156779 78 //a type which is a pointer to a rtos thread function
madcowswe 20:70d651156779 79 typedef void (*tfuncptr_t)(void const *argument);
madcowswe 16:52250d8d8fce 80
madcowswe 16:52250d8d8fce 81 //Solving for sonar bias is done by entering the following into wolfram alpha
madcowswe 16:52250d8d8fce 82 //(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 83 //where a, b, c are the measured distances, and f is the bias
madcowswe 16:52250d8d8fce 84
madcowswe 19:4b993a9a156e 85 //const float sonartimebias = 0; // TODO: measure and stick in the coprocessor code
madcowswe 17:6263e90bf3ba 86
madcowswe 17:6263e90bf3ba 87 struct pos {
madcowswe 17:6263e90bf3ba 88 float x;
madcowswe 17:6263e90bf3ba 89 float y;
madcowswe 17:6263e90bf3ba 90 };
madcowswe 17:6263e90bf3ba 91
madcowswe 19:4b993a9a156e 92 extern pos beaconpos[3];
madcowswe 19:4b993a9a156e 93
madcowswe 20:70d651156779 94 const float PI = 3.14159265359;
madcowswe 20:70d651156779 95
madcowswe 20:70d651156779 96 #endif //GLOBALS_H