Cooper Liu
/
Eurobot2013_Co-Processor
working version with calibration done
Fork of Eurobot2013 by
globals.h@10:2bd9f4e02b74, 2013-04-07 (annotated)
- Committer:
- xiaxia686
- Date:
- Sun Apr 07 16:30:49 2013 +0000
- Revision:
- 10:2bd9f4e02b74
- Parent:
- 7:88753d0ad4ca
- Child:
- 11:5ba926692210
Working version with no serial communication to the main board. The IR sensors uses mode for identification;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sv | 1:6799c07fe510 | 1 | #ifndef GLOBALS_H |
sv | 1:6799c07fe510 | 2 | #define GLOBALS_H |
sv | 1:6799c07fe510 | 3 | |
xiaxia686 | 10:2bd9f4e02b74 | 4 | #include "mbed.h" |
xiaxia686 | 10:2bd9f4e02b74 | 5 | #define PI 3.14159265 |
madcowswe | 7:88753d0ad4ca | 6 | |
madcowswe | 7:88753d0ad4ca | 7 | #define ROBOT_PRIMARY |
madcowswe | 7:88753d0ad4ca | 8 | |
xiaxia686 | 10:2bd9f4e02b74 | 9 | // Stepper motor defines go here, p30 is reserved for the hardware counter |
xiaxia686 | 10:2bd9f4e02b74 | 10 | #define STEPPER_PIN p21 //p21 pwmout |
xiaxia686 | 10:2bd9f4e02b74 | 11 | #define STEPPER_PERIOD 0.0001 //Stepper motor period in seconds, 50% duty cycle |
xiaxia686 | 10:2bd9f4e02b74 | 12 | #define STEPPER_DIV 3200 // number of steps per cycle = default * microstep |
xiaxia686 | 10:2bd9f4e02b74 | 13 | #define STEP_ANGLE ((float)(2*PI) / STEPPER_DIV) // step angle of stepper |
xiaxia686 | 10:2bd9f4e02b74 | 14 | #define IR_TIMEOUT_STEP 90 //about 10 degrees |
xiaxia686 | 10:2bd9f4e02b74 | 15 | #define IR_TIMEOUT (STEPPER_PERIOD*IR_TIMEOUT_STEP) |
madcowswe | 7:88753d0ad4ca | 16 | |
xiaxia686 | 10:2bd9f4e02b74 | 17 | // IR Sensor defines go here |
xiaxia686 | 10:2bd9f4e02b74 | 18 | #define PWM_INVERT // inverts the PWM for the IR sensor pwm input |
xiaxia686 | 10:2bd9f4e02b74 | 19 | #define IR_SENSOR_PIN p17 |
xiaxia686 | 10:2bd9f4e02b74 | 20 | #define IR0_PULSEWIDTH 1000 |
xiaxia686 | 10:2bd9f4e02b74 | 21 | #define IR1_PULSEWIDTH 750 |
xiaxia686 | 10:2bd9f4e02b74 | 22 | #define IR2_PULSEWIDTH 500 |
xiaxia686 | 10:2bd9f4e02b74 | 23 | #define PULSEWIDTH_TOLERANCE 125 |
xiaxia686 | 10:2bd9f4e02b74 | 24 | |
xiaxia686 | 10:2bd9f4e02b74 | 25 | |
xiaxia686 | 10:2bd9f4e02b74 | 26 | |
xiaxia686 | 10:2bd9f4e02b74 | 27 | |
sv | 1:6799c07fe510 | 28 | |
sv | 1:6799c07fe510 | 29 | //enables ui |
sv | 1:6799c07fe510 | 30 | //#define UION |
sv | 1:6799c07fe510 | 31 | |
sv | 1:6799c07fe510 | 32 | |
sv | 1:6799c07fe510 | 33 | |
madcowswe | 7:88753d0ad4ca | 34 | #ifdef ROBOT_PRIMARY |
madcowswe | 7:88753d0ad4ca | 35 | // Primary defs go here |
madcowswe | 7:88753d0ad4ca | 36 | //Robot hardware parameters |
madcowswe | 7:88753d0ad4ca | 37 | const int robotCircumference = 816; //mm (DUMMY!) |
sv | 1:6799c07fe510 | 38 | |
sv | 1:6799c07fe510 | 39 | //Robot movement constants |
sv | 1:6799c07fe510 | 40 | const float fwdvarperunit = 0.01; //1 std dev = 7% //NEEDS TO BE MEASURED AGAIN! |
sv | 1:6799c07fe510 | 41 | const float varperang = 0.01; //around 1 degree stddev per 180 turn |
sv | 1:6799c07fe510 | 42 | const float xyvarpertime = 0.0005; //(very poorly) accounts for hitting things |
sv | 1:6799c07fe510 | 43 | const float angvarpertime = 0.001; |
xiaxia686 | 10:2bd9f4e02b74 | 44 | #else |
xiaxia686 | 10:2bd9f4e02b74 | 45 | // Secondary defs go here |
xiaxia686 | 10:2bd9f4e02b74 | 46 | //Robot hardware parameters |
xiaxia686 | 10:2bd9f4e02b74 | 47 | const int robotCircumference = 816; //mm (DUMMY!) |
xiaxia686 | 10:2bd9f4e02b74 | 48 | |
xiaxia686 | 10:2bd9f4e02b74 | 49 | //Robot movement constants |
xiaxia686 | 10:2bd9f4e02b74 | 50 | const float fwdvarperunit = 0.01; //1 std dev = 7% //NEEDS TO BE MEASURED AGAIN! |
xiaxia686 | 10:2bd9f4e02b74 | 51 | const float varperang = 0.01; //around 1 degree stddev per 180 turn |
xiaxia686 | 10:2bd9f4e02b74 | 52 | const float xyvarpertime = 0.0005; //(very poorly) accounts for hitting things |
xiaxia686 | 10:2bd9f4e02b74 | 53 | const float angvarpertime = 0.001; |
xiaxia686 | 10:2bd9f4e02b74 | 54 | #endif |
xiaxia686 | 10:2bd9f4e02b74 | 55 | |
xiaxia686 | 10:2bd9f4e02b74 | 56 | |
sv | 1:6799c07fe510 | 57 | |
sv | 1:6799c07fe510 | 58 | //sonar constants |
sv | 1:6799c07fe510 | 59 | static const float sonarvariance = 0.005; |
sv | 1:6799c07fe510 | 60 | |
sv | 1:6799c07fe510 | 61 | //IR constants |
sv | 1:6799c07fe510 | 62 | static const float IRvariance = 0.001; |
sv | 1:6799c07fe510 | 63 | |
sv | 1:6799c07fe510 | 64 | //Arena constants |
sv | 1:6799c07fe510 | 65 | struct pos { |
sv | 1:6799c07fe510 | 66 | int x; |
sv | 1:6799c07fe510 | 67 | int y; |
sv | 1:6799c07fe510 | 68 | }; |
sv | 1:6799c07fe510 | 69 | |
sv | 1:6799c07fe510 | 70 | //beacon positions |
sv | 1:6799c07fe510 | 71 | extern pos beaconpos[]; |
sv | 1:6799c07fe510 | 72 | |
sv | 1:6799c07fe510 | 73 | //Colour |
sv | 1:6799c07fe510 | 74 | extern bool Colour; // 1 for red, 0 for blue |
sv | 1:6799c07fe510 | 75 | |
sv | 1:6799c07fe510 | 76 | //System constants |
sv | 1:6799c07fe510 | 77 | const int PREDICTPERIOD = 20; //ms |
sv | 1:6799c07fe510 | 78 | |
sv | 1:6799c07fe510 | 79 | //High speed serial port |
sv | 1:6799c07fe510 | 80 | extern Serial pc; |
sv | 1:6799c07fe510 | 81 | |
sv | 1:6799c07fe510 | 82 | |
sv | 1:6799c07fe510 | 83 | #endif |