BeaconAvoid code for AHRC competition.

Dependencies:   MODSERIAL PiSlingers m3pi mbed

Revision:
0:9ac4a91b71fa
Child:
4:369caebdf5dc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IRBehaviorController.h	Wed Apr 04 17:07:49 2012 +0000
@@ -0,0 +1,54 @@
+#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.
+    
+    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
\ No newline at end of file