PES2_mbed_os_6

Dependencies:   Servo

Revision:
0:5d4d21d56334
Child:
3:a292bdaf03f6
diff -r 000000000000 -r 5d4d21d56334 Controller.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Controller.h	Fri Mar 12 13:04:33 2021 +0000
@@ -0,0 +1,58 @@
+#ifndef CONTROLLER_H_
+#define CONTROLLER_H_
+#include <cstdlib>
+#include <mbed.h>
+#include "EncoderCounter.h"
+#include "LowpassFilter.h"
+#include "ThreadFlag.h"
+
+class Controller
+{
+
+public:
+
+    Controller(PwmOut& pwmLeft, PwmOut& pwmRight,
+               EncoderCounter& counterLeft, EncoderCounter& counterRight);
+
+    virtual ~Controller();
+    void setDesiredSpeedLeft(float desiredSpeedLeft);
+    void setDesiredSpeedRight(float desiredSpeedRight);
+    float getSpeedLeft();
+    float getSpeedRight();
+
+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;
+    float               actualAngleLeft;
+    float               actualAngleRight;
+    
+    ThreadFlag          threadFlag;
+    Thread              thread;
+    Ticker              ticker;
+    
+    void                sendThreadFlag();
+    void                run();
+
+};
+
+#endif /* CONTROLLER_H_ */
\ No newline at end of file