Robot.h@1:8fa2ee8c005e, 2010-12-16 (annotated)
- Committer:
- sowmy87
- Date:
- Thu Dec 16 09:37:34 2010 +0000
- Revision:
- 1:8fa2ee8c005e
- Parent:
- 0:637fe5c74b2d
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 | 1:8fa2ee8c005e | 28 | void Stop(); |
sowmy87 | 1:8fa2ee8c005e | 29 | void ClearCount(); |
sowmy87 | 1:8fa2ee8c005e | 30 | float GetDistance(); |
sowmy87 | 1:8fa2ee8c005e | 31 | int GetCount(); |
sowmy87 | 1:8fa2ee8c005e | 32 | |
sowmy87 | 0:637fe5c74b2d | 33 | void PivetLeft(int deg); |
sowmy87 | 0:637fe5c74b2d | 34 | void PivetRight(int deg); |
sowmy87 | 0:637fe5c74b2d | 35 | void Pivet(int deg); |
sowmy87 | 0:637fe5c74b2d | 36 | void DiGo(int inches,int inPsec); |
sowmy87 | 0:637fe5c74b2d | 37 | |
sowmy87 | 0:637fe5c74b2d | 38 | float GetRange(int position); |
sowmy87 | 0:637fe5c74b2d | 39 | |
sowmy87 | 0:637fe5c74b2d | 40 | |
sowmy87 | 0:637fe5c74b2d | 41 | |
sowmy87 | 0:637fe5c74b2d | 42 | //protected: |
sowmy87 | 0:637fe5c74b2d | 43 | |
sowmy87 | 0:637fe5c74b2d | 44 | //private: |
sowmy87 | 0:637fe5c74b2d | 45 | volatile int desiredHeading; |
sowmy87 | 0:637fe5c74b2d | 46 | volatile int actualHeading; |
sowmy87 | 0:637fe5c74b2d | 47 | volatile int deltaHeading; |
sowmy87 | 0:637fe5c74b2d | 48 | volatile int prevDeltaHeading; |
sowmy87 | 0:637fe5c74b2d | 49 | volatile int desiredSpeed; |
sowmy87 | 0:637fe5c74b2d | 50 | volatile int servoPosition;// [0,10] |
sowmy87 | 0:637fe5c74b2d | 51 | volatile int servoDirection; |
sowmy87 | 0:637fe5c74b2d | 52 | volatile int isFullScan; |
sowmy87 | 0:637fe5c74b2d | 53 | |
sowmy87 | 0:637fe5c74b2d | 54 | volatile float range0; |
sowmy87 | 0:637fe5c74b2d | 55 | volatile float range1; |
sowmy87 | 0:637fe5c74b2d | 56 | volatile float range2; |
sowmy87 | 0:637fe5c74b2d | 57 | volatile float range3; |
sowmy87 | 0:637fe5c74b2d | 58 | volatile float range4; |
sowmy87 | 0:637fe5c74b2d | 59 | volatile float range5; |
sowmy87 | 0:637fe5c74b2d | 60 | volatile float range6; |
sowmy87 | 0:637fe5c74b2d | 61 | volatile float range7; |
sowmy87 | 0:637fe5c74b2d | 62 | volatile float range8; |
sowmy87 | 0:637fe5c74b2d | 63 | volatile float range9; |
sowmy87 | 0:637fe5c74b2d | 64 | volatile float range10; |
sowmy87 | 0:637fe5c74b2d | 65 | |
sowmy87 | 0:637fe5c74b2d | 66 | void TickTick(); |
sowmy87 | 0:637fe5c74b2d | 67 | void TackTack(); |
sowmy87 | 0:637fe5c74b2d | 68 | void FlashLEDs(); |
sowmy87 | 0:637fe5c74b2d | 69 | |
sowmy87 | 0:637fe5c74b2d | 70 | DigitalOut *led1; |
sowmy87 | 0:637fe5c74b2d | 71 | DigitalOut *led2; |
sowmy87 | 0:637fe5c74b2d | 72 | DigitalOut *led3; |
sowmy87 | 0:637fe5c74b2d | 73 | PID *pid; |
sowmy87 | 0:637fe5c74b2d | 74 | Ticker ticker1; |
sowmy87 | 0:637fe5c74b2d | 75 | Ticker ticker2; |
sowmy87 | 0:637fe5c74b2d | 76 | Ticker ticker3; |
sowmy87 | 0:637fe5c74b2d | 77 | |
sowmy87 | 0:637fe5c74b2d | 78 | Serializer base; |
sowmy87 | 0:637fe5c74b2d | 79 | CMPS03 *compass; |
sowmy87 | 0:637fe5c74b2d | 80 | // SRF05 *sensor; |
sowmy87 | 0:637fe5c74b2d | 81 | Servo *servo; |
sowmy87 | 0:637fe5c74b2d | 82 | |
sowmy87 | 0:637fe5c74b2d | 83 | float *range; |
sowmy87 | 0:637fe5c74b2d | 84 | float *returnRange; |
sowmy87 | 0:637fe5c74b2d | 85 | int readingNumber; |
sowmy87 | 0:637fe5c74b2d | 86 | |
sowmy87 | 0:637fe5c74b2d | 87 | }; |
sowmy87 | 0:637fe5c74b2d | 88 | #endif |