gugus

Dependencies:   mbed

Committer:
Brignall
Date:
Fri May 18 12:18:21 2018 +0000
Revision:
0:1a0321f1ffbc
lala;

Who changed what in which revision?

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