Algorithmus

Dependencies:   mbed

Committer:
Helvis
Date:
Thu May 10 18:10:15 2018 +0000
Revision:
19:6cd6cc5c8b4c
Parent:
18:3309329d5f42
Child:
21:41997651337a
v.1.0 +printf auskommnetiert; -unerwartete Beschleunigung (tragetSpeed)

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 scanMove();
Helvis 1:2b5f79285a3e 23 void rotateL();
Helvis 1:2b5f79285a3e 24 void rotateR();
Helvis 2:f898adf2d817 25 void turnL();
Helvis 2:f898adf2d817 26 void turnR();
Helvis 1:2b5f79285a3e 27 void stop();
Helvis 1:2b5f79285a3e 28 void rotate180();
Helvis 1:2b5f79285a3e 29 void control();
Helvis 18:3309329d5f42 30 void runTask(int path[], int task, bool reverse, int junction);
Helvis 1:2b5f79285a3e 31 int finish();
Helvis 13:845e49f20426 32 void accel(float targetSpeed);
Helvis 1:2b5f79285a3e 33
Helvis 1:2b5f79285a3e 34 private:
Helvis 1:2b5f79285a3e 35
Helvis 12:75d0291a9785 36 static const float LEFT_MID_VAL;
Helvis 12:75d0291a9785 37 static const float RIGHT_MID_VAL;
Helvis 12:75d0291a9785 38 static const float KP;
Helvis 12:75d0291a9785 39 static const float KD;
Helvis 12:75d0291a9785 40 static const int MOVE_DIST;
Helvis 12:75d0291a9785 41 static const float MOVE_SPEED;
Helvis 13:845e49f20426 42 static const float SCAN_SPEED;
Helvis 12:75d0291a9785 43 static const float ROTATE_SPEED;
Helvis 13:845e49f20426 44 static const float ACCEL_CONST;
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 13:845e49f20426 54 Timer t;
Helvis 1:2b5f79285a3e 55
Helvis 12:75d0291a9785 56 float distanceL;
Helvis 12:75d0291a9785 57 float distanceC;
Helvis 12:75d0291a9785 58 float distanceR;
Helvis 12:75d0291a9785 59 int countsL;
Helvis 12:75d0291a9785 60 int countsR;
Helvis 12:75d0291a9785 61 int countsLOld;
Helvis 12:75d0291a9785 62 int countsROld;
Helvis 12:75d0291a9785 63 float speedLeft;
Helvis 12:75d0291a9785 64 float speedRight;
Helvis 12:75d0291a9785 65 float errorP;
Helvis 12:75d0291a9785 66 float errorD;
Helvis 12:75d0291a9785 67 float oldErrorP;
Helvis 12:75d0291a9785 68 float totalError;
Helvis 12:75d0291a9785 69 int waitStop;
Helvis 12:75d0291a9785 70 int path[];
Helvis 12:75d0291a9785 71 int task;
Helvis 12:75d0291a9785 72 bool reverse;
Helvis 18:3309329d5f42 73 int junction;
Helvis 12:75d0291a9785 74 bool acceleration;
Helvis 12:75d0291a9785 75 bool deceleration;
Helvis 12:75d0291a9785 76 int line;
Helvis 12:75d0291a9785 77 float countsOld;
Helvis 12:75d0291a9785 78 float avgSpeed;
Helvis 12:75d0291a9785 79 float actSpeed;
Helvis 13:845e49f20426 80 float targetSpeed;
Helvis 19:6cd6cc5c8b4c 81 bool lastMove;
Helvis 1:2b5f79285a3e 82 };
Helvis 1:2b5f79285a3e 83
Helvis 1:2b5f79285a3e 84 #endif /* MOTION_H_ */