Algorithmus

Dependencies:   mbed

Committer:
Helvis
Date:
Wed May 02 14:58:48 2018 +0000
Revision:
12:75d0291a9785
Parent:
7:22392ed60534
Child:
13:845e49f20426
v0.9.6b: funktioniert!

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 12:75d0291a9785 31 void runTask(int path[], int task, bool reverse);
Helvis 1:2b5f79285a3e 32 int finish();
Helvis 12:75d0291a9785 33 void accel();
Helvis 1:2b5f79285a3e 34
Helvis 1:2b5f79285a3e 35 private:
Helvis 1:2b5f79285a3e 36
Helvis 12:75d0291a9785 37 static const float LEFT_MID_VAL;
Helvis 12:75d0291a9785 38 static const float RIGHT_MID_VAL;
Helvis 12:75d0291a9785 39 static const float KP;
Helvis 12:75d0291a9785 40 static const float KD;
Helvis 12:75d0291a9785 41 static const int MOVE_DIST;
Helvis 12:75d0291a9785 42 static const float MOVE_SPEED;
Helvis 12:75d0291a9785 43 static const float ROTATE_SPEED;
Helvis 12:75d0291a9785 44 static const float ACCEL_SCALE;
Helvis 1:2b5f79285a3e 45
Helvis 12:75d0291a9785 46 Controller& controller;
Helvis 12:75d0291a9785 47 EncoderCounter& counterLeft;
Helvis 12:75d0291a9785 48 EncoderCounter& counterRight;
Helvis 12:75d0291a9785 49 IRSensor& irSensorL;
Helvis 12:75d0291a9785 50 IRSensor& irSensorC;
Helvis 12:75d0291a9785 51 IRSensor& irSensorR;
Helvis 12:75d0291a9785 52 AnalogIn& lineSensor;
Helvis 12:75d0291a9785 53 DigitalOut& enableMotorDriver;
Helvis 1:2b5f79285a3e 54
Helvis 12:75d0291a9785 55 float distanceL;
Helvis 12:75d0291a9785 56 float distanceC;
Helvis 12:75d0291a9785 57 float distanceR;
Helvis 12:75d0291a9785 58 int countsL;
Helvis 12:75d0291a9785 59 int countsR;
Helvis 12:75d0291a9785 60 int countsLOld;
Helvis 12:75d0291a9785 61 int countsROld;
Helvis 12:75d0291a9785 62 float speedLeft;
Helvis 12:75d0291a9785 63 float speedRight;
Helvis 12:75d0291a9785 64 float errorP;
Helvis 12:75d0291a9785 65 float errorD;
Helvis 12:75d0291a9785 66 float oldErrorP;
Helvis 12:75d0291a9785 67 float totalError;
Helvis 12:75d0291a9785 68 int waitStop;
Helvis 12:75d0291a9785 69 int path[];
Helvis 12:75d0291a9785 70 int task;
Helvis 12:75d0291a9785 71 bool reverse;
Helvis 12:75d0291a9785 72 bool acceleration;
Helvis 12:75d0291a9785 73 bool deceleration;
Helvis 12:75d0291a9785 74 int line;
Helvis 12:75d0291a9785 75 float countsOld;
Helvis 12:75d0291a9785 76 float avgSpeed;
Helvis 12:75d0291a9785 77 float avgCounts;
Helvis 12:75d0291a9785 78 float actSpeed;
Helvis 1:2b5f79285a3e 79 };
Helvis 1:2b5f79285a3e 80
Helvis 1:2b5f79285a3e 81 #endif /* MOTION_H_ */