Program that combines a linefollower program with visible ligt communication.

Dependencies:   m3pi_custom mbed

Committer:
bertgereels
Date:
Wed May 09 15:35:31 2018 +0000
Revision:
0:1f5782fc5ca3
Child:
1:243ec35fafcd
this is a test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bertgereels 0:1f5782fc5ca3 1 #include "mbed.h"
bertgereels 0:1f5782fc5ca3 2 #include "m3pi.h"
bertgereels 0:1f5782fc5ca3 3 #include "manchester.h"
bertgereels 0:1f5782fc5ca3 4
bertgereels 0:1f5782fc5ca3 5 #pragma once
bertgereels 0:1f5782fc5ca3 6
bertgereels 0:1f5782fc5ca3 7 // Minimum and maximum motor speeds
bertgereels 0:1f5782fc5ca3 8 #define MAX_SPEED 0.2
bertgereels 0:1f5782fc5ca3 9 #define MIN_SPEED 0
bertgereels 0:1f5782fc5ca3 10
bertgereels 0:1f5782fc5ca3 11 // PID terms
bertgereels 0:1f5782fc5ca3 12 #define P_TERM 1
bertgereels 0:1f5782fc5ca3 13 #define I_TERM 0
bertgereels 0:1f5782fc5ca3 14 #define D_TERM 10
bertgereels 0:1f5782fc5ca3 15
bertgereels 0:1f5782fc5ca3 16 namespace ProjectTwo{
bertgereels 0:1f5782fc5ca3 17
bertgereels 0:1f5782fc5ca3 18 class LineFollower{
bertgereels 0:1f5782fc5ca3 19 public:
bertgereels 0:1f5782fc5ca3 20 LineFollower(void);
bertgereels 0:1f5782fc5ca3 21 void followTheLine(void);
bertgereels 0:1f5782fc5ca3 22 private:
bertgereels 0:1f5782fc5ca3 23 m3pi m3pi;
bertgereels 0:1f5782fc5ca3 24 manchester decoder;
bertgereels 0:1f5782fc5ca3 25
bertgereels 0:1f5782fc5ca3 26 enum lineFollowerStates{
bertgereels 0:1f5782fc5ca3 27 STATE_INIT,
bertgereels 0:1f5782fc5ca3 28 STATE_COMPUTE,
bertgereels 0:1f5782fc5ca3 29 STATE_FORWARD,
bertgereels 0:1f5782fc5ca3 30 STATE_LEFT,
bertgereels 0:1f5782fc5ca3 31 STATE_RIGHT,
bertgereels 0:1f5782fc5ca3 32 STATE_BACKWARD,
bertgereels 0:1f5782fc5ca3 33 STATE_STOP,
bertgereels 0:1f5782fc5ca3 34 STATE_VLC
bertgereels 0:1f5782fc5ca3 35 };
bertgereels 0:1f5782fc5ca3 36 lineFollowerStates CurrentLineFollowerState;
bertgereels 0:1f5782fc5ca3 37
bertgereels 0:1f5782fc5ca3 38 float computeDerivative(void);
bertgereels 0:1f5782fc5ca3 39 float computeIntegral(void);
bertgereels 0:1f5782fc5ca3 40 float computePower(void);
bertgereels 0:1f5782fc5ca3 41 void computeNewSpeeds(void);
bertgereels 0:1f5782fc5ca3 42 void limitChecks(void);
bertgereels 0:1f5782fc5ca3 43
bertgereels 0:1f5782fc5ca3 44 void turnLeft90(void);
bertgereels 0:1f5782fc5ca3 45 void turnRight90(void);
bertgereels 0:1f5782fc5ca3 46 void goBackwards(void);
bertgereels 0:1f5782fc5ca3 47 void goForwards(void);
bertgereels 0:1f5782fc5ca3 48
bertgereels 0:1f5782fc5ca3 49 void checkForIntersection(void);
bertgereels 0:1f5782fc5ca3 50
bertgereels 0:1f5782fc5ca3 51 float right;
bertgereels 0:1f5782fc5ca3 52 float left;
bertgereels 0:1f5782fc5ca3 53 float current_pos_of_line;
bertgereels 0:1f5782fc5ca3 54 float previous_pos_of_line;
bertgereels 0:1f5782fc5ca3 55 float derivative,proportional,integral;
bertgereels 0:1f5782fc5ca3 56 float power;
bertgereels 0:1f5782fc5ca3 57 float speed;
bertgereels 0:1f5782fc5ca3 58
bertgereels 0:1f5782fc5ca3 59 bool disableStop;
bertgereels 0:1f5782fc5ca3 60 bool foundIntersection;
bertgereels 0:1f5782fc5ca3 61
bertgereels 0:1f5782fc5ca3 62 };
bertgereels 0:1f5782fc5ca3 63 };