2014 Eurobot fork

Dependencies:   mbed-rtos mbed QEI

Committer:
rsavitski
Date:
Tue Oct 15 12:19:32 2013 +0000
Revision:
92:4a1225fbb146
Parent:
91:fdadfd883825
touch: ripped out 2013-specific bits. Need to address "2014" comments. Rewrite AI layer and other deleted parts.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
madcowswe 20:70d651156779 1 #ifndef GLOBALS_H
madcowswe 20:70d651156779 2 #define GLOBALS_H
madcowswe 20:70d651156779 3
madcowswe 89:dfe8c2ec5b88 4 //#define TEAM_RED
madcowswe 89:dfe8c2ec5b88 5 #define TEAM_BLUE
madcowswe 72:7996aa8286ae 6
madcowswe 20:70d651156779 7 #include "mbed.h"
madcowswe 20:70d651156779 8
madcowswe 20:70d651156779 9 const float KALMAN_PREDICT_PERIOD = 0.05; //seconds
madcowswe 20:70d651156779 10
madcowswe 20:70d651156779 11 #define ENABLE_GLOBAL_ENCODERS
madcowswe 20:70d651156779 12
madcowswe 62:78d99b781f02 13 const float ENCODER_M_PER_TICK = 1.0f/1198.0f;
madcowswe 26:7cb3a21d9a2e 14 const float ENCODER_WHEELBASE = 0.068;
madcowswe 31:ada943ecaceb 15 const float TURRET_FWD_PLACEMENT = -0.042;
madcowswe 20:70d651156779 16
madcowswe 20:70d651156779 17 //Robot movement constants
madcowswe 79:0d3140048526 18 const float fwdvarperunit = 0.0001; //1 std dev = 7% //TODO: measrue this!!
madcowswe 79:0d3140048526 19 const float varperang = 0.0003; //around 3 degree stddev per 180 turn //TODO: measrue this!!
madcowswe 79:0d3140048526 20 const float xyvarpertime = 0.000025; //(very poorly) accounts for hitting things
madcowswe 79:0d3140048526 21 const float angvarpertime = 0.0001;
madcowswe 22:6e3218cf75f8 22
madcowswe 25:b16f1045108f 23 const float MOTORCONTROLLER_FILTER_K = 0.5;// TODO: tune this
madcowswe 33:a49197572737 24 const float MOTOR_MAX_POWER = 0.5f;
madcowswe 20:70d651156779 25
madcowswe 20:70d651156779 26 /*
madcowswe 20:70d651156779 27 PINOUT Sensors
madcowswe 20:70d651156779 28 5: RF:SDI
madcowswe 20:70d651156779 29 6 SDO
madcowswe 20:70d651156779 30 7 SCK
madcowswe 20:70d651156779 31 8 NCS
madcowswe 20:70d651156779 32 9 NIRQ
madcowswe 20:70d651156779 33 10-15 6 echo pins
madcowswe 20:70d651156779 34 16 trig
madcowswe 20:70d651156779 35 17 IRin
madcowswe 20:70d651156779 36 18-20 unused
madcowswe 20:70d651156779 37 21 stepper step
madcowswe 20:70d651156779 38 22-27 unused
madcowswe 20:70d651156779 39 28 Serial TX
madcowswe 20:70d651156779 40 29-30 unused
madcowswe 20:70d651156779 41
madcowswe 20:70d651156779 42
madcowswe 20:70d651156779 43 PINOUT Main
madcowswe 20:70d651156779 44 5: Lower arm servo
madcowswe 20:70d651156779 45 6: Upper arm servo
madcowswe 20:70d651156779 46
madcowswe 20:70d651156779 47 14: Serial RX
madcowswe 20:70d651156779 48 15: Cake distance sensor
madcowswe 20:70d651156779 49 16: Fwd distance sensor
madcowswe 20:70d651156779 50
madcowswe 20:70d651156779 51 20: color sensor in
madcowswe 20:70d651156779 52 21-24: Motors PWM IN 1-4
madcowswe 20:70d651156779 53 25-26: Encoders
madcowswe 20:70d651156779 54 27-28: Encoders
madcowswe 20:70d651156779 55 29: Color sensor RED LED
madcowswe 20:70d651156779 56 30: Color sensor BLUE LED
madcowswe 20:70d651156779 57
madcowswe 20:70d651156779 58 */
madcowswe 20:70d651156779 59
rsavitski 58:ff2121f34e3b 60 const PinName P_SERVO_LOWER_ARM = p25;
rsavitski 58:ff2121f34e3b 61 const PinName P_SERVO_UPPER_ARM = p26;
madcowswe 20:70d651156779 62
madcowswe 20:70d651156779 63 const PinName P_SERIAL_RX = p14;
madcowswe 20:70d651156779 64 const PinName P_DISTANCE_SENSOR = p15;
madcowswe 31:ada943ecaceb 65 const PinName P_FWD_DISTANCE_SENSOR = p16;
madcowswe 20:70d651156779 66
xiaxia686 43:c592bf6a6a2d 67 const PinName P_COLOR_SENSOR_IN_UPPER = p20;
xiaxia686 43:c592bf6a6a2d 68 const PinName P_COLOR_SENSOR_IN_LOWER = p19;
madcowswe 20:70d651156779 69
madcowswe 60:5058465904e0 70 const PinName P_MOT_LEFT_A = p22;
madcowswe 60:5058465904e0 71 const PinName P_MOT_LEFT_B = p21;
madcowswe 60:5058465904e0 72 const PinName P_MOT_RIGHT_A = p24;
madcowswe 60:5058465904e0 73 const PinName P_MOT_RIGHT_B = p23;
madcowswe 20:70d651156779 74
rsavitski 58:ff2121f34e3b 75 const PinName P_ENC_RIGHT_A = p28;//p26;
rsavitski 58:ff2121f34e3b 76 const PinName P_ENC_RIGHT_B = p27;//p25;
rsavitski 58:ff2121f34e3b 77 const PinName P_ENC_LEFT_A = p29;//p27;
rsavitski 58:ff2121f34e3b 78 const PinName P_ENC_LEFT_B = p30;//p28;
madcowswe 20:70d651156779 79
rsavitski 58:ff2121f34e3b 80 const PinName P_COLOR_SENSOR_RED_UPPER = p13;//p29;
rsavitski 58:ff2121f34e3b 81 const PinName P_COLOR_SENSOR_BLUE_UPPER = p12;//p30;
xiaxia686 43:c592bf6a6a2d 82 const PinName P_COLOR_SENSOR_RED_LOWER = p11;
xiaxia686 43:c592bf6a6a2d 83 const PinName P_COLOR_SENSOR_BLUE_LOWER = p10;
madcowswe 20:70d651156779 84
rsavitski 77:8d83a0c00e66 85 const PinName P_START_CORD = p17;
madcowswe 71:eb1956c2d316 86
madcowswe 84:00c799fd10a7 87 const PinName P_BALLOON = p8;
madcowswe 84:00c799fd10a7 88
madcowswe 20:70d651156779 89
madcowswe 20:70d651156779 90
madcowswe 20:70d651156779 91 //a type which is a pointer to a rtos thread function
madcowswe 20:70d651156779 92 typedef void (*tfuncptr_t)(void const *argument);
madcowswe 16:52250d8d8fce 93
madcowswe 16:52250d8d8fce 94 //Solving for sonar bias is done by entering the following into wolfram alpha
madcowswe 16:52250d8d8fce 95 //(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 96 //where a, b, c are the measured distances, and f is the bias
madcowswe 16:52250d8d8fce 97
madcowswe 19:4b993a9a156e 98 //const float sonartimebias = 0; // TODO: measure and stick in the coprocessor code
madcowswe 17:6263e90bf3ba 99
madcowswe 17:6263e90bf3ba 100 struct pos {
madcowswe 17:6263e90bf3ba 101 float x;
madcowswe 17:6263e90bf3ba 102 float y;
madcowswe 17:6263e90bf3ba 103 };
madcowswe 17:6263e90bf3ba 104
madcowswe 19:4b993a9a156e 105 extern pos beaconpos[3];
madcowswe 19:4b993a9a156e 106
madcowswe 20:70d651156779 107 const float PI = 3.14159265359;
madcowswe 20:70d651156779 108
rsavitski 24:50805ef8c499 109 typedef struct Waypoint
rsavitski 24:50805ef8c499 110 {
rsavitski 24:50805ef8c499 111 float x;
rsavitski 24:50805ef8c499 112 float y;
rsavitski 24:50805ef8c499 113 float theta;
rsavitski 24:50805ef8c499 114 float pos_threshold;
rsavitski 24:50805ef8c499 115 float angle_threshold;
rsavitski 77:8d83a0c00e66 116 float angle_exponent; //temp hack
rsavitski 24:50805ef8c499 117 } Waypoint;
rsavitski 24:50805ef8c499 118
madcowswe 33:a49197572737 119 typedef struct State
madcowswe 33:a49197572737 120 {
madcowswe 33:a49197572737 121 float x;
madcowswe 33:a49197572737 122 float y;
madcowswe 33:a49197572737 123 float theta;
madcowswe 33:a49197572737 124 } State;
madcowswe 33:a49197572737 125
madcowswe 20:70d651156779 126 #endif //GLOBALS_H