Eurobot2012_Secondary

Fork of Eurobot_2012_Secondary by Shuto Naruse

Committer:
narshu
Date:
Wed Oct 17 22:25:31 2012 +0000
Revision:
1:cc2a9eb0bd55
Parent:
0:fbfafa6bf5f9
Commit before publishing

Who changed what in which revision?

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