Marco Oehler / Mbed 2 deprecated Lab2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Controller.h Source File

Controller.h

00001 /*
00002  * Controller.h
00003  * Copyright (c) 2020, ZHAW
00004  * All rights reserved.
00005  */
00006 
00007 #ifndef CONTROLLER_H_
00008 #define CONTROLLER_H_
00009 
00010 #include <cstdlib>
00011 #include <mbed.h>
00012 #include "EncoderCounter.h"
00013 #include "Motion.h"
00014 #include "LowpassFilter.h"
00015 
00016 /**
00017  * This class implements a controller that regulates the
00018  * speed of the two motors of the ROME2 mobile robot.
00019  */
00020 class Controller {
00021     
00022     public:
00023         
00024                 Controller(PwmOut& pwmLeft, PwmOut& pwmRight, EncoderCounter& counterLeft, EncoderCounter& counterRight);
00025         virtual ~Controller();
00026         void    setTranslationalVelocity(float velocity);
00027         void    setRotationalVelocity(float velocity);
00028         float   getActualTranslationalVelocity();
00029         float   getActualRotationalVelocity();
00030         void    setDesiredSpeedLeft(float desiredSpeedLeft);
00031         void    setDesiredSpeedRight(float desiredSpeedRight);
00032         float   getActualSpeedLeft();
00033         float   getActualSpeedRight();
00034         
00035   private:
00036         
00037         static const float  PERIOD;
00038         static const float  PI;
00039         static const float  WHEEL_DISTANCE;
00040         static const float  WHEEL_RADIUS;
00041         static const float  COUNTS_PER_TURN;
00042         static const float  LOWPASS_FILTER_FREQUENCY;
00043         static const float  KN;
00044         static const float  KP;
00045         static const float  MAX_VOLTAGE;
00046         static const float  MIN_DUTY_CYCLE;
00047         static const float  MAX_DUTY_CYCLE;
00048 
00049         PwmOut&             pwmLeft;
00050         PwmOut&             pwmRight;
00051         EncoderCounter&     counterLeft;
00052         EncoderCounter&     counterRight;
00053         Motion              translationalMotion;
00054         Motion              rotationalMotion;
00055         float               translationalVelocity;
00056         float               rotationalVelocity;
00057         float               actualTranslationalVelocity;
00058         float               actualRotationalVelocity;
00059         short               previousValueCounterLeft;
00060         short               previousValueCounterRight;
00061         LowpassFilter       speedLeftFilter;
00062         LowpassFilter       speedRightFilter;
00063         float               desiredSpeedLeft;
00064         float               desiredSpeedRight;
00065         float               actualSpeedLeft;
00066         float               actualSpeedRight;
00067         Ticker              ticker;
00068         
00069         void    run();
00070 };
00071 
00072 #endif /* CONTROLLER_H_ */
00073