TeamSurface / Mbed 2 deprecated ROME_P3

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) 2018, 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 the coordinate transformation, speed control and
00018  * the position estimation of a mobile robot with differential drive.
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        setX(float x);
00031         float       getX();
00032         void        setY(float y);
00033         float       getY();
00034         void        setAlpha(float alpha);
00035         float       getAlpha();
00036         
00037     private:
00038         
00039         static const float  PERIOD;
00040         static const float  PI;
00041         static const float  WHEEL_DISTANCE;
00042         static const float  WHEEL_RADIUS;
00043         static const float  COUNTS_PER_TURN;
00044         static const float  LOWPASS_FILTER_FREQUENCY;
00045         static const float  KN;
00046         static const float  KP;
00047         static const float  MAX_VOLTAGE;
00048         static const float  MIN_DUTY_CYCLE;
00049         static const float  MAX_DUTY_CYCLE;
00050         
00051         PwmOut&             pwmLeft;
00052         PwmOut&             pwmRight;
00053         EncoderCounter&     counterLeft;
00054         EncoderCounter&     counterRight;
00055         Motion              translationalMotion;
00056         Motion              rotationalMotion;
00057         float               translationalVelocity;
00058         float               rotationalVelocity;
00059         float               actualTranslationalVelocity;
00060         float               actualRotationalVelocity;
00061         short               previousValueCounterLeft;
00062         short               previousValueCounterRight;
00063         LowpassFilter       speedLeftFilter;
00064         LowpassFilter       speedRightFilter;
00065         float               desiredSpeedLeft;
00066         float               desiredSpeedRight;
00067         float               actualSpeedLeft;
00068         float               actualSpeedRight;
00069         float               x;
00070         float               y;
00071         float               alpha;
00072         Ticker              ticker;
00073         
00074         void                run();
00075 };
00076 
00077 #endif /* CONTROLLER_H_ */
00078 
00079