BeaconAvoid code for AHRC competition.

Dependencies:   MODSERIAL PiSlingers m3pi mbed

IRBehaviorController.h

Committer:
mpanetta
Date:
2016-03-09
Revision:
4:369caebdf5dc
Parent:
0:9ac4a91b71fa

File content as of revision 4:369caebdf5dc:

#ifndef __IRBEHAVIORCONTROLLER_H__
#define __IRBEHAVIORCONTROLLER_H__

#include "mbed.h"
#include "IRObjDetector.h"
#include "PID.h"

class IRBehaviorController
{
public:
    IRBehaviorController(PID *pid) : pid(pid)
    {
        debug               = NULL;
        activationThreshold = 0.0f;
        brightness          = 0.0f;
        output              = 0.0f;        
    };
    
    IRBehaviorController(PID * pid, Serial * debug) : debug(debug), ird(debug), pid(pid)
    //IRBehaviorController(PID * pid, Serial * debug) : debug(debug), pid(pid) 
    {
        activationThreshold = 0.0f;
        brightness          = 0.0f;
        output              = 0.0f;
    };
    
    void setAvoidanceBehavior(float threshold);
    void setSeekingBehavior(float threshold);
    
    void setActiveThreshold(float threshold);   // Brightness level at which behavior is active.
    
    void runAvoidance(void);                    // Execute avoidance behavior
    void runSeeking(void);                      // Execute seeking behavior
    
    float getPower(void);                       // Returns the power value needed to execute the behavior.
    float getBrightness(void);
    float getCenteroid(void);
    
    void  dumpDebug(Serial *debug);
    
private:

    void            scanIR(void);

    Serial          *debug;
    
    IRObjDetector   ird;
    PID             *pid;
    
    float           activationThreshold;             // Brightness threshold at which behavior is active.
    float           brightness;
    float           centeroid;
      
    float           output;
};
#endif