![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
We are going to win! wohoo
globals.h@1:6799c07fe510, 2012-11-07 (annotated)
- Committer:
- sv
- Date:
- Wed Nov 07 14:37:35 2012 +0000
- Revision:
- 1:6799c07fe510
- Child:
- 3:8c78c15a92e3
- Child:
- 7:88753d0ad4ca
Preliminary copy of 2012 code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sv | 1:6799c07fe510 | 1 | #ifndef GLOBALS_H |
sv | 1:6799c07fe510 | 2 | #define GLOBALS_H |
sv | 1:6799c07fe510 | 3 | |
sv | 1:6799c07fe510 | 4 | #include "mbed.h" |
sv | 1:6799c07fe510 | 5 | #define PI 3.14159265 |
sv | 1:6799c07fe510 | 6 | |
sv | 1:6799c07fe510 | 7 | |
sv | 1:6799c07fe510 | 8 | //#define ROBOT_SECONDARY |
sv | 1:6799c07fe510 | 9 | |
sv | 1:6799c07fe510 | 10 | //enables ui |
sv | 1:6799c07fe510 | 11 | //#define UION |
sv | 1:6799c07fe510 | 12 | |
sv | 1:6799c07fe510 | 13 | #ifdef ROBOT_SECONDARY |
sv | 1:6799c07fe510 | 14 | //Secondary Robot constants in mm |
sv | 1:6799c07fe510 | 15 | const int robot_width = 260; |
sv | 1:6799c07fe510 | 16 | const int encoderRevCount = 360; |
sv | 1:6799c07fe510 | 17 | const int wheelmm = 229; |
sv | 1:6799c07fe510 | 18 | const int robotCircumference = 816; |
sv | 1:6799c07fe510 | 19 | |
sv | 1:6799c07fe510 | 20 | |
sv | 1:6799c07fe510 | 21 | #else |
sv | 1:6799c07fe510 | 22 | #define ROBOT_PRIMARY |
sv | 1:6799c07fe510 | 23 | // invert echo polarity for primary |
sv | 1:6799c07fe510 | 24 | #define SONAR_ECHO_INV |
sv | 1:6799c07fe510 | 25 | // Primary Robot constants |
sv | 1:6799c07fe510 | 26 | const int robot_width = 390; |
sv | 1:6799c07fe510 | 27 | const int encoderRevCount = 1856; |
sv | 1:6799c07fe510 | 28 | const int wheelmm = 308; |
sv | 1:6799c07fe510 | 29 | const int robotCircumference = 1150; |
sv | 1:6799c07fe510 | 30 | #endif |
sv | 1:6799c07fe510 | 31 | |
sv | 1:6799c07fe510 | 32 | |
sv | 1:6799c07fe510 | 33 | |
sv | 1:6799c07fe510 | 34 | //Robot movement constants |
sv | 1:6799c07fe510 | 35 | const float fwdvarperunit = 0.01; //1 std dev = 7% //NEEDS TO BE MEASURED AGAIN! |
sv | 1:6799c07fe510 | 36 | const float varperang = 0.01; //around 1 degree stddev per 180 turn |
sv | 1:6799c07fe510 | 37 | const float xyvarpertime = 0.0005; //(very poorly) accounts for hitting things |
sv | 1:6799c07fe510 | 38 | const float angvarpertime = 0.001; |
sv | 1:6799c07fe510 | 39 | |
sv | 1:6799c07fe510 | 40 | //sonar constants |
sv | 1:6799c07fe510 | 41 | static const float sonarvariance = 0.005; |
sv | 1:6799c07fe510 | 42 | |
sv | 1:6799c07fe510 | 43 | //IR constants |
sv | 1:6799c07fe510 | 44 | static const float IRvariance = 0.001; |
sv | 1:6799c07fe510 | 45 | |
sv | 1:6799c07fe510 | 46 | //Arena constants |
sv | 1:6799c07fe510 | 47 | struct pos { |
sv | 1:6799c07fe510 | 48 | int x; |
sv | 1:6799c07fe510 | 49 | int y; |
sv | 1:6799c07fe510 | 50 | }; |
sv | 1:6799c07fe510 | 51 | |
sv | 1:6799c07fe510 | 52 | //beacon positions |
sv | 1:6799c07fe510 | 53 | extern pos beaconpos[]; |
sv | 1:6799c07fe510 | 54 | |
sv | 1:6799c07fe510 | 55 | //Colour |
sv | 1:6799c07fe510 | 56 | extern bool Colour; // 1 for red, 0 for blue |
sv | 1:6799c07fe510 | 57 | |
sv | 1:6799c07fe510 | 58 | //System constants |
sv | 1:6799c07fe510 | 59 | const int PREDICTPERIOD = 20; //ms |
sv | 1:6799c07fe510 | 60 | |
sv | 1:6799c07fe510 | 61 | //High speed serial port |
sv | 1:6799c07fe510 | 62 | extern Serial pc; |
sv | 1:6799c07fe510 | 63 | |
sv | 1:6799c07fe510 | 64 | //I2C mutex |
sv | 1:6799c07fe510 | 65 | //extern Mutex i2c_rlock; |
sv | 1:6799c07fe510 | 66 | //extern Mutex i2c_wlock; |
sv | 1:6799c07fe510 | 67 | |
sv | 1:6799c07fe510 | 68 | |
sv | 1:6799c07fe510 | 69 | // IR angle calc |
sv | 1:6799c07fe510 | 70 | #define RELI_BOUND_LOW 4 |
sv | 1:6799c07fe510 | 71 | #define RELI_BOUND_HIGH 25 |
sv | 1:6799c07fe510 | 72 | |
sv | 1:6799c07fe510 | 73 | // Movement target tolerances |
sv | 1:6799c07fe510 | 74 | #define POSITION_TOR 20 // in mm |
sv | 1:6799c07fe510 | 75 | #define ANGLE_TOR 0.06 // in rad |
sv | 1:6799c07fe510 | 76 | |
sv | 1:6799c07fe510 | 77 | // motion control |
sv | 1:6799c07fe510 | 78 | |
sv | 1:6799c07fe510 | 79 | #ifndef MOVE_SPEED_DEF |
sv | 1:6799c07fe510 | 80 | #define MOVE_SPEED_DEF |
sv | 1:6799c07fe510 | 81 | static int MOVE_SPEED = 35; |
sv | 1:6799c07fe510 | 82 | #endif |
sv | 1:6799c07fe510 | 83 | |
sv | 1:6799c07fe510 | 84 | #define MAX_STEP_RATIO 0.10 //maximum change in the speed |
sv | 1:6799c07fe510 | 85 | //#define TRACK_RATE 10 // +- rate for each wheel when tracking |
sv | 1:6799c07fe510 | 86 | |
sv | 1:6799c07fe510 | 87 | #ifdef ROBOT_PRIMARY |
sv | 1:6799c07fe510 | 88 | #define FWD_MOVE_P 20//18 |
sv | 1:6799c07fe510 | 89 | #define SPIN_MOVE_P 7//5.8 |
sv | 1:6799c07fe510 | 90 | #else |
sv | 1:6799c07fe510 | 91 | #define FWD_MOVE_P 3.2 |
sv | 1:6799c07fe510 | 92 | #define SPIN_MOVE_P 4 |
sv | 1:6799c07fe510 | 93 | #endif |
sv | 1:6799c07fe510 | 94 | |
sv | 1:6799c07fe510 | 95 | // Task suspend periods |
sv | 1:6799c07fe510 | 96 | #define IR_TURRET_PERIOD 200 |
sv | 1:6799c07fe510 | 97 | #define MOTION_UPDATE_PERIOD 20 |
sv | 1:6799c07fe510 | 98 | |
sv | 1:6799c07fe510 | 99 | #endif |