Algorithmus

Dependencies:   mbed

Committer:
luethale
Date:
Sat Jun 30 14:13:27 2018 +0000
Revision:
36:99f60052c746
Parent:
27:f111ba194412
Nacht_der_Technik; Angepasste Werte:; Move & HalfeMove; Ev. Bechleunigung verbessern (aprupte Stops); Ev. Move & HalfeMove weiter anpassen

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 23:accd07ca2da7 22 void moveHalf();
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 18:3309329d5f42 31 void runTask(int path[], int task, bool reverse, int junction);
Helvis 1:2b5f79285a3e 32 int finish();
Helvis 13:845e49f20426 33 void accel(float targetSpeed);
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;
luethale 27:f111ba194412 43 static const float RUN_SPEED;
luethale 27:f111ba194412 44 static const float TURN_SPEED_LEFT;
Helvis 12:75d0291a9785 45 static const float ROTATE_SPEED;
Helvis 13:845e49f20426 46 static const float ACCEL_CONST;
Helvis 1:2b5f79285a3e 47
Helvis 12:75d0291a9785 48 Controller& controller;
Helvis 12:75d0291a9785 49 EncoderCounter& counterLeft;
Helvis 12:75d0291a9785 50 EncoderCounter& counterRight;
Helvis 12:75d0291a9785 51 IRSensor& irSensorL;
Helvis 12:75d0291a9785 52 IRSensor& irSensorC;
Helvis 12:75d0291a9785 53 IRSensor& irSensorR;
Helvis 12:75d0291a9785 54 AnalogIn& lineSensor;
Helvis 12:75d0291a9785 55 DigitalOut& enableMotorDriver;
Helvis 13:845e49f20426 56 Timer t;
Helvis 1:2b5f79285a3e 57
Helvis 12:75d0291a9785 58 float distanceL;
Helvis 12:75d0291a9785 59 float distanceC;
Helvis 12:75d0291a9785 60 float distanceR;
Helvis 12:75d0291a9785 61 int countsL;
Helvis 12:75d0291a9785 62 int countsR;
Helvis 12:75d0291a9785 63 int countsLOld;
Helvis 12:75d0291a9785 64 int countsROld;
Helvis 12:75d0291a9785 65 float speedLeft;
Helvis 12:75d0291a9785 66 float speedRight;
Helvis 12:75d0291a9785 67 float errorP;
Helvis 12:75d0291a9785 68 float errorD;
Helvis 12:75d0291a9785 69 float oldErrorP;
Helvis 12:75d0291a9785 70 float totalError;
Helvis 12:75d0291a9785 71 int waitStop;
Helvis 12:75d0291a9785 72 int path[];
Helvis 12:75d0291a9785 73 int task;
Helvis 12:75d0291a9785 74 bool reverse;
Helvis 18:3309329d5f42 75 int junction;
Helvis 12:75d0291a9785 76 bool acceleration;
Helvis 12:75d0291a9785 77 bool deceleration;
Helvis 21:41997651337a 78 bool longMove;
Helvis 12:75d0291a9785 79 int line;
Helvis 12:75d0291a9785 80 float countsOld;
Helvis 12:75d0291a9785 81 float avgSpeed;
Helvis 12:75d0291a9785 82 float actSpeed;
Helvis 13:845e49f20426 83 float targetSpeed;
Helvis 19:6cd6cc5c8b4c 84 bool lastMove;
luethale 27:f111ba194412 85 bool speedRun;
Helvis 1:2b5f79285a3e 86 };
Helvis 1:2b5f79285a3e 87
Helvis 1:2b5f79285a3e 88 #endif /* MOTION_H_ */