BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

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