This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
globals.h@32:e3f633620816, 2013-04-10 (annotated)
- Committer:
- madcowswe
- Date:
- Wed Apr 10 18:25:16 2013 +0000
- Revision:
- 32:e3f633620816
- Parent:
- 31:ada943ecaceb
- Parent:
- 30:791739422122
- Child:
- 33:a49197572737
Merged ryan oskar
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 | 26:7cb3a21d9a2e | 11 | const float ENCODER_M_PER_TICK = 0.00084; |
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 | 20:70d651156779 | 16 | const float fwdvarperunit = 0.01; //1 std dev = 7% //TODO: measrue this!! |
madcowswe | 31:ada943ecaceb | 17 | const float varperang = 0.0002; //around 1 degree stddev per 180 turn //TODO: measrue this!! |
madcowswe | 31:ada943ecaceb | 18 | const float xyvarpertime = 0;//0.0005; //(very poorly) accounts for hitting things |
madcowswe | 31:ada943ecaceb | 19 | const float angvarpertime = 0;//0.001; |
madcowswe | 22:6e3218cf75f8 | 20 | |
madcowswe | 25:b16f1045108f | 21 | const float MOTORCONTROLLER_FILTER_K = 0.5;// TODO: tune this |
madcowswe | 22:6e3218cf75f8 | 22 | const float MOTOR_MAX_POWER = 0.4f; |
madcowswe | 22:6e3218cf75f8 | 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 | |
madcowswe | 20:70d651156779 | 65 | const PinName P_COLOR_SENSOR_IN = p20; |
madcowswe | 20:70d651156779 | 66 | |
madcowswe | 25:b16f1045108f | 67 | const PinName P_MOT_LEFT_A = p21; |
madcowswe | 25:b16f1045108f | 68 | const PinName P_MOT_LEFT_B = p22; |
madcowswe | 25:b16f1045108f | 69 | const PinName P_MOT_RIGHT_A = p23; |
madcowswe | 25:b16f1045108f | 70 | const PinName P_MOT_RIGHT_B = p24; |
madcowswe | 20:70d651156779 | 71 | |
madcowswe | 25:b16f1045108f | 72 | const PinName P_ENC_RIGHT_A = p26; |
madcowswe | 25:b16f1045108f | 73 | const PinName P_ENC_RIGHT_B = p25; |
madcowswe | 25:b16f1045108f | 74 | const PinName P_ENC_LEFT_A = p27; |
madcowswe | 25:b16f1045108f | 75 | const PinName P_ENC_LEFT_B = p28; |
madcowswe | 20:70d651156779 | 76 | |
madcowswe | 20:70d651156779 | 77 | const PinName P_COLOR_SENSOR_RED = p29; |
madcowswe | 20:70d651156779 | 78 | const PinName P_COLOR_SENSOR_BLUE = p30; |
madcowswe | 20:70d651156779 | 79 | |
madcowswe | 20:70d651156779 | 80 | |
madcowswe | 20:70d651156779 | 81 | |
madcowswe | 20:70d651156779 | 82 | //a type which is a pointer to a rtos thread function |
madcowswe | 20:70d651156779 | 83 | typedef void (*tfuncptr_t)(void const *argument); |
madcowswe | 16:52250d8d8fce | 84 | |
madcowswe | 16:52250d8d8fce | 85 | //Solving for sonar bias is done by entering the following into wolfram alpha |
madcowswe | 16:52250d8d8fce | 86 | //(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 | 87 | //where a, b, c are the measured distances, and f is the bias |
madcowswe | 16:52250d8d8fce | 88 | |
madcowswe | 19:4b993a9a156e | 89 | //const float sonartimebias = 0; // TODO: measure and stick in the coprocessor code |
madcowswe | 17:6263e90bf3ba | 90 | |
madcowswe | 17:6263e90bf3ba | 91 | struct pos { |
madcowswe | 17:6263e90bf3ba | 92 | float x; |
madcowswe | 17:6263e90bf3ba | 93 | float y; |
madcowswe | 17:6263e90bf3ba | 94 | }; |
madcowswe | 17:6263e90bf3ba | 95 | |
madcowswe | 19:4b993a9a156e | 96 | extern pos beaconpos[3]; |
madcowswe | 19:4b993a9a156e | 97 | |
madcowswe | 20:70d651156779 | 98 | const float PI = 3.14159265359; |
madcowswe | 20:70d651156779 | 99 | |
rsavitski | 24:50805ef8c499 | 100 | typedef struct Waypoint |
rsavitski | 24:50805ef8c499 | 101 | { |
rsavitski | 24:50805ef8c499 | 102 | float x; |
rsavitski | 24:50805ef8c499 | 103 | float y; |
rsavitski | 24:50805ef8c499 | 104 | float theta; |
rsavitski | 24:50805ef8c499 | 105 | float pos_threshold; |
rsavitski | 24:50805ef8c499 | 106 | float angle_threshold; |
rsavitski | 24:50805ef8c499 | 107 | } Waypoint; |
rsavitski | 24:50805ef8c499 | 108 | |
madcowswe | 20:70d651156779 | 109 | #endif //GLOBALS_H |