Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Committer:
narshu
Date:
Tue May 01 16:54:44 2012 +0000
Revision:
21:15da49f18c63
Parent:
19:06610e1c0895
Child:
22:7ba09c0af0d0
Added support for both starting locs (except AI target mirroring)

Who changed what in which revision?

UserRevisionLine numberNew 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 #define STARTLOC_RED
narshu 21:15da49f18c63 10 //#define STARTLOC_BLUE
narshu 21:15da49f18c63 11
narshu 14:24f994dc2770 12 //enables ui
narshu 14:24f994dc2770 13 #define UION
narshu 14:24f994dc2770 14
narshu 9:377560539b74 15 #ifdef ROBOT_SECONDARY
narshu 5:7ac07bf30707 16 //Secondary Robot constants in mm
narshu 5:7ac07bf30707 17 const int robot_width = 260;
narshu 5:7ac07bf30707 18 const int encoderRevCount = 360;
narshu 5:7ac07bf30707 19 const int wheelmm = 226;
narshu 5:7ac07bf30707 20 const int robotCircumference = 816;
narshu 0:f3bf6c7e2283 21
narshu 5:7ac07bf30707 22
narshu 9:377560539b74 23 #else
narshu 9:377560539b74 24 #define ROBOT_PRIMARY
narshu 9:377560539b74 25 // invert echo polarity for primary
narshu 9:377560539b74 26 #define SONAR_ECHO_INV
narshu 9:377560539b74 27 // Primary Robot constants
narshu 9:377560539b74 28 const int robot_width = 390;
narshu 9:377560539b74 29 const int encoderRevCount = 1856;
narshu 9:377560539b74 30 const int wheelmm = 304;
narshu 9:377560539b74 31 const int robotCircumference = 1150;
narshu 9:377560539b74 32 #endif
narshu 0:f3bf6c7e2283 33
narshu 5:7ac07bf30707 34
narshu 1:bbabbd997d21 35
narshu 1:bbabbd997d21 36 //Robot movement constants
narshu 14:24f994dc2770 37 const float fwdvarperunit = 0.01; //1 std dev = 7% //NEEDS TO BE MEASURED AGAIN!
narshu 14:24f994dc2770 38 const float varperang = 0.01; //around 1 degree stddev per 180 turn
narshu 10:294b9adbc9d3 39 const float xyvarpertime = 0;//0.0005; //(very poorly) accounts for hitting things
narshu 10:294b9adbc9d3 40 const float angvarpertime = 0;//0.001;
narshu 1:bbabbd997d21 41
narshu 1:bbabbd997d21 42 //sonar constants
narshu 1:bbabbd997d21 43 static const float sonarvariance = 0.005;
narshu 0:f3bf6c7e2283 44
narshu 9:377560539b74 45 //IR constants
narshu 9:377560539b74 46 static const float IRvariance = 0.001;
narshu 9:377560539b74 47
narshu 0:f3bf6c7e2283 48 //Arena constants
narshu 0:f3bf6c7e2283 49 struct pos {
narshu 0:f3bf6c7e2283 50 int x;
narshu 0:f3bf6c7e2283 51 int y;
narshu 0:f3bf6c7e2283 52 };
narshu 21:15da49f18c63 53 #ifdef STARTLOC_RED
narshu 0:f3bf6c7e2283 54 const pos beaconpos[] = {{3000, 1000},{0,0}, {0,2000}};
narshu 21:15da49f18c63 55 #elif STARTLOC_BLUE
narshu 21:15da49f18c63 56 const pos beaconpos[] = {{0, 1000},{3000,2000}, {3000,0}};
narshu 21:15da49f18c63 57 #endif
narshu 0:f3bf6c7e2283 58
narshu 1:bbabbd997d21 59 //System constants
narshu 1:bbabbd997d21 60 const int PREDICTPERIOD = 20; //ms
narshu 0:f3bf6c7e2283 61
narshu 0:f3bf6c7e2283 62 //High speed serial port
narshu 0:f3bf6c7e2283 63 extern Serial pc;
narshu 0:f3bf6c7e2283 64
narshu 0:f3bf6c7e2283 65 //I2C mutex
narshu 0:f3bf6c7e2283 66 //extern Mutex i2c_rlock;
narshu 0:f3bf6c7e2283 67 //extern Mutex i2c_wlock;
narshu 0:f3bf6c7e2283 68
narshu 0:f3bf6c7e2283 69
narshu 0:f3bf6c7e2283 70 // IR angle calc
narshu 0:f3bf6c7e2283 71 #define RELI_BOUND_LOW 4
narshu 0:f3bf6c7e2283 72 #define RELI_BOUND_HIGH 25
narshu 0:f3bf6c7e2283 73
narshu 10:294b9adbc9d3 74 // Movement target tolerances
narshu 1:bbabbd997d21 75 #define POSITION_TOR 50
narshu 10:294b9adbc9d3 76 #define ANGLE_TOR 0.1
narshu 0:f3bf6c7e2283 77
narshu 0:f3bf6c7e2283 78 // motion control
narshu 19:06610e1c0895 79 #define MOVE_SPEED 20
narshu 0:f3bf6c7e2283 80 #define MAX_STEP_RATIO 0.10 //maximum change in the speed
narshu 0:f3bf6c7e2283 81 //#define TRACK_RATE 10 // +- rate for each wheel when tracking
narshu 0:f3bf6c7e2283 82
narshu 10:294b9adbc9d3 83 #ifdef ROBOT_PRIMARY
narshu 15:acae5c0e9ca8 84 #define FWD_MOVE_P 14
narshu 13:57ea4e520dbd 85 #define SPIN_MOVE_P 5.8
narshu 10:294b9adbc9d3 86 #else
narshu 10:294b9adbc9d3 87 #define FWD_MOVE_P 3.2
narshu 10:294b9adbc9d3 88 #define SPIN_MOVE_P 4
narshu 10:294b9adbc9d3 89 #endif
narshu 10:294b9adbc9d3 90
narshu 0:f3bf6c7e2283 91 // Task suspend periods
narshu 0:f3bf6c7e2283 92 #define IR_TURRET_PERIOD 200
narshu 0:f3bf6c7e2283 93 #define MOTION_UPDATE_PERIOD 20
narshu 0:f3bf6c7e2283 94
narshu 0:f3bf6c7e2283 95 #endif