Robot.h@0:637fe5c74b2d, 2010-12-16 (annotated)
- Committer:
- sowmy87
- Date:
- Thu Dec 16 09:25:37 2010 +0000
- Revision:
- 0:637fe5c74b2d
- Child:
- 1:8fa2ee8c005e
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sowmy87 | 0:637fe5c74b2d | 1 | #ifndef __ROBOT__H |
sowmy87 | 0:637fe5c74b2d | 2 | #define __ROBOT__H |
sowmy87 | 0:637fe5c74b2d | 3 | #include "CMPS03.h" |
sowmy87 | 0:637fe5c74b2d | 4 | #include "Serializer.h" |
sowmy87 | 0:637fe5c74b2d | 5 | #include "PID.h" |
sowmy87 | 0:637fe5c74b2d | 6 | #include "SRF05.h" |
sowmy87 | 0:637fe5c74b2d | 7 | #include "Servo.h" |
sowmy87 | 0:637fe5c74b2d | 8 | |
sowmy87 | 0:637fe5c74b2d | 9 | |
sowmy87 | 0:637fe5c74b2d | 10 | #define MAX_ROBOT_SPEED 51 |
sowmy87 | 0:637fe5c74b2d | 11 | #define PID_RATE 0.05 |
sowmy87 | 0:637fe5c74b2d | 12 | #define SERVO_RATE .1 |
sowmy87 | 0:637fe5c74b2d | 13 | |
sowmy87 | 0:637fe5c74b2d | 14 | |
sowmy87 | 0:637fe5c74b2d | 15 | |
sowmy87 | 0:637fe5c74b2d | 16 | class Robot { |
sowmy87 | 0:637fe5c74b2d | 17 | public: |
sowmy87 | 0:637fe5c74b2d | 18 | Robot(); |
sowmy87 | 0:637fe5c74b2d | 19 | ~Robot(); |
sowmy87 | 0:637fe5c74b2d | 20 | int SetDediredHeading(int deg); |
sowmy87 | 0:637fe5c74b2d | 21 | int GetDesiredHeading(); |
sowmy87 | 0:637fe5c74b2d | 22 | int GetActualHeading(); |
sowmy87 | 0:637fe5c74b2d | 23 | |
sowmy87 | 0:637fe5c74b2d | 24 | void SetSpeed(int spd); |
sowmy87 | 0:637fe5c74b2d | 25 | void SetSpeed(int lSpd, int rSpd); |
sowmy87 | 0:637fe5c74b2d | 26 | void SetLeftSpeed(int spd); |
sowmy87 | 0:637fe5c74b2d | 27 | void SetRightSpeed(int spd); |
sowmy87 | 0:637fe5c74b2d | 28 | |
sowmy87 | 0:637fe5c74b2d | 29 | void PivetLeft(int deg); |
sowmy87 | 0:637fe5c74b2d | 30 | void PivetRight(int deg); |
sowmy87 | 0:637fe5c74b2d | 31 | void Pivet(int deg); |
sowmy87 | 0:637fe5c74b2d | 32 | void DiGo(int inches,int inPsec); |
sowmy87 | 0:637fe5c74b2d | 33 | |
sowmy87 | 0:637fe5c74b2d | 34 | float GetRange(int position); |
sowmy87 | 0:637fe5c74b2d | 35 | |
sowmy87 | 0:637fe5c74b2d | 36 | |
sowmy87 | 0:637fe5c74b2d | 37 | |
sowmy87 | 0:637fe5c74b2d | 38 | //protected: |
sowmy87 | 0:637fe5c74b2d | 39 | |
sowmy87 | 0:637fe5c74b2d | 40 | //private: |
sowmy87 | 0:637fe5c74b2d | 41 | volatile int desiredHeading; |
sowmy87 | 0:637fe5c74b2d | 42 | volatile int actualHeading; |
sowmy87 | 0:637fe5c74b2d | 43 | volatile int deltaHeading; |
sowmy87 | 0:637fe5c74b2d | 44 | volatile int prevDeltaHeading; |
sowmy87 | 0:637fe5c74b2d | 45 | volatile int desiredSpeed; |
sowmy87 | 0:637fe5c74b2d | 46 | volatile int servoPosition;// [0,10] |
sowmy87 | 0:637fe5c74b2d | 47 | volatile int servoDirection; |
sowmy87 | 0:637fe5c74b2d | 48 | volatile int isFullScan; |
sowmy87 | 0:637fe5c74b2d | 49 | |
sowmy87 | 0:637fe5c74b2d | 50 | volatile float range0; |
sowmy87 | 0:637fe5c74b2d | 51 | volatile float range1; |
sowmy87 | 0:637fe5c74b2d | 52 | volatile float range2; |
sowmy87 | 0:637fe5c74b2d | 53 | volatile float range3; |
sowmy87 | 0:637fe5c74b2d | 54 | volatile float range4; |
sowmy87 | 0:637fe5c74b2d | 55 | volatile float range5; |
sowmy87 | 0:637fe5c74b2d | 56 | volatile float range6; |
sowmy87 | 0:637fe5c74b2d | 57 | volatile float range7; |
sowmy87 | 0:637fe5c74b2d | 58 | volatile float range8; |
sowmy87 | 0:637fe5c74b2d | 59 | volatile float range9; |
sowmy87 | 0:637fe5c74b2d | 60 | volatile float range10; |
sowmy87 | 0:637fe5c74b2d | 61 | |
sowmy87 | 0:637fe5c74b2d | 62 | void TickTick(); |
sowmy87 | 0:637fe5c74b2d | 63 | void TackTack(); |
sowmy87 | 0:637fe5c74b2d | 64 | void FlashLEDs(); |
sowmy87 | 0:637fe5c74b2d | 65 | |
sowmy87 | 0:637fe5c74b2d | 66 | DigitalOut *led1; |
sowmy87 | 0:637fe5c74b2d | 67 | DigitalOut *led2; |
sowmy87 | 0:637fe5c74b2d | 68 | DigitalOut *led3; |
sowmy87 | 0:637fe5c74b2d | 69 | PID *pid; |
sowmy87 | 0:637fe5c74b2d | 70 | Ticker ticker1; |
sowmy87 | 0:637fe5c74b2d | 71 | Ticker ticker2; |
sowmy87 | 0:637fe5c74b2d | 72 | Ticker ticker3; |
sowmy87 | 0:637fe5c74b2d | 73 | |
sowmy87 | 0:637fe5c74b2d | 74 | Serializer base; |
sowmy87 | 0:637fe5c74b2d | 75 | CMPS03 *compass; |
sowmy87 | 0:637fe5c74b2d | 76 | // SRF05 *sensor; |
sowmy87 | 0:637fe5c74b2d | 77 | Servo *servo; |
sowmy87 | 0:637fe5c74b2d | 78 | |
sowmy87 | 0:637fe5c74b2d | 79 | float *range; |
sowmy87 | 0:637fe5c74b2d | 80 | float *returnRange; |
sowmy87 | 0:637fe5c74b2d | 81 | int readingNumber; |
sowmy87 | 0:637fe5c74b2d | 82 | |
sowmy87 | 0:637fe5c74b2d | 83 | }; |
sowmy87 | 0:637fe5c74b2d | 84 | #endif |