![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Version12.04.18
Dependencies: mbed
Fork of Micromouse_alpha_copy_copy by
Controller.h@1:d9e840c48b1e, 2018-03-31 (annotated)
- Committer:
- ruesipat
- Date:
- Sat Mar 31 16:45:57 2018 +0000
- Revision:
- 1:d9e840c48b1e
- Parent:
- 0:a9fe4ef404bf
j
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ruesipat | 0:a9fe4ef404bf | 1 | #ifndef CONTROLLER_H_ |
ruesipat | 0:a9fe4ef404bf | 2 | #define CONTROLLER_H_ |
ruesipat | 0:a9fe4ef404bf | 3 | #include <cstdlib> |
ruesipat | 0:a9fe4ef404bf | 4 | #include <mbed.h> |
ruesipat | 0:a9fe4ef404bf | 5 | #include "EncoderCounter.h" |
ruesipat | 0:a9fe4ef404bf | 6 | #include "LowpassFilter.h" |
ruesipat | 0:a9fe4ef404bf | 7 | |
ruesipat | 0:a9fe4ef404bf | 8 | class Controller |
ruesipat | 0:a9fe4ef404bf | 9 | { |
ruesipat | 0:a9fe4ef404bf | 10 | |
ruesipat | 0:a9fe4ef404bf | 11 | public: |
ruesipat | 0:a9fe4ef404bf | 12 | |
ruesipat | 0:a9fe4ef404bf | 13 | Controller(PwmOut& pwmLeft, PwmOut& pwmRight, |
ruesipat | 0:a9fe4ef404bf | 14 | EncoderCounter& counterLeft, EncoderCounter& counterRight); |
ruesipat | 0:a9fe4ef404bf | 15 | |
ruesipat | 0:a9fe4ef404bf | 16 | virtual ~Controller(); |
ruesipat | 0:a9fe4ef404bf | 17 | void setDesiredSpeedLeft(float desiredSpeedLeft); |
ruesipat | 0:a9fe4ef404bf | 18 | void setDesiredSpeedRight(float desiredSpeedRight); |
ruesipat | 1:d9e840c48b1e | 19 | float getSpeedLeft(); |
ruesipat | 1:d9e840c48b1e | 20 | float getSpeedRight(); |
ruesipat | 1:d9e840c48b1e | 21 | float getIntegralLeft(); |
ruesipat | 1:d9e840c48b1e | 22 | float getIntegralRight(); |
ruesipat | 1:d9e840c48b1e | 23 | float getProportionalLeft(); |
ruesipat | 1:d9e840c48b1e | 24 | float getProportionalRight(); |
ruesipat | 0:a9fe4ef404bf | 25 | |
ruesipat | 0:a9fe4ef404bf | 26 | private: |
ruesipat | 0:a9fe4ef404bf | 27 | |
ruesipat | 0:a9fe4ef404bf | 28 | static const float PERIOD; |
ruesipat | 0:a9fe4ef404bf | 29 | static const float COUNTS_PER_TURN; |
ruesipat | 0:a9fe4ef404bf | 30 | static const float LOWPASS_FILTER_FREQUENCY; |
ruesipat | 0:a9fe4ef404bf | 31 | static const float KN; |
ruesipat | 0:a9fe4ef404bf | 32 | static const float KP; |
ruesipat | 1:d9e840c48b1e | 33 | static const float KI; |
ruesipat | 1:d9e840c48b1e | 34 | static const float I_MAX; |
ruesipat | 0:a9fe4ef404bf | 35 | static const float MAX_VOLTAGE; |
ruesipat | 0:a9fe4ef404bf | 36 | static const float MIN_DUTY_CYCLE; |
ruesipat | 0:a9fe4ef404bf | 37 | static const float MAX_DUTY_CYCLE; |
ruesipat | 0:a9fe4ef404bf | 38 | |
ruesipat | 0:a9fe4ef404bf | 39 | PwmOut& pwmLeft; |
ruesipat | 0:a9fe4ef404bf | 40 | PwmOut& pwmRight; |
ruesipat | 0:a9fe4ef404bf | 41 | EncoderCounter& counterLeft; |
ruesipat | 0:a9fe4ef404bf | 42 | EncoderCounter& counterRight; |
ruesipat | 0:a9fe4ef404bf | 43 | short previousValueCounterLeft; |
ruesipat | 0:a9fe4ef404bf | 44 | short previousValueCounterRight; |
ruesipat | 0:a9fe4ef404bf | 45 | LowpassFilter speedLeftFilter; |
ruesipat | 0:a9fe4ef404bf | 46 | LowpassFilter speedRightFilter; |
ruesipat | 0:a9fe4ef404bf | 47 | float desiredSpeedLeft; |
ruesipat | 0:a9fe4ef404bf | 48 | float desiredSpeedRight; |
ruesipat | 0:a9fe4ef404bf | 49 | float actualSpeedLeft; |
ruesipat | 0:a9fe4ef404bf | 50 | float actualSpeedRight; |
ruesipat | 1:d9e840c48b1e | 51 | float iSumLeft; |
ruesipat | 1:d9e840c48b1e | 52 | float iSumRight; |
ruesipat | 0:a9fe4ef404bf | 53 | Ticker ticker; |
ruesipat | 1:d9e840c48b1e | 54 | |
ruesipat | 0:a9fe4ef404bf | 55 | void run(); |
ruesipat | 0:a9fe4ef404bf | 56 | |
ruesipat | 0:a9fe4ef404bf | 57 | }; |
ruesipat | 0:a9fe4ef404bf | 58 | |
ruesipat | 0:a9fe4ef404bf | 59 | #endif /* CONTROLLER_H_ */ |
ruesipat | 0:a9fe4ef404bf | 60 | |
ruesipat | 0:a9fe4ef404bf | 61 | |
ruesipat | 0:a9fe4ef404bf | 62 | |
ruesipat | 0:a9fe4ef404bf | 63 | |
ruesipat | 0:a9fe4ef404bf | 64 |