Zürcher Eliteeinheit / Mbed 2 deprecated ROME2_P4

Dependencies:   ROME2_P2 mbed

Fork of ROME2_P3 by Zürcher Eliteeinheit

Controller.h

Committer:
Appalco
Date:
2018-03-16
Revision:
1:31b1c5cefd64
Parent:
0:e360940c4b88
Child:
4:4428ede9beee

File content as of revision 1:31b1c5cefd64:

/*
 * Controller.h
 * Copyright (c) 2018, ZHAW
 * All rights reserved.
 */

#ifndef CONTROLLER_H_
#define CONTROLLER_H_

#include <cstdlib>
#include <mbed.h>
#include "EncoderCounter.h"
#include "Motion.h"
#include "LowpassFilter.h"

/**
 * This class implements the coordinate transformation, speed control and
 * the position estimation of a mobile robot with differential drive.
 */
class Controller {

    public:
    
                    Controller(PwmOut& pwmLeft, PwmOut& pwmRight, EncoderCounter& counterLeft, EncoderCounter& counterRight);
        virtual     ~Controller();
        void        setTranslationalVelocity(float velocity);
        void        setRotationalVelocity(float velocity);
        float       getActualTranslationalVelocity();
        float       getActualRotationalVelocity();
        
    private:
        
        static const float  PERIOD;
        static const float  COUNTS_PER_TURN;
        static const float  LOWPASS_FILTER_FREQUENCY;
        static const float  KN;
        static const float  KP;
        static const float  MAX_VOLTAGE;
        static const float  MIN_DUTY_CYCLE;
        static const float  MAX_DUTY_CYCLE;
        static const float  PI;                   // the constant PI
        static const float  WHEEL_DISTANCE;            // distance between wheels, given in [m]
        static const float  WHEEL_RADIUS;             // radius of wheels, given in [m]
        
        PwmOut&             pwmLeft;
        PwmOut&             pwmRight;
        EncoderCounter&     counterLeft;
        EncoderCounter&     counterRight;
        Motion              translationalMotion;
        Motion              rotationalMotion;
        float               translationalVelocity;
        float               rotationalVelocity;
        float               actualTranslationalVelocity;
        float               actualRotationalVelocity;
        short               previousValueCounterLeft;
        short               previousValueCounterRight;
        LowpassFilter       speedLeftFilter;
        LowpassFilter       speedRightFilter;
        float               desiredSpeedLeft;
        float               desiredSpeedRight;
        float               actualSpeedLeft;
        float               actualSpeedRight;
        Ticker              ticker;
        
        void                run();
};

#endif /* CONTROLLER_H_ */