Program that combines a linefollower program with visible ligt communication.

Dependencies:   m3pi_custom mbed

linefollower.h

Committer:
bertgereels
Date:
2018-05-09
Revision:
0:1f5782fc5ca3
Child:
1:243ec35fafcd

File content as of revision 0:1f5782fc5ca3:

#include "mbed.h"
#include "m3pi.h"
#include "manchester.h"

#pragma once 

// Minimum and maximum motor speeds
#define MAX_SPEED 0.2
#define MIN_SPEED 0

// PID terms
#define P_TERM 1
#define I_TERM 0
#define D_TERM 10

namespace ProjectTwo{
    
    class LineFollower{
        public:
            LineFollower(void);
            void followTheLine(void);
        private:
            m3pi m3pi;
            manchester decoder;
            
            enum lineFollowerStates{
                STATE_INIT,
                STATE_COMPUTE,
                STATE_FORWARD,
                STATE_LEFT,
                STATE_RIGHT,
                STATE_BACKWARD,
                STATE_STOP,
                STATE_VLC
            };
            lineFollowerStates CurrentLineFollowerState;
            
            float computeDerivative(void);
            float computeIntegral(void);
            float computePower(void);
            void computeNewSpeeds(void);
            void limitChecks(void);

            void turnLeft90(void);
            void turnRight90(void);
            void goBackwards(void);
            void goForwards(void);
            
            void checkForIntersection(void);
            
            float right;
            float left;
            float current_pos_of_line;
            float previous_pos_of_line;
            float derivative,proportional,integral;
            float power;
            float speed;
            
            bool disableStop;
            bool foundIntersection;

    };
};