Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:02dd72d1d465 1 /*
borlanic 0:02dd72d1d465 2 * Controller.cpp
borlanic 0:02dd72d1d465 3 * Copyright (c) 2018, ZHAW
borlanic 0:02dd72d1d465 4 * All rights reserved.
borlanic 0:02dd72d1d465 5 *
borlanic 0:02dd72d1d465 6 * Created on: 27.03.2018
borlanic 0:02dd72d1d465 7 * Author: BaBoRo Development Team
borlanic 0:02dd72d1d465 8 */
borlanic 0:02dd72d1d465 9
borlanic 0:02dd72d1d465 10 #ifndef CONTROLLER_H_
borlanic 0:02dd72d1d465 11 #define CONTROLLER_H_
borlanic 0:02dd72d1d465 12
borlanic 0:02dd72d1d465 13 #include <stdint.h>
borlanic 0:02dd72d1d465 14 #include "mbed.h"
borlanic 0:02dd72d1d465 15 #include "EncoderCounter.h"
borlanic 0:02dd72d1d465 16 #include "IMU.h"
borlanic 0:02dd72d1d465 17 #include "LowpassFilter.h"
borlanic 0:02dd72d1d465 18 #include "Motion.h"
borlanic 0:02dd72d1d465 19
borlanic 0:02dd72d1d465 20 /**
borlanic 0:02dd72d1d465 21 * controller class
borlanic 0:02dd72d1d465 22 */
borlanic 0:02dd72d1d465 23 class Controller {
borlanic 0:02dd72d1d465 24
borlanic 0:02dd72d1d465 25 public:
borlanic 0:02dd72d1d465 26
borlanic 0:02dd72d1d465 27 //static const float TRANSLATIONAL_PROFILE_VELOCITY;
borlanic 0:02dd72d1d465 28 //static const float ROTATIONAL_PROFILE_VELOCITY;
borlanic 0:02dd72d1d465 29 static const float ALPHA;
borlanic 0:02dd72d1d465 30 static const float RB;
borlanic 0:02dd72d1d465 31 static const float RW;
borlanic 0:02dd72d1d465 32 static const float PI;
borlanic 0:02dd72d1d465 33 static const float SQRT_3;
borlanic 0:02dd72d1d465 34 static const float LOWPASS_FILTER_FREQUENCY;
borlanic 0:02dd72d1d465 35 static const float COUNTS_PER_TURN;
borlanic 0:02dd72d1d465 36 static const float KI;
borlanic 0:02dd72d1d465 37 static const float MIN_DUTY_CYCLE;
borlanic 0:02dd72d1d465 38 static const float MAX_DUTY_CYCLE;
borlanic 0:02dd72d1d465 39 static const float MAX_ACC_M;
borlanic 0:02dd72d1d465 40
borlanic 0:02dd72d1d465 41 Controller(PwmOut& pwm0, PwmOut& pwm1, PwmOut& pwm2, EncoderCounter& counter1, EncoderCounter& counter2, EncoderCounter& counter3, IMU& imu);
borlanic 0:02dd72d1d465 42 virtual ~Controller();
borlanic 0:02dd72d1d465 43 void setGammaX(float gammaX);
borlanic 0:02dd72d1d465 44 void setGammaY(float gammaY);
borlanic 0:02dd72d1d465 45 void setGammaZ(float gammaZ);
borlanic 0:02dd72d1d465 46 void setPhiX(float phiX);
borlanic 0:02dd72d1d465 47 void setPhiY(float phiY);
borlanic 0:02dd72d1d465 48 void setX(float x);
borlanic 0:02dd72d1d465 49 void setY(float y);
borlanic 0:02dd72d1d465 50
borlanic 0:02dd72d1d465 51 float getPhiX();
borlanic 0:02dd72d1d465 52 float getPhiY();
borlanic 0:02dd72d1d465 53 float getX();
borlanic 0:02dd72d1d465 54 float getY();
borlanic 0:02dd72d1d465 55
borlanic 0:02dd72d1d465 56
borlanic 0:02dd72d1d465 57 private:
borlanic 0:02dd72d1d465 58
borlanic 0:02dd72d1d465 59 static const uint32_t STACK_SIZE = 4096; // stack size of thread, given in [bytes]
borlanic 0:02dd72d1d465 60 static const float PERIOD; // the period of the timer interrupt, given in [s]
borlanic 0:02dd72d1d465 61
borlanic 0:02dd72d1d465 62 PwmOut& pwm0;
borlanic 0:02dd72d1d465 63 PwmOut& pwm1;
borlanic 0:02dd72d1d465 64 PwmOut& pwm2;
borlanic 0:02dd72d1d465 65
borlanic 0:02dd72d1d465 66 EncoderCounter& counter1;
borlanic 0:02dd72d1d465 67 EncoderCounter& counter2;
borlanic 0:02dd72d1d465 68 EncoderCounter& counter3;
borlanic 0:02dd72d1d465 69
borlanic 0:02dd72d1d465 70 float gammaXref;
borlanic 0:02dd72d1d465 71 float gammaYref;
borlanic 0:02dd72d1d465 72 float gammaZref;
borlanic 0:02dd72d1d465 73 float phiXref;
borlanic 0:02dd72d1d465 74 float phiYref;
borlanic 0:02dd72d1d465 75
borlanic 0:02dd72d1d465 76 float gammaX;
borlanic 0:02dd72d1d465 77 float gammaY;
borlanic 0:02dd72d1d465 78 float gammaZ;
borlanic 0:02dd72d1d465 79 float phiX;
borlanic 0:02dd72d1d465 80 float phiY;
borlanic 0:02dd72d1d465 81 float x;
borlanic 0:02dd72d1d465 82 float y;
borlanic 0:02dd72d1d465 83
borlanic 0:02dd72d1d465 84 float d_gammaX;
borlanic 0:02dd72d1d465 85 float d_gammaY;
borlanic 0:02dd72d1d465 86 float d_gammaZ;
borlanic 0:02dd72d1d465 87 float d_phiX;
borlanic 0:02dd72d1d465 88 float d_phiY;
borlanic 0:02dd72d1d465 89
borlanic 0:02dd72d1d465 90 LowpassFilter speedFilter1;
borlanic 0:02dd72d1d465 91 LowpassFilter speedFilter2;
borlanic 0:02dd72d1d465 92 LowpassFilter speedFilter3;
borlanic 0:02dd72d1d465 93
borlanic 0:02dd72d1d465 94 LowpassFilter d_phiXFilter;
borlanic 0:02dd72d1d465 95 LowpassFilter d_phiYFilter;
borlanic 0:02dd72d1d465 96
borlanic 0:02dd72d1d465 97 LowpassFilter gammaXFilter;
borlanic 0:02dd72d1d465 98 LowpassFilter gammaYFilter;
borlanic 0:02dd72d1d465 99 LowpassFilter d_gammaXFilter;
borlanic 0:02dd72d1d465 100 LowpassFilter d_gammaYFilter;
borlanic 0:02dd72d1d465 101
borlanic 0:02dd72d1d465 102 LowpassFilter M1Filter;
borlanic 0:02dd72d1d465 103 LowpassFilter M2Filter;
borlanic 0:02dd72d1d465 104 LowpassFilter M3Filter;
borlanic 0:02dd72d1d465 105
borlanic 0:02dd72d1d465 106 float previousValueCounter1;
borlanic 0:02dd72d1d465 107 float previousValueCounter2;
borlanic 0:02dd72d1d465 108 float previousValueCounter3;
borlanic 0:02dd72d1d465 109 float actualSpeed1;
borlanic 0:02dd72d1d465 110 float actualSpeed2;
borlanic 0:02dd72d1d465 111 float actualSpeed3;
borlanic 0:02dd72d1d465 112
borlanic 0:02dd72d1d465 113 Motion M1motion;
borlanic 0:02dd72d1d465 114 Motion M2motion;
borlanic 0:02dd72d1d465 115 Motion M3motion;
borlanic 0:02dd72d1d465 116 Motion d_phiXMotion;
borlanic 0:02dd72d1d465 117 Motion d_phiYMotion;
borlanic 0:02dd72d1d465 118
borlanic 0:02dd72d1d465 119 IMU& imu;
borlanic 0:02dd72d1d465 120 //Signal signal;
borlanic 0:02dd72d1d465 121 Thread thread;
borlanic 0:02dd72d1d465 122 //Ticker ticker;
borlanic 0:02dd72d1d465 123 Mutex mutex; // mutex to lock critical sections
borlanic 0:02dd72d1d465 124
borlanic 0:02dd72d1d465 125 //void sendSignal();
borlanic 0:02dd72d1d465 126 void run();
borlanic 0:02dd72d1d465 127 };
borlanic 0:02dd72d1d465 128
borlanic 0:02dd72d1d465 129 #endif /* CONTROLLER_H_ */