Zürcher Eliteeinheit / Mbed 2 deprecated ROME2_P4

Dependencies:   ROME2_P2 mbed

Fork of ROME2_P3 by Zürcher Eliteeinheit

Committer:
Appalco
Date:
Fri Mar 16 14:40:52 2018 +0000
Revision:
1:31b1c5cefd64
Parent:
0:e360940c4b88
Child:
4:4428ede9beee
implemented Controller.cpp motion controll

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Appalco 0:e360940c4b88 1 /*
Appalco 0:e360940c4b88 2 * Controller.h
Appalco 0:e360940c4b88 3 * Copyright (c) 2018, ZHAW
Appalco 0:e360940c4b88 4 * All rights reserved.
Appalco 0:e360940c4b88 5 */
Appalco 0:e360940c4b88 6
Appalco 0:e360940c4b88 7 #ifndef CONTROLLER_H_
Appalco 0:e360940c4b88 8 #define CONTROLLER_H_
Appalco 0:e360940c4b88 9
Appalco 0:e360940c4b88 10 #include <cstdlib>
Appalco 0:e360940c4b88 11 #include <mbed.h>
Appalco 0:e360940c4b88 12 #include "EncoderCounter.h"
Appalco 0:e360940c4b88 13 #include "Motion.h"
Appalco 0:e360940c4b88 14 #include "LowpassFilter.h"
Appalco 0:e360940c4b88 15
Appalco 0:e360940c4b88 16 /**
Appalco 0:e360940c4b88 17 * This class implements the coordinate transformation, speed control and
Appalco 0:e360940c4b88 18 * the position estimation of a mobile robot with differential drive.
Appalco 0:e360940c4b88 19 */
Appalco 0:e360940c4b88 20 class Controller {
Appalco 0:e360940c4b88 21
Appalco 0:e360940c4b88 22 public:
Appalco 0:e360940c4b88 23
Appalco 0:e360940c4b88 24 Controller(PwmOut& pwmLeft, PwmOut& pwmRight, EncoderCounter& counterLeft, EncoderCounter& counterRight);
Appalco 0:e360940c4b88 25 virtual ~Controller();
Appalco 0:e360940c4b88 26 void setTranslationalVelocity(float velocity);
Appalco 0:e360940c4b88 27 void setRotationalVelocity(float velocity);
Appalco 0:e360940c4b88 28 float getActualTranslationalVelocity();
Appalco 0:e360940c4b88 29 float getActualRotationalVelocity();
Appalco 0:e360940c4b88 30
Appalco 0:e360940c4b88 31 private:
Appalco 0:e360940c4b88 32
Appalco 0:e360940c4b88 33 static const float PERIOD;
Appalco 0:e360940c4b88 34 static const float COUNTS_PER_TURN;
Appalco 0:e360940c4b88 35 static const float LOWPASS_FILTER_FREQUENCY;
Appalco 0:e360940c4b88 36 static const float KN;
Appalco 0:e360940c4b88 37 static const float KP;
Appalco 0:e360940c4b88 38 static const float MAX_VOLTAGE;
Appalco 0:e360940c4b88 39 static const float MIN_DUTY_CYCLE;
Appalco 0:e360940c4b88 40 static const float MAX_DUTY_CYCLE;
Appalco 1:31b1c5cefd64 41 static const float PI; // the constant PI
Appalco 1:31b1c5cefd64 42 static const float WHEEL_DISTANCE; // distance between wheels, given in [m]
Appalco 1:31b1c5cefd64 43 static const float WHEEL_RADIUS; // radius of wheels, given in [m]
Appalco 0:e360940c4b88 44
Appalco 0:e360940c4b88 45 PwmOut& pwmLeft;
Appalco 0:e360940c4b88 46 PwmOut& pwmRight;
Appalco 0:e360940c4b88 47 EncoderCounter& counterLeft;
Appalco 0:e360940c4b88 48 EncoderCounter& counterRight;
Appalco 0:e360940c4b88 49 Motion translationalMotion;
Appalco 0:e360940c4b88 50 Motion rotationalMotion;
Appalco 0:e360940c4b88 51 float translationalVelocity;
Appalco 0:e360940c4b88 52 float rotationalVelocity;
Appalco 0:e360940c4b88 53 float actualTranslationalVelocity;
Appalco 0:e360940c4b88 54 float actualRotationalVelocity;
Appalco 0:e360940c4b88 55 short previousValueCounterLeft;
Appalco 0:e360940c4b88 56 short previousValueCounterRight;
Appalco 0:e360940c4b88 57 LowpassFilter speedLeftFilter;
Appalco 0:e360940c4b88 58 LowpassFilter speedRightFilter;
Appalco 0:e360940c4b88 59 float desiredSpeedLeft;
Appalco 0:e360940c4b88 60 float desiredSpeedRight;
Appalco 0:e360940c4b88 61 float actualSpeedLeft;
Appalco 0:e360940c4b88 62 float actualSpeedRight;
Appalco 0:e360940c4b88 63 Ticker ticker;
Appalco 0:e360940c4b88 64
Appalco 0:e360940c4b88 65 void run();
Appalco 0:e360940c4b88 66 };
Appalco 0:e360940c4b88 67
Appalco 0:e360940c4b88 68 #endif /* CONTROLLER_H_ */
Appalco 0:e360940c4b88 69