IMU measurement + Speed controller

Dependencies:   mbed

Committer:
boro
Date:
Thu May 30 12:41:57 2019 +0000
Revision:
0:5a93e4916fb1
IMU + measure

Who changed what in which revision?

UserRevisionLine numberNew contents of line
boro 0:5a93e4916fb1 1 #ifndef CONTROLLER_H_
boro 0:5a93e4916fb1 2 #define CONTROLLER_H_
boro 0:5a93e4916fb1 3 #include <cstdlib>
boro 0:5a93e4916fb1 4 #include <mbed.h>
boro 0:5a93e4916fb1 5 #include "EncoderCounter.h"
boro 0:5a93e4916fb1 6 #include "LowpassFilter.h"
boro 0:5a93e4916fb1 7
boro 0:5a93e4916fb1 8 class Controller
boro 0:5a93e4916fb1 9 {
boro 0:5a93e4916fb1 10
boro 0:5a93e4916fb1 11 public:
boro 0:5a93e4916fb1 12
boro 0:5a93e4916fb1 13 Controller(PwmOut& pwmLeft, PwmOut& pwmRight,
boro 0:5a93e4916fb1 14 EncoderCounter& counterLeft, EncoderCounter& counterRight);
boro 0:5a93e4916fb1 15
boro 0:5a93e4916fb1 16 virtual ~Controller();
boro 0:5a93e4916fb1 17 void setDesiredSpeedLeft(float desiredSpeedLeft);
boro 0:5a93e4916fb1 18 void setDesiredSpeedRight(float desiredSpeedRight);
boro 0:5a93e4916fb1 19 float getSpeedLeft();
boro 0:5a93e4916fb1 20 float getSpeedRight();
boro 0:5a93e4916fb1 21 float getIntegralLeft();
boro 0:5a93e4916fb1 22 float getIntegralRight();
boro 0:5a93e4916fb1 23 float getProportionalLeft();
boro 0:5a93e4916fb1 24 float getProportionalRight();
boro 0:5a93e4916fb1 25
boro 0:5a93e4916fb1 26 private:
boro 0:5a93e4916fb1 27
boro 0:5a93e4916fb1 28 static const float PERIOD;
boro 0:5a93e4916fb1 29 static const float COUNTS_PER_TURN;
boro 0:5a93e4916fb1 30 static const float LOWPASS_FILTER_FREQUENCY;
boro 0:5a93e4916fb1 31 static const float KN;
boro 0:5a93e4916fb1 32 static const float KP;
boro 0:5a93e4916fb1 33 static const float KI;
boro 0:5a93e4916fb1 34 static const float I_MAX;
boro 0:5a93e4916fb1 35 static const float MAX_VOLTAGE;
boro 0:5a93e4916fb1 36 static const float MIN_DUTY_CYCLE;
boro 0:5a93e4916fb1 37 static const float MAX_DUTY_CYCLE;
boro 0:5a93e4916fb1 38
boro 0:5a93e4916fb1 39 PwmOut& pwmLeft;
boro 0:5a93e4916fb1 40 PwmOut& pwmRight;
boro 0:5a93e4916fb1 41 EncoderCounter& counterLeft;
boro 0:5a93e4916fb1 42 EncoderCounter& counterRight;
boro 0:5a93e4916fb1 43 short previousValueCounterLeft;
boro 0:5a93e4916fb1 44 short previousValueCounterRight;
boro 0:5a93e4916fb1 45 LowpassFilter speedLeftFilter;
boro 0:5a93e4916fb1 46 LowpassFilter speedRightFilter;
boro 0:5a93e4916fb1 47 float desiredSpeedLeft;
boro 0:5a93e4916fb1 48 float desiredSpeedRight;
boro 0:5a93e4916fb1 49 float actualSpeedLeft;
boro 0:5a93e4916fb1 50 float actualSpeedRight;
boro 0:5a93e4916fb1 51 float iSumLeft;
boro 0:5a93e4916fb1 52 float iSumRight;
boro 0:5a93e4916fb1 53 Ticker ticker;
boro 0:5a93e4916fb1 54
boro 0:5a93e4916fb1 55 void run();
boro 0:5a93e4916fb1 56
boro 0:5a93e4916fb1 57 };
boro 0:5a93e4916fb1 58
boro 0:5a93e4916fb1 59 #endif /* CONTROLLER_H_ */