Marco Oehler / Mbed 2 deprecated ROME2

Dependencies:   mbed

Committer:
oehlemar
Date:
Mon Feb 24 16:05:50 2020 +0000
Revision:
0:7ee4c6416e08
ROME2 P1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
oehlemar 0:7ee4c6416e08 1 /*
oehlemar 0:7ee4c6416e08 2 * Controller.h
oehlemar 0:7ee4c6416e08 3 * Copyright (c) 2020, ZHAW
oehlemar 0:7ee4c6416e08 4 * All rights reserved.
oehlemar 0:7ee4c6416e08 5 */
oehlemar 0:7ee4c6416e08 6
oehlemar 0:7ee4c6416e08 7 #ifndef CONTROLLER_H_
oehlemar 0:7ee4c6416e08 8 #define CONTROLLER_H_
oehlemar 0:7ee4c6416e08 9
oehlemar 0:7ee4c6416e08 10 #include <cstdlib>
oehlemar 0:7ee4c6416e08 11 #include <mbed.h>
oehlemar 0:7ee4c6416e08 12 #include "EncoderCounter.h"
oehlemar 0:7ee4c6416e08 13 #include "LowpassFilter.h"
oehlemar 0:7ee4c6416e08 14
oehlemar 0:7ee4c6416e08 15 /**
oehlemar 0:7ee4c6416e08 16 * This class implements a controller that regulates the
oehlemar 0:7ee4c6416e08 17 * speed of the two motors of the ROME2 mobile robot.
oehlemar 0:7ee4c6416e08 18 */
oehlemar 0:7ee4c6416e08 19 class Controller {
oehlemar 0:7ee4c6416e08 20
oehlemar 0:7ee4c6416e08 21 public:
oehlemar 0:7ee4c6416e08 22
oehlemar 0:7ee4c6416e08 23 Controller(PwmOut& pwmLeft, PwmOut& pwmRight, EncoderCounter& counterLeft, EncoderCounter& counterRight);
oehlemar 0:7ee4c6416e08 24 virtual ~Controller();
oehlemar 0:7ee4c6416e08 25 void setDesiredSpeedLeft(float desiredSpeedLeft);
oehlemar 0:7ee4c6416e08 26 void setDesiredSpeedRight(float desiredSpeedRight);
oehlemar 0:7ee4c6416e08 27
oehlemar 0:7ee4c6416e08 28 private:
oehlemar 0:7ee4c6416e08 29
oehlemar 0:7ee4c6416e08 30 static const float PERIOD;
oehlemar 0:7ee4c6416e08 31 static const float COUNTS_PER_TURN;
oehlemar 0:7ee4c6416e08 32 static const float LOWPASS_FILTER_FREQUENCY;
oehlemar 0:7ee4c6416e08 33 static const float KN;
oehlemar 0:7ee4c6416e08 34 static const float KP;
oehlemar 0:7ee4c6416e08 35 static const float MAX_VOLTAGE;
oehlemar 0:7ee4c6416e08 36 static const float MIN_DUTY_CYCLE;
oehlemar 0:7ee4c6416e08 37 static const float MAX_DUTY_CYCLE;
oehlemar 0:7ee4c6416e08 38
oehlemar 0:7ee4c6416e08 39 PwmOut& pwmLeft;
oehlemar 0:7ee4c6416e08 40 PwmOut& pwmRight;
oehlemar 0:7ee4c6416e08 41 EncoderCounter& counterLeft;
oehlemar 0:7ee4c6416e08 42 EncoderCounter& counterRight;
oehlemar 0:7ee4c6416e08 43 short previousValueCounterLeft;
oehlemar 0:7ee4c6416e08 44 short previousValueCounterRight;
oehlemar 0:7ee4c6416e08 45 LowpassFilter speedLeftFilter;
oehlemar 0:7ee4c6416e08 46 LowpassFilter speedRightFilter;
oehlemar 0:7ee4c6416e08 47 float desiredSpeedLeft;
oehlemar 0:7ee4c6416e08 48 float desiredSpeedRight;
oehlemar 0:7ee4c6416e08 49 float actualSpeedLeft;
oehlemar 0:7ee4c6416e08 50 float actualSpeedRight;
oehlemar 0:7ee4c6416e08 51 Ticker ticker;
oehlemar 0:7ee4c6416e08 52
oehlemar 0:7ee4c6416e08 53 void run();
oehlemar 0:7ee4c6416e08 54 };
oehlemar 0:7ee4c6416e08 55
oehlemar 0:7ee4c6416e08 56 #endif /* CONTROLLER_H_ */
oehlemar 0:7ee4c6416e08 57