Erste version der Software für der Prototyp

Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
3:27100cbaaa6e
commentar

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:380207fcb5c1 1 /*
borlanic 0:380207fcb5c1 2 * Controller.cpp
borlanic 0:380207fcb5c1 3 * Copyright (c) 2018, ZHAW
borlanic 0:380207fcb5c1 4 * All rights reserved.
borlanic 0:380207fcb5c1 5 *
borlanic 0:380207fcb5c1 6 * Created on: 27.03.2018
borlanic 0:380207fcb5c1 7 * Author: BaBoRo Development Team
borlanic 0:380207fcb5c1 8 */
borlanic 0:380207fcb5c1 9
borlanic 0:380207fcb5c1 10 #ifndef CONTROLLER_H_
borlanic 0:380207fcb5c1 11 #define CONTROLLER_H_
borlanic 0:380207fcb5c1 12
borlanic 0:380207fcb5c1 13 #include <stdint.h>
borlanic 0:380207fcb5c1 14 #include "mbed.h"
borlanic 0:380207fcb5c1 15 #include "EncoderCounter.h"
borlanic 0:380207fcb5c1 16 #include "IMU.h"
borlanic 0:380207fcb5c1 17 #include "LowpassFilter.h"
borlanic 0:380207fcb5c1 18
borlanic 0:380207fcb5c1 19 /**
borlanic 3:27100cbaaa6e 20 * controller class
borlanic 0:380207fcb5c1 21 */
borlanic 0:380207fcb5c1 22 class Controller {
borlanic 0:380207fcb5c1 23
borlanic 0:380207fcb5c1 24 public:
borlanic 0:380207fcb5c1 25
borlanic 0:380207fcb5c1 26 //static const float TRANSLATIONAL_PROFILE_VELOCITY;
borlanic 0:380207fcb5c1 27 //static const float ROTATIONAL_PROFILE_VELOCITY;
borlanic 0:380207fcb5c1 28 static const float ALPHA;
borlanic 0:380207fcb5c1 29 static const float RB;
borlanic 0:380207fcb5c1 30 static const float RW;
borlanic 0:380207fcb5c1 31 static const float PI;
borlanic 0:380207fcb5c1 32 static const float SQRT_3;
borlanic 0:380207fcb5c1 33 static const float LOWPASS_FILTER_FREQUENCY;
borlanic 0:380207fcb5c1 34 static const float COUNTS_PER_TURN;
borlanic 3:27100cbaaa6e 35 static const float KI;
borlanic 3:27100cbaaa6e 36 static const float MIN_DUTY_CYCLE;
borlanic 3:27100cbaaa6e 37 static const float MAX_DUTY_CYCLE;
borlanic 0:380207fcb5c1 38
borlanic 0:380207fcb5c1 39 Controller(PwmOut& pwm0, PwmOut& pwm1, PwmOut& pwm2, EncoderCounter& counter1, EncoderCounter& counter2, EncoderCounter& counter3, IMU& imu);
borlanic 0:380207fcb5c1 40 virtual ~Controller();
borlanic 0:380207fcb5c1 41 void setGammaX(float gammaX);
borlanic 0:380207fcb5c1 42 void setGammaY(float gammaY);
borlanic 0:380207fcb5c1 43 void setGammaZ(float gammaZ);
borlanic 0:380207fcb5c1 44 void setPhiX(float phiX);
borlanic 0:380207fcb5c1 45 void setPhiY(float phiY);
borlanic 0:380207fcb5c1 46 void setX(float x);
borlanic 0:380207fcb5c1 47 void setY(float y);
borlanic 0:380207fcb5c1 48
borlanic 0:380207fcb5c1 49 float getPhiX();
borlanic 0:380207fcb5c1 50 float getPhiY();
borlanic 0:380207fcb5c1 51 float getX();
borlanic 0:380207fcb5c1 52 float getY();
borlanic 0:380207fcb5c1 53
borlanic 0:380207fcb5c1 54
borlanic 0:380207fcb5c1 55 private:
borlanic 0:380207fcb5c1 56
borlanic 0:380207fcb5c1 57 static const uint32_t STACK_SIZE = 4096; // stack size of thread, given in [bytes]
borlanic 0:380207fcb5c1 58 static const float PERIOD; // the period of the timer interrupt, given in [s]
borlanic 0:380207fcb5c1 59
borlanic 0:380207fcb5c1 60 PwmOut& pwm0;
borlanic 0:380207fcb5c1 61 PwmOut& pwm1;
borlanic 0:380207fcb5c1 62 PwmOut& pwm2;
borlanic 0:380207fcb5c1 63
borlanic 0:380207fcb5c1 64 EncoderCounter& counter1;
borlanic 0:380207fcb5c1 65 EncoderCounter& counter2;
borlanic 0:380207fcb5c1 66 EncoderCounter& counter3;
borlanic 0:380207fcb5c1 67
borlanic 0:380207fcb5c1 68 float gammaX;
borlanic 0:380207fcb5c1 69 float gammaY;
borlanic 0:380207fcb5c1 70 float gammaZ;
borlanic 0:380207fcb5c1 71 float phiX;
borlanic 0:380207fcb5c1 72 float phiY;
borlanic 0:380207fcb5c1 73 float x;
borlanic 0:380207fcb5c1 74 float y;
borlanic 0:380207fcb5c1 75
borlanic 0:380207fcb5c1 76 float d_gammaX;
borlanic 0:380207fcb5c1 77 float d_gammaY;
borlanic 0:380207fcb5c1 78 float d_gammaZ;
borlanic 0:380207fcb5c1 79 float d_phiX;
borlanic 0:380207fcb5c1 80 float d_phiY;
borlanic 0:380207fcb5c1 81
borlanic 0:380207fcb5c1 82 LowpassFilter speedFilter1;
borlanic 0:380207fcb5c1 83 LowpassFilter speedFilter2;
borlanic 0:380207fcb5c1 84 LowpassFilter speedFilter3;
borlanic 0:380207fcb5c1 85
borlanic 0:380207fcb5c1 86 float previousValueCounter1;
borlanic 0:380207fcb5c1 87 float previousValueCounter2;
borlanic 0:380207fcb5c1 88 float previousValueCounter3;
borlanic 0:380207fcb5c1 89 float actualSpeed1;
borlanic 0:380207fcb5c1 90 float actualSpeed2;
borlanic 0:380207fcb5c1 91 float actualSpeed3;
borlanic 0:380207fcb5c1 92
borlanic 0:380207fcb5c1 93 IMU& imu;
borlanic 0:380207fcb5c1 94 //Signal signal;
borlanic 0:380207fcb5c1 95 Thread thread;
borlanic 0:380207fcb5c1 96 //Ticker ticker;
borlanic 0:380207fcb5c1 97
borlanic 0:380207fcb5c1 98 //void sendSignal();
borlanic 0:380207fcb5c1 99 void run();
borlanic 0:380207fcb5c1 100 };
borlanic 0:380207fcb5c1 101
borlanic 0:380207fcb5c1 102 #endif /* CONTROLLER_H_ */