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