Terrabots
/
Tracker2
Made distance public
Fork of Tracker by
Tracker.h
- Committer:
- simplyellow
- Date:
- 2017-02-14
- Revision:
- 5:757a984ac553
- Parent:
- 0:8038ea3ee241
- Child:
- 6:50f337affc44
File content as of revision 5:757a984ac553:
/** * @file Tracker.h * * @brief Tracker class implements API for sensing the position of the * dump truck. * * @author Terrabots Team * */ #ifndef TRACKER_H #define TRACKER_H #include "mbed.h" #include "QEI.h" /** * @class Tracker * * @brief Interface for tracking the position of a Dump Truck configured * "robot." */ #define STRAIGHT 0 #define CCW 1 #define CW 2 #define PI 3.14159265 class Tracker { public: /** * Constructor for the Tracker object. * * @param[in] _chA The interrupt pin used for channel A * @param[in] _chB The interrupt pin used for channel B * @param[in] _pot The AnalogIn pin used for the potentiometer */ Tracker(PinName _chA, PinName _chB, PinName _pot); /** * Set initial position and distance traveled to 0. */ void clear(); /** * Set a reference "zero angle" for the potentiometer and wait five * seconds for the user to set a turning angle. */ void potSetup(); /** * Set a direction, either clockwise or counterclockwise, for the * dump truck, based on the turning angle. */ void setDirection(); /** * Check if the dump truck has moved before starting position-tracking * calculations. */ void checkToStart(); /** * Calculate the x and y position of the dump truck based on sensor * measurements. */ void calcDisplacement(); private: QEI *wheel; PinName chA; PinName chB; AnalogIn pot; float pulseCount; float encoding; float circumference; float constant; float distance; float x; float y; float value; float turnAngle; float zeroAngle; int dir; float df; float db; float W; float R; float dispAngle; }; #endif