BA / Mbed OS BaBoRo_test2
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Controller.h Source File

Controller.h

00001 /*
00002  * Controller.cpp
00003  * Copyright (c) 2018, ZHAW
00004  * All rights reserved.
00005  *
00006  *  Created on: 27.03.2018
00007  *      Author: BaBoRo Development Team
00008  */
00009 
00010 #ifndef CONTROLLER_H_
00011 #define CONTROLLER_H_
00012 
00013 #include <stdint.h>
00014 #include "mbed.h"
00015 #include "EncoderCounter.h"
00016 #include "IMU.h"
00017 #include "LowpassFilter.h"
00018 #include "Motion.h"
00019 
00020 /**
00021  * controller class
00022  */
00023 class Controller {
00024     
00025     public:
00026         
00027         //static const float      TRANSLATIONAL_PROFILE_VELOCITY;
00028         //static const float      ROTATIONAL_PROFILE_VELOCITY;
00029         static const float        ALPHA;
00030         static const float        RB;
00031         static const float        RW;
00032         static const float        PI;
00033         static const float        SQRT_3;
00034         static const float        LOWPASS_FILTER_FREQUENCY;
00035         static const float        COUNTS_PER_TURN;
00036         static const float        KI;
00037         static const float        MIN_DUTY_CYCLE;
00038         static const float        MAX_DUTY_CYCLE;
00039         static const float        MAX_ACC_M;
00040         
00041                     Controller(PwmOut& pwm0, PwmOut& pwm1, PwmOut& pwm2, EncoderCounter& counter1, EncoderCounter& counter2, EncoderCounter& counter3, IMU& imu);
00042         virtual     ~Controller();
00043         void        setGammaX(float gammaX);
00044         void        setGammaY(float gammaY);
00045         void        setGammaZ(float gammaZ);
00046         void        setPhiX(float phiX);
00047         void        setPhiY(float phiY);
00048         void        setX(float x);
00049         void        setY(float y);
00050         
00051         float       getPhiX();
00052         float       getPhiY();
00053         float       getX();
00054         float       getY();
00055 
00056         
00057     private:
00058         
00059         static const uint32_t   STACK_SIZE = 4096;  // stack size of thread, given in [bytes]
00060         static const float      PERIOD;             // the period of the timer interrupt, given in [s]
00061         
00062         PwmOut&             pwm0;
00063         PwmOut&             pwm1;
00064         PwmOut&             pwm2;
00065         
00066         EncoderCounter&     counter1;
00067         EncoderCounter&     counter2;
00068         EncoderCounter&     counter3;
00069         
00070         float               gammaXref;
00071         float               gammaYref;
00072         float               gammaZref;
00073         float               phiXref;
00074         float               phiYref;
00075         
00076         float               gammaX;
00077         float               gammaY;
00078         float               gammaZ;
00079         float               phiX;
00080         float               phiY;
00081         float               x;
00082         float               y;
00083         
00084         float               d_gammaX;
00085         float               d_gammaY;
00086         float               d_gammaZ;
00087         float               d_phiX;
00088         float               d_phiY;
00089         
00090         LowpassFilter       speedFilter1;
00091         LowpassFilter       speedFilter2;
00092         LowpassFilter       speedFilter3;
00093         
00094         LowpassFilter       d_phiXFilter;
00095         LowpassFilter       d_phiYFilter;
00096         
00097         LowpassFilter       gammaXFilter;
00098         LowpassFilter       gammaYFilter;
00099         LowpassFilter       d_gammaXFilter;
00100         LowpassFilter       d_gammaYFilter;
00101         
00102         LowpassFilter       M1Filter;
00103         LowpassFilter       M2Filter;
00104         LowpassFilter       M3Filter;
00105         
00106         float               previousValueCounter1;
00107         float               previousValueCounter2;
00108         float               previousValueCounter3;
00109         float               actualSpeed1;
00110         float               actualSpeed2;
00111         float               actualSpeed3;
00112         
00113         Motion              M1motion;
00114         Motion              M2motion;
00115         Motion              M3motion;
00116         Motion              d_phiXMotion;
00117         Motion              d_phiYMotion;
00118         
00119         IMU&                imu;
00120         //Signal              signal;
00121         Thread              thread;
00122         //Ticker              ticker;
00123         Mutex               mutex;      // mutex to lock critical sections
00124         
00125         //void        sendSignal();
00126         void        run();
00127 };
00128 
00129 #endif /* CONTROLLER_H_ */