Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Committer:
narshu
Date:
Sat Apr 28 20:44:09 2012 +0000
Revision:
14:24f994dc2770
Parent:
13:57ea4e520dbd
Child:
15:acae5c0e9ca8
added speed limiter

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