Alle Prinf's auskommentiert

Dependencies:   mbed

Fork of Micromouse by Helvijs Kiselis

Committer:
luethale
Date:
Thu May 10 16:33:32 2018 +0000
Revision:
19:e2cb5b8a7a29
Parent:
18:3309329d5f42
Alle Printf's auskommentiert

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 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;
Helvis 13:845e49f20426 43 static const float SCAN_SPEED;
Helvis 12:75d0291a9785 44 static const float ROTATE_SPEED;
Helvis 13:845e49f20426 45 static const float ACCEL_CONST;
Helvis 1:2b5f79285a3e 46
Helvis 12:75d0291a9785 47 Controller& controller;
Helvis 12:75d0291a9785 48 EncoderCounter& counterLeft;
Helvis 12:75d0291a9785 49 EncoderCounter& counterRight;
Helvis 12:75d0291a9785 50 IRSensor& irSensorL;
Helvis 12:75d0291a9785 51 IRSensor& irSensorC;
Helvis 12:75d0291a9785 52 IRSensor& irSensorR;
Helvis 12:75d0291a9785 53 AnalogIn& lineSensor;
Helvis 12:75d0291a9785 54 DigitalOut& enableMotorDriver;
Helvis 13:845e49f20426 55 Timer t;
Helvis 1:2b5f79285a3e 56
Helvis 12:75d0291a9785 57 float distanceL;
Helvis 12:75d0291a9785 58 float distanceC;
Helvis 12:75d0291a9785 59 float distanceR;
Helvis 12:75d0291a9785 60 int countsL;
Helvis 12:75d0291a9785 61 int countsR;
Helvis 12:75d0291a9785 62 int countsLOld;
Helvis 12:75d0291a9785 63 int countsROld;
Helvis 12:75d0291a9785 64 float speedLeft;
Helvis 12:75d0291a9785 65 float speedRight;
Helvis 12:75d0291a9785 66 float errorP;
Helvis 12:75d0291a9785 67 float errorD;
Helvis 12:75d0291a9785 68 float oldErrorP;
Helvis 12:75d0291a9785 69 float totalError;
Helvis 12:75d0291a9785 70 int waitStop;
Helvis 12:75d0291a9785 71 int path[];
Helvis 12:75d0291a9785 72 int task;
Helvis 12:75d0291a9785 73 bool reverse;
Helvis 18:3309329d5f42 74 int junction;
Helvis 12:75d0291a9785 75 bool acceleration;
Helvis 12:75d0291a9785 76 bool deceleration;
Helvis 12:75d0291a9785 77 int line;
Helvis 12:75d0291a9785 78 float countsOld;
Helvis 12:75d0291a9785 79 float avgSpeed;
Helvis 12:75d0291a9785 80 float avgCounts;
Helvis 12:75d0291a9785 81 float actSpeed;
Helvis 13:845e49f20426 82 float targetSpeed;
Helvis 1:2b5f79285a3e 83 };
Helvis 1:2b5f79285a3e 84
Helvis 1:2b5f79285a3e 85 #endif /* MOTION_H_ */