P2 halbfertig

Fork of Library by St Knz

Committer:
kueenste
Date:
Fri Mar 09 15:29:36 2018 +0000
Revision:
0:bb408887ab78
P2_unfertig;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kueenste 0:bb408887ab78 1 /*
kueenste 0:bb408887ab78 2 * Controller.h
kueenste 0:bb408887ab78 3 * Copyright (c) 2018, ZHAW
kueenste 0:bb408887ab78 4 * All rights reserved.
kueenste 0:bb408887ab78 5 */
kueenste 0:bb408887ab78 6
kueenste 0:bb408887ab78 7 #ifndef CONTROLLER_H_
kueenste 0:bb408887ab78 8 #define CONTROLLER_H_
kueenste 0:bb408887ab78 9
kueenste 0:bb408887ab78 10 #include <cstdlib>
kueenste 0:bb408887ab78 11 #include <mbed.h>
kueenste 0:bb408887ab78 12 #include "EncoderCounter.h"
kueenste 0:bb408887ab78 13 #include "Motion.h"
kueenste 0:bb408887ab78 14 #include "LowpassFilter.h"
kueenste 0:bb408887ab78 15
kueenste 0:bb408887ab78 16 /**
kueenste 0:bb408887ab78 17 * This class implements the coordinate transformation, speed control and
kueenste 0:bb408887ab78 18 * the position estimation of a mobile robot with differential drive.
kueenste 0:bb408887ab78 19 */
kueenste 0:bb408887ab78 20 class Controller {
kueenste 0:bb408887ab78 21
kueenste 0:bb408887ab78 22 public:
kueenste 0:bb408887ab78 23
kueenste 0:bb408887ab78 24 Controller(PwmOut& pwmLeft, PwmOut& pwmRight, EncoderCounter& counterLeft, EncoderCounter& counterRight);
kueenste 0:bb408887ab78 25 virtual ~Controller();
kueenste 0:bb408887ab78 26 void setTranslationalVelocity(float velocity);
kueenste 0:bb408887ab78 27 void setRotationalVelocity(float velocity);
kueenste 0:bb408887ab78 28 float getActualTranslationalVelocity();
kueenste 0:bb408887ab78 29 float getActualRotationalVelocity();
kueenste 0:bb408887ab78 30
kueenste 0:bb408887ab78 31 private:
kueenste 0:bb408887ab78 32
kueenste 0:bb408887ab78 33 static const float PERIOD;
kueenste 0:bb408887ab78 34 static const float COUNTS_PER_TURN;
kueenste 0:bb408887ab78 35 static const float LOWPASS_FILTER_FREQUENCY;
kueenste 0:bb408887ab78 36 static const float KN;
kueenste 0:bb408887ab78 37 static const float KP;
kueenste 0:bb408887ab78 38 static const float MAX_VOLTAGE;
kueenste 0:bb408887ab78 39 static const float MIN_DUTY_CYCLE;
kueenste 0:bb408887ab78 40 static const float MAX_DUTY_CYCLE;
kueenste 0:bb408887ab78 41
kueenste 0:bb408887ab78 42 static const float R;
kueenste 0:bb408887ab78 43 static const float r;
kueenste 0:bb408887ab78 44
kueenste 0:bb408887ab78 45 PwmOut& pwmLeft;
kueenste 0:bb408887ab78 46 PwmOut& pwmRight;
kueenste 0:bb408887ab78 47 EncoderCounter& counterLeft;
kueenste 0:bb408887ab78 48 EncoderCounter& counterRight;
kueenste 0:bb408887ab78 49 Motion translationalMotion;
kueenste 0:bb408887ab78 50 Motion rotationalMotion;
kueenste 0:bb408887ab78 51 float translationalVelocity;
kueenste 0:bb408887ab78 52 float rotationalVelocity;
kueenste 0:bb408887ab78 53 float actualTranslationalVelocity;
kueenste 0:bb408887ab78 54 float actualRotationalVelocity;
kueenste 0:bb408887ab78 55 short previousValueCounterLeft;
kueenste 0:bb408887ab78 56 short previousValueCounterRight;
kueenste 0:bb408887ab78 57 LowpassFilter speedLeftFilter;
kueenste 0:bb408887ab78 58 LowpassFilter speedRightFilter;
kueenste 0:bb408887ab78 59 float desiredSpeedLeft;
kueenste 0:bb408887ab78 60 float desiredSpeedRight;
kueenste 0:bb408887ab78 61 float actualSpeedLeft;
kueenste 0:bb408887ab78 62 float actualSpeedRight;
kueenste 0:bb408887ab78 63 Ticker ticker;
kueenste 0:bb408887ab78 64
kueenste 0:bb408887ab78 65
kueenste 0:bb408887ab78 66 void run();
kueenste 0:bb408887ab78 67 };
kueenste 0:bb408887ab78 68
kueenste 0:bb408887ab78 69 #endif /* CONTROLLER_H_ */
kueenste 0:bb408887ab78 70