![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
PES2_mbed_os_6
Controller.h@0:5d4d21d56334, 2021-03-12 (annotated)
- Committer:
- boro
- Date:
- Fri Mar 12 13:04:33 2021 +0000
- Revision:
- 0:5d4d21d56334
- Child:
- 3:a292bdaf03f6
controller added;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
boro | 0:5d4d21d56334 | 1 | #ifndef CONTROLLER_H_ |
boro | 0:5d4d21d56334 | 2 | #define CONTROLLER_H_ |
boro | 0:5d4d21d56334 | 3 | #include <cstdlib> |
boro | 0:5d4d21d56334 | 4 | #include <mbed.h> |
boro | 0:5d4d21d56334 | 5 | #include "EncoderCounter.h" |
boro | 0:5d4d21d56334 | 6 | #include "LowpassFilter.h" |
boro | 0:5d4d21d56334 | 7 | #include "ThreadFlag.h" |
boro | 0:5d4d21d56334 | 8 | |
boro | 0:5d4d21d56334 | 9 | class Controller |
boro | 0:5d4d21d56334 | 10 | { |
boro | 0:5d4d21d56334 | 11 | |
boro | 0:5d4d21d56334 | 12 | public: |
boro | 0:5d4d21d56334 | 13 | |
boro | 0:5d4d21d56334 | 14 | Controller(PwmOut& pwmLeft, PwmOut& pwmRight, |
boro | 0:5d4d21d56334 | 15 | EncoderCounter& counterLeft, EncoderCounter& counterRight); |
boro | 0:5d4d21d56334 | 16 | |
boro | 0:5d4d21d56334 | 17 | virtual ~Controller(); |
boro | 0:5d4d21d56334 | 18 | void setDesiredSpeedLeft(float desiredSpeedLeft); |
boro | 0:5d4d21d56334 | 19 | void setDesiredSpeedRight(float desiredSpeedRight); |
boro | 0:5d4d21d56334 | 20 | float getSpeedLeft(); |
boro | 0:5d4d21d56334 | 21 | float getSpeedRight(); |
boro | 0:5d4d21d56334 | 22 | |
boro | 0:5d4d21d56334 | 23 | private: |
boro | 0:5d4d21d56334 | 24 | |
boro | 0:5d4d21d56334 | 25 | static const float PERIOD; |
boro | 0:5d4d21d56334 | 26 | static const float COUNTS_PER_TURN; |
boro | 0:5d4d21d56334 | 27 | static const float LOWPASS_FILTER_FREQUENCY; |
boro | 0:5d4d21d56334 | 28 | static const float KN; |
boro | 0:5d4d21d56334 | 29 | static const float KP; |
boro | 0:5d4d21d56334 | 30 | static const float MAX_VOLTAGE; |
boro | 0:5d4d21d56334 | 31 | static const float MIN_DUTY_CYCLE; |
boro | 0:5d4d21d56334 | 32 | static const float MAX_DUTY_CYCLE; |
boro | 0:5d4d21d56334 | 33 | |
boro | 0:5d4d21d56334 | 34 | PwmOut& pwmLeft; |
boro | 0:5d4d21d56334 | 35 | PwmOut& pwmRight; |
boro | 0:5d4d21d56334 | 36 | EncoderCounter& counterLeft; |
boro | 0:5d4d21d56334 | 37 | EncoderCounter& counterRight; |
boro | 0:5d4d21d56334 | 38 | short previousValueCounterLeft; |
boro | 0:5d4d21d56334 | 39 | short previousValueCounterRight; |
boro | 0:5d4d21d56334 | 40 | LowpassFilter speedLeftFilter; |
boro | 0:5d4d21d56334 | 41 | LowpassFilter speedRightFilter; |
boro | 0:5d4d21d56334 | 42 | float desiredSpeedLeft; |
boro | 0:5d4d21d56334 | 43 | float desiredSpeedRight; |
boro | 0:5d4d21d56334 | 44 | float actualSpeedLeft; |
boro | 0:5d4d21d56334 | 45 | float actualSpeedRight; |
boro | 0:5d4d21d56334 | 46 | float actualAngleLeft; |
boro | 0:5d4d21d56334 | 47 | float actualAngleRight; |
boro | 0:5d4d21d56334 | 48 | |
boro | 0:5d4d21d56334 | 49 | ThreadFlag threadFlag; |
boro | 0:5d4d21d56334 | 50 | Thread thread; |
boro | 0:5d4d21d56334 | 51 | Ticker ticker; |
boro | 0:5d4d21d56334 | 52 | |
boro | 0:5d4d21d56334 | 53 | void sendThreadFlag(); |
boro | 0:5d4d21d56334 | 54 | void run(); |
boro | 0:5d4d21d56334 | 55 | |
boro | 0:5d4d21d56334 | 56 | }; |
boro | 0:5d4d21d56334 | 57 | |
boro | 0:5d4d21d56334 | 58 | #endif /* CONTROLLER_H_ */ |