2014 Eurobot fork
Dependencies: mbed-rtos mbed QEI
globals.h@60:5058465904e0, 2013-04-13 (annotated)
- Committer:
- madcowswe
- Date:
- Sat Apr 13 22:41:00 2013 +0000
- Revision:
- 60:5058465904e0
- Parent:
- 50:937e860f4621
- Child:
- 61:a7782a35ce4f
Added feed forward. Maybe positive feedback
Who changed what in which revision?
User | Revision | Line number | New 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 | 60:5058465904e0 | 11 | const float ENCODER_M_PER_TICK = 1.0f/11980.0f; |
madcowswe | 26:7cb3a21d9a2e | 12 | const float ENCODER_WHEELBASE = 0.068; |
madcowswe | 31:ada943ecaceb | 13 | const float TURRET_FWD_PLACEMENT = -0.042; |
madcowswe | 20:70d651156779 | 14 | |
madcowswe | 20:70d651156779 | 15 | //Robot movement constants |
madcowswe | 49:665bdca0f2cd | 16 | const float fwdvarperunit = 0.001; //1 std dev = 7% //TODO: measrue this!! |
madcowswe | 49:665bdca0f2cd | 17 | const float varperang = 0.0005; //around 3 degree stddev per 180 turn //TODO: measrue this!! |
madcowswe | 49:665bdca0f2cd | 18 | const float xyvarpertime = 0.0001; //(very poorly) accounts for hitting things |
madcowswe | 49:665bdca0f2cd | 19 | const float angvarpertime = 0.001; |
madcowswe | 22:6e3218cf75f8 | 20 | |
madcowswe | 25:b16f1045108f | 21 | const float MOTORCONTROLLER_FILTER_K = 0.5;// TODO: tune this |
madcowswe | 33:a49197572737 | 22 | const float MOTOR_MAX_POWER = 0.5f; |
madcowswe | 20:70d651156779 | 23 | |
madcowswe | 20:70d651156779 | 24 | /* |
madcowswe | 20:70d651156779 | 25 | PINOUT Sensors |
madcowswe | 20:70d651156779 | 26 | 5: RF:SDI |
madcowswe | 20:70d651156779 | 27 | 6 SDO |
madcowswe | 20:70d651156779 | 28 | 7 SCK |
madcowswe | 20:70d651156779 | 29 | 8 NCS |
madcowswe | 20:70d651156779 | 30 | 9 NIRQ |
madcowswe | 20:70d651156779 | 31 | 10-15 6 echo pins |
madcowswe | 20:70d651156779 | 32 | 16 trig |
madcowswe | 20:70d651156779 | 33 | 17 IRin |
madcowswe | 20:70d651156779 | 34 | 18-20 unused |
madcowswe | 20:70d651156779 | 35 | 21 stepper step |
madcowswe | 20:70d651156779 | 36 | 22-27 unused |
madcowswe | 20:70d651156779 | 37 | 28 Serial TX |
madcowswe | 20:70d651156779 | 38 | 29-30 unused |
madcowswe | 20:70d651156779 | 39 | |
madcowswe | 20:70d651156779 | 40 | |
madcowswe | 20:70d651156779 | 41 | PINOUT Main |
madcowswe | 20:70d651156779 | 42 | 5: Lower arm servo |
madcowswe | 20:70d651156779 | 43 | 6: Upper arm servo |
madcowswe | 20:70d651156779 | 44 | |
madcowswe | 20:70d651156779 | 45 | 14: Serial RX |
madcowswe | 20:70d651156779 | 46 | 15: Cake distance sensor |
madcowswe | 20:70d651156779 | 47 | 16: Fwd distance sensor |
madcowswe | 20:70d651156779 | 48 | |
madcowswe | 20:70d651156779 | 49 | 20: color sensor in |
madcowswe | 20:70d651156779 | 50 | 21-24: Motors PWM IN 1-4 |
madcowswe | 20:70d651156779 | 51 | 25-26: Encoders |
madcowswe | 20:70d651156779 | 52 | 27-28: Encoders |
madcowswe | 20:70d651156779 | 53 | 29: Color sensor RED LED |
madcowswe | 20:70d651156779 | 54 | 30: Color sensor BLUE LED |
madcowswe | 20:70d651156779 | 55 | |
madcowswe | 20:70d651156779 | 56 | */ |
madcowswe | 20:70d651156779 | 57 | |
madcowswe | 20:70d651156779 | 58 | const PinName P_SERVO_LOWER_ARM = p5; |
madcowswe | 20:70d651156779 | 59 | const PinName P_SERVO_UPPER_ARM = p6; |
madcowswe | 20:70d651156779 | 60 | |
madcowswe | 20:70d651156779 | 61 | const PinName P_SERIAL_RX = p14; |
madcowswe | 20:70d651156779 | 62 | const PinName P_DISTANCE_SENSOR = p15; |
madcowswe | 31:ada943ecaceb | 63 | const PinName P_FWD_DISTANCE_SENSOR = p16; |
madcowswe | 20:70d651156779 | 64 | |
xiaxia686 | 43:c592bf6a6a2d | 65 | const PinName P_COLOR_SENSOR_IN_UPPER = p20; |
xiaxia686 | 43:c592bf6a6a2d | 66 | const PinName P_COLOR_SENSOR_IN_LOWER = p19; |
madcowswe | 20:70d651156779 | 67 | |
madcowswe | 60:5058465904e0 | 68 | const PinName P_MOT_LEFT_A = p22; |
madcowswe | 60:5058465904e0 | 69 | const PinName P_MOT_LEFT_B = p21; |
madcowswe | 60:5058465904e0 | 70 | const PinName P_MOT_RIGHT_A = p24; |
madcowswe | 60:5058465904e0 | 71 | const PinName P_MOT_RIGHT_B = p23; |
madcowswe | 20:70d651156779 | 72 | |
madcowswe | 25:b16f1045108f | 73 | const PinName P_ENC_RIGHT_A = p26; |
madcowswe | 25:b16f1045108f | 74 | const PinName P_ENC_RIGHT_B = p25; |
madcowswe | 25:b16f1045108f | 75 | const PinName P_ENC_LEFT_A = p27; |
madcowswe | 25:b16f1045108f | 76 | const PinName P_ENC_LEFT_B = p28; |
madcowswe | 20:70d651156779 | 77 | |
xiaxia686 | 43:c592bf6a6a2d | 78 | const PinName P_COLOR_SENSOR_RED_UPPER = p29; |
xiaxia686 | 43:c592bf6a6a2d | 79 | const PinName P_COLOR_SENSOR_BLUE_UPPER = p30; |
xiaxia686 | 43:c592bf6a6a2d | 80 | const PinName P_COLOR_SENSOR_RED_LOWER = p11; |
xiaxia686 | 43:c592bf6a6a2d | 81 | const PinName P_COLOR_SENSOR_BLUE_LOWER = p10; |
madcowswe | 20:70d651156779 | 82 | |
madcowswe | 20:70d651156779 | 83 | |
madcowswe | 20:70d651156779 | 84 | |
madcowswe | 20:70d651156779 | 85 | //a type which is a pointer to a rtos thread function |
madcowswe | 20:70d651156779 | 86 | typedef void (*tfuncptr_t)(void const *argument); |
madcowswe | 16:52250d8d8fce | 87 | |
madcowswe | 16:52250d8d8fce | 88 | //Solving for sonar bias is done by entering the following into wolfram alpha |
madcowswe | 16:52250d8d8fce | 89 | //(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 | 90 | //where a, b, c are the measured distances, and f is the bias |
madcowswe | 16:52250d8d8fce | 91 | |
madcowswe | 19:4b993a9a156e | 92 | //const float sonartimebias = 0; // TODO: measure and stick in the coprocessor code |
madcowswe | 17:6263e90bf3ba | 93 | |
madcowswe | 17:6263e90bf3ba | 94 | struct pos { |
madcowswe | 17:6263e90bf3ba | 95 | float x; |
madcowswe | 17:6263e90bf3ba | 96 | float y; |
madcowswe | 17:6263e90bf3ba | 97 | }; |
madcowswe | 17:6263e90bf3ba | 98 | |
madcowswe | 19:4b993a9a156e | 99 | extern pos beaconpos[3]; |
madcowswe | 19:4b993a9a156e | 100 | |
madcowswe | 20:70d651156779 | 101 | const float PI = 3.14159265359; |
madcowswe | 20:70d651156779 | 102 | |
rsavitski | 24:50805ef8c499 | 103 | typedef struct Waypoint |
rsavitski | 24:50805ef8c499 | 104 | { |
rsavitski | 24:50805ef8c499 | 105 | float x; |
rsavitski | 24:50805ef8c499 | 106 | float y; |
rsavitski | 24:50805ef8c499 | 107 | float theta; |
rsavitski | 24:50805ef8c499 | 108 | float pos_threshold; |
rsavitski | 24:50805ef8c499 | 109 | float angle_threshold; |
rsavitski | 24:50805ef8c499 | 110 | } Waypoint; |
rsavitski | 24:50805ef8c499 | 111 | |
madcowswe | 33:a49197572737 | 112 | typedef struct State |
madcowswe | 33:a49197572737 | 113 | { |
madcowswe | 33:a49197572737 | 114 | float x; |
madcowswe | 33:a49197572737 | 115 | float y; |
madcowswe | 33:a49197572737 | 116 | float theta; |
madcowswe | 33:a49197572737 | 117 | } State; |
madcowswe | 33:a49197572737 | 118 | |
madcowswe | 20:70d651156779 | 119 | #endif //GLOBALS_H |