Colour sensors calibrated

Dependencies:   mbed-rtos mbed Servo QEI

Fork of ICRSEurobot13 by Thomas Branch

Revision:
31:791739422122
Child:
34:a49197572737
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Processes/AI/ai.cpp	Wed Apr 10 18:03:32 2013 +0000
@@ -0,0 +1,62 @@
+#include "ai.h"
+
+namespace AI
+{
+
+Mutex waypoint_flag_mutex;
+
+Waypoint* current_waypoint = NULL; //global scope
+
+bool waypoint_reached = false; // is current waypoint reached
+
+void ailayer(void const *dummy)
+{
+    //TODO: temp current waypoint hack
+    current_waypoint = new Waypoint;
+    current_waypoint->x = 0.5;
+    current_waypoint->y = 0.7;
+    current_waypoint->theta = 0.0;
+    current_waypoint->pos_threshold = 0.05;
+    current_waypoint->angle_threshold = 0.1*PI;
+    
+    Waypoint* secondwp = new Waypoint;
+    secondwp->x = 2;
+    secondwp->y = 1.2;
+    secondwp->theta = PI;
+    secondwp->pos_threshold = 0.05;
+    secondwp->angle_threshold = 0.1*PI;
+    
+    
+    while(1)
+    {
+        Thread::wait(100);
+        
+        waypoint_flag_mutex.lock();
+        if (checkWaypointStatus())
+        {
+            clearWaypointReached();
+            delete current_waypoint;
+            current_waypoint = secondwp;
+        }
+        waypoint_flag_mutex.unlock();
+    }
+    
+    Thread::yield(); //TODO!!!!!!!!!!!!!!!!!!!
+}
+
+void setWaypointReached()
+{
+    waypoint_reached = true;
+}
+
+void clearWaypointReached()
+{
+    waypoint_reached = false;
+}
+
+bool checkWaypointStatus()
+{
+    return waypoint_reached;
+}
+
+} //namespace
\ No newline at end of file