Used to track the robot's position and initialise an m3pi object to drive the robot
Navigate_Pololu.h@3:c5dff598fea4, 2016-03-04 (annotated)
- Committer:
- sleighton
- Date:
- Fri Mar 04 18:46:26 2016 +0000
- Revision:
- 3:c5dff598fea4
- Parent:
- 2:1255feea1c59
Before Tidy up
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sleighton | 0:33c364521d16 | 1 | #include "mbed.h" |
sleighton | 2:1255feea1c59 | 2 | #include "m3pi.h" |
sleighton | 0:33c364521d16 | 3 | |
sleighton | 0:33c364521d16 | 4 | class Navigate_Pololu{ |
sleighton | 0:33c364521d16 | 5 | |
sleighton | 0:33c364521d16 | 6 | private: |
sleighton | 2:1255feea1c59 | 7 | const float PI = 3.14159f; //declare constants for pi and 2pi |
sleighton | 0:33c364521d16 | 8 | const float TWO_PI = PI * 2.0f; |
sleighton | 0:33c364521d16 | 9 | float distancePerCount; |
sleighton | 0:33c364521d16 | 10 | float radiansPerCount; |
sleighton | 0:33c364521d16 | 11 | float X; |
sleighton | 0:33c364521d16 | 12 | float Y; |
sleighton | 0:33c364521d16 | 13 | float heading; |
sleighton | 0:33c364521d16 | 14 | int previousLeftCounts; |
sleighton | 0:33c364521d16 | 15 | int previousRightCounts; |
sleighton | 0:33c364521d16 | 16 | float deltaDistance; |
sleighton | 0:33c364521d16 | 17 | float deltaX; |
sleighton | 0:33c364521d16 | 18 | float deltaY; |
sleighton | 0:33c364521d16 | 19 | int leftCounts; |
sleighton | 0:33c364521d16 | 20 | int rightCounts; |
sleighton | 0:33c364521d16 | 21 | int deltaLeft; |
sleighton | 0:33c364521d16 | 22 | int deltaRight; |
sleighton | 0:33c364521d16 | 23 | float deltaHeading; |
sleighton | 0:33c364521d16 | 24 | InterruptIn leftOpto; |
sleighton | 0:33c364521d16 | 25 | InterruptIn rightOpto; |
sleighton | 0:33c364521d16 | 26 | |
sleighton | 0:33c364521d16 | 27 | public: |
sleighton | 0:33c364521d16 | 28 | |
sleighton | 2:1255feea1c59 | 29 | m3pi robot; //create robot object, make it public so it can be accessed by main program |
sleighton | 2:1255feea1c59 | 30 | |
sleighton | 1:b6c1de65e591 | 31 | Navigate_Pololu(PinName leftIn, PinName rightIn, int countsPerRevolution, float wheelDiameter, float trackWidth,PinName robotTx, PinName robotRx); |
sleighton | 2:1255feea1c59 | 32 | //constuctor |
sleighton | 0:33c364521d16 | 33 | |
sleighton | 0:33c364521d16 | 34 | void leftWheelInterrupt(); |
sleighton | 0:33c364521d16 | 35 | //IRQ for left wheel sensor |
sleighton | 0:33c364521d16 | 36 | |
sleighton | 0:33c364521d16 | 37 | void rightWheelInterrupt(); |
sleighton | 0:33c364521d16 | 38 | //IRQ for right wheel sensor |
sleighton | 0:33c364521d16 | 39 | |
sleighton | 0:33c364521d16 | 40 | void UpdatePosition(); |
sleighton | 0:33c364521d16 | 41 | //Updates position based on wheel counts |
sleighton | 1:b6c1de65e591 | 42 | int getX(); |
sleighton | 0:33c364521d16 | 43 | //returns x coordinate |
sleighton | 0:33c364521d16 | 44 | |
sleighton | 1:b6c1de65e591 | 45 | int getY(); |
sleighton | 0:33c364521d16 | 46 | //returns y coordinate |
sleighton | 0:33c364521d16 | 47 | |
sleighton | 1:b6c1de65e591 | 48 | int getHeading(); |
sleighton | 0:33c364521d16 | 49 | //returns heading |
sleighton | 1:b6c1de65e591 | 50 | |
sleighton | 2:1255feea1c59 | 51 | void calibratePos(); |
sleighton | 1:b6c1de65e591 | 52 | //aligns wheels |
sleighton | 3:c5dff598fea4 | 53 | |
sleighton | 3:c5dff598fea4 | 54 | void resetCoordinates(); |
sleighton | 3:c5dff598fea4 | 55 | //resets X and Y coordinates |
sleighton | 0:33c364521d16 | 56 | }; |