Used to track the robot's position and initialise an m3pi object to drive the robot
Navigate_Pololu.h
- Committer:
- sleighton
- Date:
- 2016-01-31
- Revision:
- 2:1255feea1c59
- Parent:
- 1:b6c1de65e591
- Child:
- 3:c5dff598fea4
File content as of revision 2:1255feea1c59:
#include "mbed.h" #include "m3pi.h" class Navigate_Pololu{ private: const float PI = 3.14159f; //declare constants for pi and 2pi const float TWO_PI = PI * 2.0f; float distancePerCount; float radiansPerCount; float X; float Y; float heading; int previousLeftCounts; int previousRightCounts; float deltaDistance; float deltaX; float deltaY; int leftCounts; int rightCounts; int deltaLeft; int deltaRight; float deltaHeading; InterruptIn leftOpto; InterruptIn rightOpto; public: m3pi robot; //create robot object, make it public so it can be accessed by main program Navigate_Pololu(PinName leftIn, PinName rightIn, int countsPerRevolution, float wheelDiameter, float trackWidth,PinName robotTx, PinName robotRx); //constuctor void leftWheelInterrupt(); //IRQ for left wheel sensor void rightWheelInterrupt(); //IRQ for right wheel sensor void UpdatePosition(); //Updates position based on wheel counts int getX(); //returns x coordinate int getY(); //returns y coordinate int getHeading(); //returns heading void calibratePos(); //aligns wheels };