Algorithmus

Dependencies:   mbed

Committer:
Helvis
Date:
Fri Apr 27 13:07:13 2018 +0000
Revision:
7:22392ed60534
Parent:
6:4868f789c223
Child:
12:75d0291a9785
v0.9.5b

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Helvis 1:2b5f79285a3e 1 #ifndef MOTION_H_
Helvis 1:2b5f79285a3e 2 #define MOTION_H_
Helvis 1:2b5f79285a3e 3
Helvis 1:2b5f79285a3e 4 #include <cstdlib>
Helvis 1:2b5f79285a3e 5 #include <mbed.h>
Helvis 1:2b5f79285a3e 6 #include "EncoderCounter.h"
Helvis 1:2b5f79285a3e 7 #include "Controller.h"
Helvis 1:2b5f79285a3e 8 #include "IRSensor.h"
Helvis 1:2b5f79285a3e 9
Helvis 1:2b5f79285a3e 10
Helvis 1:2b5f79285a3e 11 class Motion {
Helvis 1:2b5f79285a3e 12
Helvis 1:2b5f79285a3e 13 public:
Helvis 1:2b5f79285a3e 14
Helvis 1:2b5f79285a3e 15 Motion(Controller& controller, EncoderCounter& counterLeft,
Helvis 1:2b5f79285a3e 16 EncoderCounter& counterRight, IRSensor& irSensorL,
Helvis 1:2b5f79285a3e 17 IRSensor& irSensorC, IRSensor& irSensorR, AnalogIn& lineSensor,
Helvis 1:2b5f79285a3e 18 DigitalOut& enableMotorDriver);
Helvis 1:2b5f79285a3e 19
Helvis 1:2b5f79285a3e 20 virtual ~Motion();
Helvis 1:2b5f79285a3e 21 void move();
Helvis 1:2b5f79285a3e 22 void moveFast();
Helvis 1:2b5f79285a3e 23 void scanMove();
Helvis 1:2b5f79285a3e 24 void rotateL();
Helvis 1:2b5f79285a3e 25 void rotateR();
Helvis 2:f898adf2d817 26 void turnL();
Helvis 2:f898adf2d817 27 void turnR();
Helvis 1:2b5f79285a3e 28 void stop();
Helvis 1:2b5f79285a3e 29 void rotate180();
Helvis 1:2b5f79285a3e 30 void control();
Helvis 1:2b5f79285a3e 31 void runTask(int task);
Helvis 1:2b5f79285a3e 32 int finish();
Helvis 1:2b5f79285a3e 33
Helvis 1:2b5f79285a3e 34 private:
Helvis 1:2b5f79285a3e 35
Helvis 1:2b5f79285a3e 36 static const float LEFT_MID_VAL;
Helvis 1:2b5f79285a3e 37 static const float RIGHT_MID_VAL;
Helvis 1:2b5f79285a3e 38 static const float KP;
Helvis 1:2b5f79285a3e 39 static const float KD;
Helvis 6:4868f789c223 40 static const int MOVE_DIST;
Helvis 6:4868f789c223 41 static const float MOVE_SPEED;
Helvis 1:2b5f79285a3e 42
Helvis 1:2b5f79285a3e 43 Controller& controller;
Helvis 1:2b5f79285a3e 44 EncoderCounter& counterLeft;
Helvis 1:2b5f79285a3e 45 EncoderCounter& counterRight;
Helvis 1:2b5f79285a3e 46 IRSensor& irSensorL;
Helvis 1:2b5f79285a3e 47 IRSensor& irSensorC;
Helvis 1:2b5f79285a3e 48 IRSensor& irSensorR;
Helvis 1:2b5f79285a3e 49 AnalogIn& lineSensor;
Helvis 1:2b5f79285a3e 50 DigitalOut& enableMotorDriver;
Helvis 1:2b5f79285a3e 51
Helvis 1:2b5f79285a3e 52 float distanceL;
Helvis 1:2b5f79285a3e 53 float distanceC;
Helvis 1:2b5f79285a3e 54 float distanceR;
Helvis 7:22392ed60534 55 int countsL;
Helvis 7:22392ed60534 56 int countsR;
Helvis 7:22392ed60534 57 int countsLOld;
Helvis 7:22392ed60534 58 int countsROld;
Helvis 1:2b5f79285a3e 59 float speedLeft;
Helvis 1:2b5f79285a3e 60 float speedRight;
Helvis 1:2b5f79285a3e 61 float errorP;
Helvis 1:2b5f79285a3e 62 float errorD;
Helvis 1:2b5f79285a3e 63 float oldErrorP;
Helvis 1:2b5f79285a3e 64 float totalError;
Helvis 1:2b5f79285a3e 65 int waitStop;
Helvis 1:2b5f79285a3e 66 int task;
Helvis 1:2b5f79285a3e 67 int line;
Helvis 5:e2c0a4388d85 68 float countsOld;
Helvis 1:2b5f79285a3e 69 };
Helvis 1:2b5f79285a3e 70
Helvis 1:2b5f79285a3e 71 #endif /* MOTION_H_ */