ROME_P5

Dependencies:   mbed

Committer:
Inaueadr
Date:
Fri Apr 27 08:47:34 2018 +0000
Revision:
0:29be10cb0afc
Hallo

Who changed what in which revision?

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