Colour sensors calibrated

Dependencies:   mbed-rtos mbed Servo QEI

Fork of ICRSEurobot13 by Thomas Branch

Committer:
xiaxia686
Date:
Fri Apr 12 20:59:18 2013 +0000
Revision:
46:adcd57a5e402
Parent:
44:555136de33e4
Colours Sensors fixed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
madcowswe 16:52250d8d8fce 1
madcowswe 20:70d651156779 2 #ifndef GLOBALS_H
madcowswe 20:70d651156779 3 #define GLOBALS_H
madcowswe 20:70d651156779 4
madcowswe 20:70d651156779 5 #include "mbed.h"
madcowswe 20:70d651156779 6
madcowswe 20:70d651156779 7 const float KALMAN_PREDICT_PERIOD = 0.05; //seconds
madcowswe 20:70d651156779 8
madcowswe 20:70d651156779 9 #define ENABLE_GLOBAL_ENCODERS
madcowswe 20:70d651156779 10
madcowswe 27:7cb3a21d9a2e 11 const float ENCODER_M_PER_TICK = 0.00084;
madcowswe 27:7cb3a21d9a2e 12 const float ENCODER_WHEELBASE = 0.068;
madcowswe 32:ada943ecaceb 13 const float TURRET_FWD_PLACEMENT = -0.042;
madcowswe 20:70d651156779 14
madcowswe 20:70d651156779 15 //Robot movement constants
madcowswe 20:70d651156779 16 const float fwdvarperunit = 0.01; //1 std dev = 7% //TODO: measrue this!!
madcowswe 32:ada943ecaceb 17 const float varperang = 0.0002; //around 1 degree stddev per 180 turn //TODO: measrue this!!
madcowswe 32:ada943ecaceb 18 const float xyvarpertime = 0;//0.0005; //(very poorly) accounts for hitting things
madcowswe 32:ada943ecaceb 19 const float angvarpertime = 0;//0.001;
madcowswe 23:6e3218cf75f8 20
madcowswe 26:b16f1045108f 21 const float MOTORCONTROLLER_FILTER_K = 0.5;// TODO: tune this
madcowswe 34:a49197572737 22 const float MOTOR_MAX_POWER = 0.5f;
madcowswe 20:70d651156779 23
madcowswe 20:70d651156779 24 /*
madcowswe 20:70d651156779 25 PINOUT Sensors
madcowswe 20:70d651156779 26 5: RF:SDI
madcowswe 20:70d651156779 27 6 SDO
madcowswe 20:70d651156779 28 7 SCK
madcowswe 20:70d651156779 29 8 NCS
madcowswe 20:70d651156779 30 9 NIRQ
madcowswe 20:70d651156779 31 10-15 6 echo pins
madcowswe 20:70d651156779 32 16 trig
madcowswe 20:70d651156779 33 17 IRin
madcowswe 20:70d651156779 34 18-20 unused
madcowswe 20:70d651156779 35 21 stepper step
madcowswe 20:70d651156779 36 22-27 unused
madcowswe 20:70d651156779 37 28 Serial TX
madcowswe 20:70d651156779 38 29-30 unused
madcowswe 20:70d651156779 39
madcowswe 20:70d651156779 40
madcowswe 20:70d651156779 41 PINOUT Main
madcowswe 20:70d651156779 42 5: Lower arm servo
madcowswe 20:70d651156779 43 6: Upper arm servo
madcowswe 20:70d651156779 44
madcowswe 20:70d651156779 45 14: Serial RX
madcowswe 20:70d651156779 46 15: Cake distance sensor
madcowswe 20:70d651156779 47 16: Fwd distance sensor
madcowswe 20:70d651156779 48
madcowswe 20:70d651156779 49 20: color sensor in
madcowswe 20:70d651156779 50 21-24: Motors PWM IN 1-4
madcowswe 20:70d651156779 51 25-26: Encoders
madcowswe 20:70d651156779 52 27-28: Encoders
madcowswe 20:70d651156779 53 29: Color sensor RED LED
madcowswe 20:70d651156779 54 30: Color sensor BLUE LED
madcowswe 20:70d651156779 55
madcowswe 20:70d651156779 56 */
madcowswe 20:70d651156779 57
madcowswe 20:70d651156779 58 const PinName P_SERVO_LOWER_ARM = p5;
madcowswe 20:70d651156779 59 const PinName P_SERVO_UPPER_ARM = p6;
madcowswe 20:70d651156779 60
madcowswe 20:70d651156779 61 const PinName P_SERIAL_RX = p14;
madcowswe 20:70d651156779 62 const PinName P_DISTANCE_SENSOR = p15;
madcowswe 32:ada943ecaceb 63 const PinName P_FWD_DISTANCE_SENSOR = p16;
madcowswe 20:70d651156779 64
xiaxia686 21:c592bf6a6a2d 65 const PinName P_COLOR_SENSOR_IN_UPPER = p20;
xiaxia686 21:c592bf6a6a2d 66 const PinName P_COLOR_SENSOR_IN_LOWER = p19;
madcowswe 20:70d651156779 67
madcowswe 26:b16f1045108f 68 const PinName P_MOT_LEFT_A = p21;
madcowswe 26:b16f1045108f 69 const PinName P_MOT_LEFT_B = p22;
madcowswe 26:b16f1045108f 70 const PinName P_MOT_RIGHT_A = p23;
madcowswe 26:b16f1045108f 71 const PinName P_MOT_RIGHT_B = p24;
madcowswe 20:70d651156779 72
madcowswe 26:b16f1045108f 73 const PinName P_ENC_RIGHT_A = p26;
madcowswe 26:b16f1045108f 74 const PinName P_ENC_RIGHT_B = p25;
madcowswe 26:b16f1045108f 75 const PinName P_ENC_LEFT_A = p27;
madcowswe 26:b16f1045108f 76 const PinName P_ENC_LEFT_B = p28;
madcowswe 20:70d651156779 77
xiaxia686 21:c592bf6a6a2d 78 const PinName P_COLOR_SENSOR_RED_UPPER = p29;
xiaxia686 21:c592bf6a6a2d 79 const PinName P_COLOR_SENSOR_BLUE_UPPER = p30;
xiaxia686 21:c592bf6a6a2d 80 const PinName P_COLOR_SENSOR_RED_LOWER = p11;
xiaxia686 21:c592bf6a6a2d 81 const PinName P_COLOR_SENSOR_BLUE_LOWER = p10;
madcowswe 20:70d651156779 82
madcowswe 20:70d651156779 83
madcowswe 20:70d651156779 84
madcowswe 20:70d651156779 85 //a type which is a pointer to a rtos thread function
madcowswe 20:70d651156779 86 typedef void (*tfuncptr_t)(void const *argument);
madcowswe 16:52250d8d8fce 87
madcowswe 16:52250d8d8fce 88 //Solving for sonar bias is done by entering the following into wolfram alpha
madcowswe 16:52250d8d8fce 89 //(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
madcowswe 16:52250d8d8fce 90 //where a, b, c are the measured distances, and f is the bias
madcowswe 16:52250d8d8fce 91
madcowswe 19:4b993a9a156e 92 //const float sonartimebias = 0; // TODO: measure and stick in the coprocessor code
madcowswe 17:6263e90bf3ba 93
madcowswe 17:6263e90bf3ba 94 struct pos {
madcowswe 17:6263e90bf3ba 95 float x;
madcowswe 17:6263e90bf3ba 96 float y;
madcowswe 17:6263e90bf3ba 97 };
madcowswe 17:6263e90bf3ba 98
madcowswe 19:4b993a9a156e 99 extern pos beaconpos[3];
madcowswe 19:4b993a9a156e 100
madcowswe 20:70d651156779 101 const float PI = 3.14159265359;
madcowswe 20:70d651156779 102
rsavitski 25:50805ef8c499 103 typedef struct Waypoint
rsavitski 25:50805ef8c499 104 {
rsavitski 25:50805ef8c499 105 float x;
rsavitski 25:50805ef8c499 106 float y;
rsavitski 25:50805ef8c499 107 float theta;
rsavitski 25:50805ef8c499 108 float pos_threshold;
rsavitski 25:50805ef8c499 109 float angle_threshold;
rsavitski 25:50805ef8c499 110 } Waypoint;
rsavitski 25:50805ef8c499 111
madcowswe 34:a49197572737 112 typedef struct State
madcowswe 34:a49197572737 113 {
madcowswe 34:a49197572737 114 float x;
madcowswe 34:a49197572737 115 float y;
madcowswe 34:a49197572737 116 float theta;
madcowswe 34:a49197572737 117 } State;
madcowswe 34:a49197572737 118
madcowswe 20:70d651156779 119 #endif //GLOBALS_H