Algorithmus

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Motion.h Source File

Motion.h

00001 #ifndef MOTION_H_
00002 #define MOTION_H_
00003 
00004 #include <cstdlib>
00005 #include <mbed.h>
00006 #include "EncoderCounter.h"
00007 #include "Controller.h"
00008 #include "IRSensor.h"
00009 
00010 
00011 class Motion {
00012     
00013     public:
00014     
00015         Motion(Controller& controller, EncoderCounter& counterLeft,
00016                 EncoderCounter& counterRight, IRSensor& irSensorL,
00017                 IRSensor& irSensorC, IRSensor& irSensorR, AnalogIn& lineSensor,
00018                 DigitalOut& enableMotorDriver);
00019         
00020         virtual ~Motion();
00021         void    move();
00022         void    moveHalf();
00023         void    scanMove();
00024         void    rotateL();
00025         void    rotateR();
00026         void    turnL();
00027         void    turnR();
00028         void    stop();
00029         void    rotate180();
00030         void    control();
00031         void    runTask(int path[], int task, bool reverse, int junction);
00032         int     finish();
00033         void    accel(float targetSpeed);
00034 
00035     private:
00036     
00037         static const float  LEFT_MID_VAL;
00038         static const float  RIGHT_MID_VAL;
00039         static const float  KP;
00040         static const float  KD;
00041         static const int    MOVE_DIST;
00042         static const float  MOVE_SPEED;
00043         static const float  RUN_SPEED;
00044         static const float  TURN_SPEED_LEFT;
00045         static const float  ROTATE_SPEED;
00046         static const float  ACCEL_CONST;
00047         
00048         Controller&         controller;
00049         EncoderCounter&     counterLeft;
00050         EncoderCounter&     counterRight;
00051         IRSensor&           irSensorL;
00052         IRSensor&           irSensorC;
00053         IRSensor&           irSensorR;
00054         AnalogIn&           lineSensor;
00055         DigitalOut&         enableMotorDriver;
00056         Timer               t;
00057         
00058         float               distanceL;
00059         float               distanceC;
00060         float               distanceR;
00061         int                 countsL;
00062         int                 countsR;
00063         int                 countsLOld;
00064         int                 countsROld;
00065         float               speedLeft;
00066         float               speedRight;
00067         float               errorP;
00068         float               errorD;
00069         float               oldErrorP;
00070         float               totalError;
00071         int                 waitStop;
00072         int                 path[];
00073         int                 task;
00074         bool                reverse;
00075         int                 junction;
00076         bool                acceleration;
00077         bool                deceleration;
00078         bool                longMove;
00079         int                 line;
00080         float               countsOld;
00081         float               avgSpeed;
00082         float               actSpeed;
00083         float               targetSpeed;
00084         bool                lastMove;
00085         bool                speedRun;
00086     };
00087     
00088 #endif /* MOTION_H_ */