Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Committer:
narshu
Date:
Thu May 03 14:20:04 2012 +0000
Revision:
22:7ba09c0af0d0
Parent:
21:15da49f18c63
Child:
23:1901cb6d0d95
added 90sec timer and tigger

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 22:7ba09c0af0d0 9 //#define STARTLOC_RED
narshu 22:7ba09c0af0d0 10 #define STARTLOC_BLUE
narshu 21:15da49f18c63 11
narshu 14:24f994dc2770 12 //enables ui
narshu 22:7ba09c0af0d0 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 22:7ba09c0af0d0 19 const int wheelmm = 229;
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 22:7ba09c0af0d0 30 const int wheelmm = 308;
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 22:7ba09c0af0d0 53
narshu 22:7ba09c0af0d0 54 // Red start
narshu 21:15da49f18c63 55 #ifdef STARTLOC_RED
narshu 0:f3bf6c7e2283 56 const pos beaconpos[] = {{3000, 1000},{0,0}, {0,2000}};
narshu 22:7ba09c0af0d0 57
narshu 22:7ba09c0af0d0 58 // Blue Start
narshu 22:7ba09c0af0d0 59 #else
narshu 22:7ba09c0af0d0 60 const pos beaconpos[] = {{0, 1000},{3000,0}, {3000,2000}};
narshu 21:15da49f18c63 61 #endif
narshu 0:f3bf6c7e2283 62
narshu 1:bbabbd997d21 63 //System constants
narshu 1:bbabbd997d21 64 const int PREDICTPERIOD = 20; //ms
narshu 0:f3bf6c7e2283 65
narshu 0:f3bf6c7e2283 66 //High speed serial port
narshu 0:f3bf6c7e2283 67 extern Serial pc;
narshu 0:f3bf6c7e2283 68
narshu 0:f3bf6c7e2283 69 //I2C mutex
narshu 0:f3bf6c7e2283 70 //extern Mutex i2c_rlock;
narshu 0:f3bf6c7e2283 71 //extern Mutex i2c_wlock;
narshu 0:f3bf6c7e2283 72
narshu 0:f3bf6c7e2283 73
narshu 0:f3bf6c7e2283 74 // IR angle calc
narshu 0:f3bf6c7e2283 75 #define RELI_BOUND_LOW 4
narshu 0:f3bf6c7e2283 76 #define RELI_BOUND_HIGH 25
narshu 0:f3bf6c7e2283 77
narshu 10:294b9adbc9d3 78 // Movement target tolerances
narshu 22:7ba09c0af0d0 79 #define POSITION_TOR 30 // in mm
narshu 22:7ba09c0af0d0 80 #define ANGLE_TOR 0.1 // in rad
narshu 0:f3bf6c7e2283 81
narshu 0:f3bf6c7e2283 82 // motion control
narshu 19:06610e1c0895 83 #define MOVE_SPEED 20
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 15:acae5c0e9ca8 88 #define FWD_MOVE_P 14
narshu 13:57ea4e520dbd 89 #define SPIN_MOVE_P 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