rome2_p6 imported

Dependencies:   mbed

Committer:
Appalco
Date:
Fri May 18 13:54:25 2018 +0000
Revision:
5:957580f33e52
Parent:
0:351a2fb21235
fixed tolerance and wayponts

Who changed what in which revision?

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