Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Committer:
narshu
Date:
Thu Apr 26 23:49:49 2012 +0000
Revision:
5:7ac07bf30707
Parent:
2:cffa347bb943
Child:
9:377560539b74
Fixed Sonar and most of the kalman filter except for the IR serial;

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 2:cffa347bb943 4 //#define ROBOT_SECONDARY
narshu 2:cffa347bb943 5
narshu 2:cffa347bb943 6 #ifndef ROBOT_SECONDARY
narshu 2:cffa347bb943 7 #define ROBOT_PRIMARY
narshu 2:cffa347bb943 8 // invert echo polarity for primary
narshu 2:cffa347bb943 9 #define SONAR_ECHO_INV
narshu 5:7ac07bf30707 10 // Primary Robot constants
narshu 5:7ac07bf30707 11 const int robot_width = 410;
narshu 5:7ac07bf30707 12 const int encoderRevCount = 1856;
narshu 5:7ac07bf30707 13 const int wheelmm = 314;
narshu 5:7ac07bf30707 14 const int robotCircumference = 1256;
narshu 5:7ac07bf30707 15 #else
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 2:cffa347bb943 21 #endif
narshu 2:cffa347bb943 22
narshu 0:f3bf6c7e2283 23 #include "mbed.h"
narshu 0:f3bf6c7e2283 24
narshu 0:f3bf6c7e2283 25 #define PI 3.14159265
narshu 0:f3bf6c7e2283 26
narshu 5:7ac07bf30707 27
narshu 0:f3bf6c7e2283 28
narshu 5:7ac07bf30707 29
narshu 1:bbabbd997d21 30
narshu 1:bbabbd997d21 31 //Robot movement constants
narshu 1:bbabbd997d21 32 const float fwdvarperunit = 0.005; //1 std dev = 7% //NEEDS TO BE MEASURED AGAIN!
narshu 1:bbabbd997d21 33 const float varperang = 3E-5; //around 1 degree stddev per 180 turn
narshu 1:bbabbd997d21 34 const float xyvarpertime = 0.001; //(very poorly) accounts for hitting things
narshu 1:bbabbd997d21 35 const float angvarpertime = 0.001;
narshu 1:bbabbd997d21 36
narshu 1:bbabbd997d21 37 //sonar constants
narshu 1:bbabbd997d21 38 static const float sonarvariance = 0.005;
narshu 0:f3bf6c7e2283 39
narshu 0:f3bf6c7e2283 40 //Arena constants
narshu 0:f3bf6c7e2283 41 struct pos {
narshu 0:f3bf6c7e2283 42 int x;
narshu 0:f3bf6c7e2283 43 int y;
narshu 0:f3bf6c7e2283 44 };
narshu 0:f3bf6c7e2283 45 const pos beaconpos[] = {{3000, 1000},{0,0}, {0,2000}};
narshu 0:f3bf6c7e2283 46
narshu 1:bbabbd997d21 47 //System constants
narshu 1:bbabbd997d21 48 const int PREDICTPERIOD = 20; //ms
narshu 0:f3bf6c7e2283 49
narshu 0:f3bf6c7e2283 50 //High speed serial port
narshu 0:f3bf6c7e2283 51 extern Serial pc;
narshu 0:f3bf6c7e2283 52
narshu 0:f3bf6c7e2283 53 //I2C mutex
narshu 0:f3bf6c7e2283 54 //extern Mutex i2c_rlock;
narshu 0:f3bf6c7e2283 55 //extern Mutex i2c_wlock;
narshu 0:f3bf6c7e2283 56
narshu 0:f3bf6c7e2283 57
narshu 0:f3bf6c7e2283 58 // IR angle calc
narshu 0:f3bf6c7e2283 59 #define RELI_BOUND_LOW 4
narshu 0:f3bf6c7e2283 60 #define RELI_BOUND_HIGH 25
narshu 0:f3bf6c7e2283 61
narshu 1:bbabbd997d21 62 // Localization estimate tolerences
narshu 1:bbabbd997d21 63 #define POSITION_TOR 50
narshu 0:f3bf6c7e2283 64 #define ANGLE_TOR 0.15
narshu 0:f3bf6c7e2283 65
narshu 0:f3bf6c7e2283 66 // motion control
narshu 1:bbabbd997d21 67 #define MOVE_SPEED 30
narshu 0:f3bf6c7e2283 68 #define MAX_STEP_RATIO 0.10 //maximum change in the speed
narshu 0:f3bf6c7e2283 69 //#define TRACK_RATE 10 // +- rate for each wheel when tracking
narshu 0:f3bf6c7e2283 70
narshu 0:f3bf6c7e2283 71 // Task suspend periods
narshu 0:f3bf6c7e2283 72 #define IR_TURRET_PERIOD 200
narshu 0:f3bf6c7e2283 73 #define MOTION_UPDATE_PERIOD 20
narshu 0:f3bf6c7e2283 74
narshu 0:f3bf6c7e2283 75 #endif