Colour sensors calibrated

Dependencies:   mbed-rtos mbed Servo QEI

Fork of ICRSEurobot13 by Thomas Branch

Processes/AI/ai.cpp

Committer:
rsavitski
Date:
2013-04-10
Revision:
31:791739422122
Child:
34:a49197572737

File content as of revision 31:791739422122:

#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