BA / Mbed OS BaBoRo1
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 
00019 /**
00020  * controller class
00021  */
00022 class Controller {
00023     
00024     public:
00025         
00026         //static const float      TRANSLATIONAL_PROFILE_VELOCITY;
00027         //static const float      ROTATIONAL_PROFILE_VELOCITY;
00028         static const float        ALPHA;
00029         static const float        RB;
00030         static const float        RW;
00031         static const float        PI;
00032         static const float        SQRT_3;
00033         static const float        LOWPASS_FILTER_FREQUENCY;
00034         static const float        COUNTS_PER_TURN;
00035         static const float        KI;
00036         static const float        MIN_DUTY_CYCLE;
00037         static const float        MAX_DUTY_CYCLE;
00038         
00039                     Controller(PwmOut& pwm0, PwmOut& pwm1, PwmOut& pwm2, EncoderCounter& counter1, EncoderCounter& counter2, EncoderCounter& counter3, IMU& imu);
00040         virtual     ~Controller();
00041         void        setGammaX(float gammaX);
00042         void        setGammaY(float gammaY);
00043         void        setGammaZ(float gammaZ);
00044         void        setPhiX(float phiX);
00045         void        setPhiY(float phiY);
00046         void        setX(float x);
00047         void        setY(float y);
00048         
00049         float       getPhiX();
00050         float       getPhiY();
00051         float       getX();
00052         float       getY();
00053 
00054         
00055     private:
00056         
00057         static const uint32_t   STACK_SIZE = 4096;  // stack size of thread, given in [bytes]
00058         static const float      PERIOD;             // the period of the timer interrupt, given in [s]
00059         
00060         PwmOut&             pwm0;
00061         PwmOut&             pwm1;
00062         PwmOut&             pwm2;
00063         
00064         EncoderCounter&     counter1;
00065         EncoderCounter&     counter2;
00066         EncoderCounter&     counter3;
00067         
00068         float               gammaX;
00069         float               gammaY;
00070         float               gammaZ;
00071         float               phiX;
00072         float               phiY;
00073         float               x;
00074         float               y;
00075         
00076         float               d_gammaX;
00077         float               d_gammaY;
00078         float               d_gammaZ;
00079         float               d_phiX;
00080         float               d_phiY;
00081         
00082         LowpassFilter       speedFilter1;
00083         LowpassFilter       speedFilter2;
00084         LowpassFilter       speedFilter3;
00085         
00086         float               previousValueCounter1;
00087         float               previousValueCounter2;
00088         float               previousValueCounter3;
00089         float               actualSpeed1;
00090         float               actualSpeed2;
00091         float               actualSpeed3;
00092         
00093         IMU&                imu;
00094         //Signal              signal;
00095         Thread              thread;
00096         //Ticker              ticker;
00097         
00098         //void        sendSignal();
00099         void        run();
00100 };
00101 
00102 #endif /* CONTROLLER_H_ */