Grundfunktionen für Micromouse
Dependencies: AutomationElements mbed
MotorDriver/Controller.h@0:e38b500d6e74, 2018-04-19 (annotated)
- Committer:
- wengefa1
- Date:
- Thu Apr 19 11:31:49 2018 +0000
- Revision:
- 0:e38b500d6e74
keine Regelung vorhanden
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wengefa1 | 0:e38b500d6e74 | 1 | #ifndef CONTROLLER_H_ |
wengefa1 | 0:e38b500d6e74 | 2 | #define CONTROLLER_H_ |
wengefa1 | 0:e38b500d6e74 | 3 | #include <cstdlib> |
wengefa1 | 0:e38b500d6e74 | 4 | #include <mbed.h> |
wengefa1 | 0:e38b500d6e74 | 5 | #include "EncoderCounter.h" |
wengefa1 | 0:e38b500d6e74 | 6 | #include "LowpassFilter.h" |
wengefa1 | 0:e38b500d6e74 | 7 | |
wengefa1 | 0:e38b500d6e74 | 8 | class Controller |
wengefa1 | 0:e38b500d6e74 | 9 | { |
wengefa1 | 0:e38b500d6e74 | 10 | |
wengefa1 | 0:e38b500d6e74 | 11 | public: |
wengefa1 | 0:e38b500d6e74 | 12 | |
wengefa1 | 0:e38b500d6e74 | 13 | Controller(PwmOut& pwmLeft, PwmOut& pwmRight, |
wengefa1 | 0:e38b500d6e74 | 14 | EncoderCounter& counterLeft, EncoderCounter& counterRight); |
wengefa1 | 0:e38b500d6e74 | 15 | |
wengefa1 | 0:e38b500d6e74 | 16 | virtual ~Controller(); |
wengefa1 | 0:e38b500d6e74 | 17 | void setDesiredSpeedLeft(float desiredSpeedLeft); |
wengefa1 | 0:e38b500d6e74 | 18 | void setDesiredSpeedRight(float desiredSpeedRight); |
wengefa1 | 0:e38b500d6e74 | 19 | void AttachTicker(void); |
wengefa1 | 0:e38b500d6e74 | 20 | void DetachTicker(void); |
wengefa1 | 0:e38b500d6e74 | 21 | float getSpeedLeft(); |
wengefa1 | 0:e38b500d6e74 | 22 | float getSpeedRight(); |
wengefa1 | 0:e38b500d6e74 | 23 | float getIntegralLeft(); |
wengefa1 | 0:e38b500d6e74 | 24 | float getIntegralRight(); |
wengefa1 | 0:e38b500d6e74 | 25 | float getProportionalLeft(); |
wengefa1 | 0:e38b500d6e74 | 26 | float getProportionalRight(); |
wengefa1 | 0:e38b500d6e74 | 27 | |
wengefa1 | 0:e38b500d6e74 | 28 | private: |
wengefa1 | 0:e38b500d6e74 | 29 | |
wengefa1 | 0:e38b500d6e74 | 30 | static const float PERIOD; |
wengefa1 | 0:e38b500d6e74 | 31 | static const float COUNTS_PER_TURN; |
wengefa1 | 0:e38b500d6e74 | 32 | static const float LOWPASS_FILTER_FREQUENCY; |
wengefa1 | 0:e38b500d6e74 | 33 | static const float KN; |
wengefa1 | 0:e38b500d6e74 | 34 | static const float KP; |
wengefa1 | 0:e38b500d6e74 | 35 | static const float KI; |
wengefa1 | 0:e38b500d6e74 | 36 | static const float I_MAX; |
wengefa1 | 0:e38b500d6e74 | 37 | static const float MAX_VOLTAGE; |
wengefa1 | 0:e38b500d6e74 | 38 | static const float MIN_DUTY_CYCLE; |
wengefa1 | 0:e38b500d6e74 | 39 | static const float MAX_DUTY_CYCLE; |
wengefa1 | 0:e38b500d6e74 | 40 | |
wengefa1 | 0:e38b500d6e74 | 41 | PwmOut& pwmLeft; |
wengefa1 | 0:e38b500d6e74 | 42 | PwmOut& pwmRight; |
wengefa1 | 0:e38b500d6e74 | 43 | EncoderCounter& counterLeft; |
wengefa1 | 0:e38b500d6e74 | 44 | EncoderCounter& counterRight; |
wengefa1 | 0:e38b500d6e74 | 45 | short previousValueCounterLeft; |
wengefa1 | 0:e38b500d6e74 | 46 | short previousValueCounterRight; |
wengefa1 | 0:e38b500d6e74 | 47 | LowpassFilter speedLeftFilter; |
wengefa1 | 0:e38b500d6e74 | 48 | LowpassFilter speedRightFilter; |
wengefa1 | 0:e38b500d6e74 | 49 | float desiredSpeedLeft; |
wengefa1 | 0:e38b500d6e74 | 50 | float desiredSpeedRight; |
wengefa1 | 0:e38b500d6e74 | 51 | float actualSpeedLeft; |
wengefa1 | 0:e38b500d6e74 | 52 | float actualSpeedRight; |
wengefa1 | 0:e38b500d6e74 | 53 | float iSumLeft; |
wengefa1 | 0:e38b500d6e74 | 54 | float iSumRight; |
wengefa1 | 0:e38b500d6e74 | 55 | Ticker ticker; |
wengefa1 | 0:e38b500d6e74 | 56 | |
wengefa1 | 0:e38b500d6e74 | 57 | void run(); |
wengefa1 | 0:e38b500d6e74 | 58 | |
wengefa1 | 0:e38b500d6e74 | 59 | }; |
wengefa1 | 0:e38b500d6e74 | 60 | |
wengefa1 | 0:e38b500d6e74 | 61 | #endif /* CONTROLLER_H_ */ |
wengefa1 | 0:e38b500d6e74 | 62 | |
wengefa1 | 0:e38b500d6e74 | 63 | |
wengefa1 | 0:e38b500d6e74 | 64 | |
wengefa1 | 0:e38b500d6e74 | 65 | |
wengefa1 | 0:e38b500d6e74 | 66 | |
wengefa1 | 0:e38b500d6e74 | 67 | |
wengefa1 | 0:e38b500d6e74 | 68 |