Ryan Savitski / Mbed 2 deprecated ICRSEurobot14

Dependencies:   mbed-rtos mbed QEI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers globals.h Source File

globals.h

00001 #ifndef GLOBALS_H
00002 #define GLOBALS_H
00003 
00004 //#define TEAM_RED
00005 #define TEAM_BLUE
00006 
00007 #include "mbed.h"
00008 
00009 const float KALMAN_PREDICT_PERIOD = 0.05; //seconds
00010 
00011 #define ENABLE_GLOBAL_ENCODERS
00012 
00013 const float ENCODER_M_PER_TICK = 1.0f/1198.0f;
00014 const float ENCODER_WHEELBASE = 0.068;
00015 const float TURRET_FWD_PLACEMENT = -0.042;
00016 
00017 //Robot movement constants
00018 const float fwdvarperunit = 0.0001; //1 std dev = 7% //TODO: measrue this!!
00019 const float varperang = 0.0003; //around 3 degree stddev per 180 turn //TODO: measrue this!!
00020 const float xyvarpertime = 0.000025; //(very poorly) accounts for hitting things
00021 const float angvarpertime = 0.0001;  
00022 
00023 const float MOTORCONTROLLER_FILTER_K = 0.5;// TODO: tune this
00024 const float MOTOR_MAX_POWER = 0.5f;
00025 
00026 /*
00027 PINOUT Sensors
00028 5:  RF:SDI
00029 6 SDO
00030 7 SCK
00031 8 NCS
00032 9 NIRQ
00033 10-15 6 echo pins
00034 16 trig
00035 17 IRin
00036 18-20 unused
00037 21 stepper step
00038 22-27 unused
00039 28 Serial TX
00040 29-30 unused
00041 
00042 
00043 PINOUT Main
00044 5: Lower arm servo
00045 6: Upper arm servo
00046 
00047 14: Serial RX
00048 15: Cake distance sensor
00049 16: Fwd distance sensor
00050 
00051 20: color sensor in
00052 21-24: Motors PWM IN 1-4
00053 25-26: Encoders 
00054 27-28: Encoders 
00055 29: Color sensor RED LED
00056 30: Color sensor BLUE LED
00057 
00058 */
00059 
00060 const PinName P_SERVO_LOWER_ARM = p25;
00061 const PinName P_SERVO_UPPER_ARM = p26;
00062 
00063 const PinName P_SERIAL_RX       = p14;
00064 const PinName P_DISTANCE_SENSOR = p15;
00065 const PinName P_FWD_DISTANCE_SENSOR = p16;
00066 
00067 const PinName P_COLOR_SENSOR_IN_UPPER = p20;
00068 const PinName P_COLOR_SENSOR_IN_LOWER = p19;
00069 
00070 const PinName P_MOT_LEFT_A     = p22;
00071 const PinName P_MOT_LEFT_B     = p21;
00072 const PinName P_MOT_RIGHT_A      = p24;
00073 const PinName P_MOT_RIGHT_B      = p23;
00074 
00075 const PinName P_ENC_RIGHT_A     = p28;//p26;
00076 const PinName P_ENC_RIGHT_B     = p27;//p25;
00077 const PinName P_ENC_LEFT_A      = p29;//p27;
00078 const PinName P_ENC_LEFT_B      = p30;//p28;
00079 
00080 const PinName P_COLOR_SENSOR_RED_UPPER = p13;//p29;
00081 const PinName P_COLOR_SENSOR_BLUE_UPPER = p12;//p30;
00082 const PinName P_COLOR_SENSOR_RED_LOWER = p11;
00083 const PinName P_COLOR_SENSOR_BLUE_LOWER = p10;
00084 
00085 const PinName P_START_CORD = p17;
00086 
00087 const PinName P_BALLOON = p8;
00088 
00089 
00090 
00091 //a type which is a pointer to a rtos thread function
00092 typedef void (*tfuncptr_t)(void const *argument);
00093 
00094 //Solving for sonar bias is done by entering the following into wolfram alpha
00095 //(a-f)^2 = x^2 + y^2; (b-f)^2 = (x-3)^2 + y^2; (c-f)^2 = (x-1.5)^2+(y-2)^2: solve for x,y,f
00096 //where a, b, c are the measured distances, and f is the bias
00097 
00098 //const float sonartimebias = 0; // TODO: measure and stick in the coprocessor code
00099 
00100 struct pos {
00101     float x;
00102     float y;
00103 };
00104 
00105 extern pos beaconpos[3];
00106 
00107 const float PI = 3.14159265359;
00108 
00109 typedef struct Waypoint
00110 {
00111     float x;
00112     float y;
00113     float theta;
00114     float pos_threshold;
00115     float angle_threshold;
00116     float angle_exponent; //temp hack
00117 } Waypoint;
00118 
00119 typedef struct State 
00120 {
00121     float x;
00122     float y;
00123     float theta;
00124 } State;
00125 
00126 #endif //GLOBALS_H