---
Dependencies: mbed
Fork of MicroMouse_MASTER_FIVE by
Diff: Controller.h
- Revision:
- 0:a9fe4ef404bf
- Child:
- 1:d9e840c48b1e
diff -r 000000000000 -r a9fe4ef404bf Controller.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Controller.h Wed Mar 07 14:06:19 2018 +0000 @@ -0,0 +1,54 @@ +#ifndef CONTROLLER_H_ +#define CONTROLLER_H_ +#include <cstdlib> +#include <mbed.h> +#include "EncoderCounter.h" +#include "LowpassFilter.h" + +class Controller +{ + +public: + + Controller(PwmOut& pwmLeft, PwmOut& pwmRight, + EncoderCounter& counterLeft, EncoderCounter& counterRight); + + virtual ~Controller(); + void setDesiredSpeedLeft(float desiredSpeedLeft); + void setDesiredSpeedRight(float desiredSpeedRight); + +private: + + static const float PERIOD; + static const float COUNTS_PER_TURN; + static const float LOWPASS_FILTER_FREQUENCY; + static const float KN; + static const float KP; + static const float MAX_VOLTAGE; + static const float MIN_DUTY_CYCLE; + static const float MAX_DUTY_CYCLE; + + PwmOut& pwmLeft; + PwmOut& pwmRight; + EncoderCounter& counterLeft; + EncoderCounter& counterRight; + short previousValueCounterLeft; + short previousValueCounterRight; + LowpassFilter speedLeftFilter; + LowpassFilter speedRightFilter; + float desiredSpeedLeft; + float desiredSpeedRight; + float actualSpeedLeft; + float actualSpeedRight; + Ticker ticker; + + void run(); + +}; + +#endif /* CONTROLLER_H_ */ + + + + +