Nim leo niiiim
Controller.h@0:da791f233257, 2018-05-11 (annotated)
- Committer:
- Kiwicjam
- Date:
- Fri May 11 12:21:19 2018 +0000
- Revision:
- 0:da791f233257
start of rome2 p5;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kiwicjam | 0:da791f233257 | 1 | /* |
Kiwicjam | 0:da791f233257 | 2 | * Controller.h |
Kiwicjam | 0:da791f233257 | 3 | * Copyright (c) 2018, ZHAW |
Kiwicjam | 0:da791f233257 | 4 | * All rights reserved. |
Kiwicjam | 0:da791f233257 | 5 | */ |
Kiwicjam | 0:da791f233257 | 6 | |
Kiwicjam | 0:da791f233257 | 7 | #ifndef CONTROLLER_H_ |
Kiwicjam | 0:da791f233257 | 8 | #define CONTROLLER_H_ |
Kiwicjam | 0:da791f233257 | 9 | |
Kiwicjam | 0:da791f233257 | 10 | #include <cstdlib> |
Kiwicjam | 0:da791f233257 | 11 | #include <mbed.h> |
Kiwicjam | 0:da791f233257 | 12 | #include "EncoderCounter.h" |
Kiwicjam | 0:da791f233257 | 13 | #include "Motion.h" |
Kiwicjam | 0:da791f233257 | 14 | #include "LowpassFilter.h" |
Kiwicjam | 0:da791f233257 | 15 | |
Kiwicjam | 0:da791f233257 | 16 | /** |
Kiwicjam | 0:da791f233257 | 17 | * This class implements the coordinate transformation, speed control and |
Kiwicjam | 0:da791f233257 | 18 | * the position estimation of a mobile robot with differential drive. |
Kiwicjam | 0:da791f233257 | 19 | */ |
Kiwicjam | 0:da791f233257 | 20 | class Controller { |
Kiwicjam | 0:da791f233257 | 21 | |
Kiwicjam | 0:da791f233257 | 22 | public: |
Kiwicjam | 0:da791f233257 | 23 | |
Kiwicjam | 0:da791f233257 | 24 | Controller(PwmOut& pwmLeft, PwmOut& pwmRight, EncoderCounter& counterLeft, EncoderCounter& counterRight); |
Kiwicjam | 0:da791f233257 | 25 | virtual ~Controller(); |
Kiwicjam | 0:da791f233257 | 26 | void setTranslationalVelocity(float velocity); |
Kiwicjam | 0:da791f233257 | 27 | void setRotationalVelocity(float velocity); |
Kiwicjam | 0:da791f233257 | 28 | float getActualTranslationalVelocity(); |
Kiwicjam | 0:da791f233257 | 29 | float getActualRotationalVelocity(); |
Kiwicjam | 0:da791f233257 | 30 | void setX(float x); |
Kiwicjam | 0:da791f233257 | 31 | float getX(); |
Kiwicjam | 0:da791f233257 | 32 | void setY(float y); |
Kiwicjam | 0:da791f233257 | 33 | float getY(); |
Kiwicjam | 0:da791f233257 | 34 | void setAlpha(float alpha); |
Kiwicjam | 0:da791f233257 | 35 | float getAlpha(); |
Kiwicjam | 0:da791f233257 | 36 | |
Kiwicjam | 0:da791f233257 | 37 | private: |
Kiwicjam | 0:da791f233257 | 38 | |
Kiwicjam | 0:da791f233257 | 39 | static const float PERIOD; |
Kiwicjam | 0:da791f233257 | 40 | static const float PI; |
Kiwicjam | 0:da791f233257 | 41 | static const float WHEEL_DISTANCE; |
Kiwicjam | 0:da791f233257 | 42 | static const float WHEEL_RADIUS; |
Kiwicjam | 0:da791f233257 | 43 | static const float COUNTS_PER_TURN; |
Kiwicjam | 0:da791f233257 | 44 | static const float LOWPASS_FILTER_FREQUENCY; |
Kiwicjam | 0:da791f233257 | 45 | static const float KN; |
Kiwicjam | 0:da791f233257 | 46 | static const float KP; |
Kiwicjam | 0:da791f233257 | 47 | static const float MAX_VOLTAGE; |
Kiwicjam | 0:da791f233257 | 48 | static const float MIN_DUTY_CYCLE; |
Kiwicjam | 0:da791f233257 | 49 | static const float MAX_DUTY_CYCLE; |
Kiwicjam | 0:da791f233257 | 50 | |
Kiwicjam | 0:da791f233257 | 51 | PwmOut& pwmLeft; |
Kiwicjam | 0:da791f233257 | 52 | PwmOut& pwmRight; |
Kiwicjam | 0:da791f233257 | 53 | EncoderCounter& counterLeft; |
Kiwicjam | 0:da791f233257 | 54 | EncoderCounter& counterRight; |
Kiwicjam | 0:da791f233257 | 55 | Motion translationalMotion; |
Kiwicjam | 0:da791f233257 | 56 | Motion rotationalMotion; |
Kiwicjam | 0:da791f233257 | 57 | float translationalVelocity; |
Kiwicjam | 0:da791f233257 | 58 | float rotationalVelocity; |
Kiwicjam | 0:da791f233257 | 59 | float actualTranslationalVelocity; |
Kiwicjam | 0:da791f233257 | 60 | float actualRotationalVelocity; |
Kiwicjam | 0:da791f233257 | 61 | short previousValueCounterLeft; |
Kiwicjam | 0:da791f233257 | 62 | short previousValueCounterRight; |
Kiwicjam | 0:da791f233257 | 63 | LowpassFilter speedLeftFilter; |
Kiwicjam | 0:da791f233257 | 64 | LowpassFilter speedRightFilter; |
Kiwicjam | 0:da791f233257 | 65 | float desiredSpeedLeft; |
Kiwicjam | 0:da791f233257 | 66 | float desiredSpeedRight; |
Kiwicjam | 0:da791f233257 | 67 | float actualSpeedLeft; |
Kiwicjam | 0:da791f233257 | 68 | float actualSpeedRight; |
Kiwicjam | 0:da791f233257 | 69 | float x; |
Kiwicjam | 0:da791f233257 | 70 | float y; |
Kiwicjam | 0:da791f233257 | 71 | float alpha; |
Kiwicjam | 0:da791f233257 | 72 | Ticker ticker; |
Kiwicjam | 0:da791f233257 | 73 | |
Kiwicjam | 0:da791f233257 | 74 | void run(); |
Kiwicjam | 0:da791f233257 | 75 | }; |
Kiwicjam | 0:da791f233257 | 76 | |
Kiwicjam | 0:da791f233257 | 77 | #endif /* CONTROLLER_H_ */ |
Kiwicjam | 0:da791f233257 | 78 |