2014 Eurobot fork

Dependencies:   mbed-rtos mbed QEI

Processes/AI/ai.cpp

Committer:
rsavitski
Date:
2013-04-12
Revision:
54:99d3158c9207
Parent:
53:b013df99b747
Child:
55:0c8897da6b3a

File content as of revision 54:99d3158c9207:

#include "ai.h"

namespace AI
{

void ailayer(void const *dummy)
{
    Waypoint current_waypoint;

    current_waypoint.x = 2.2;
    current_waypoint.y = 1.85;
    current_waypoint.theta = PI;
    current_waypoint.pos_threshold = 0.01;
    current_waypoint.angle_threshold = 0.02*PI;

    motion::setNewWaypoint(&current_waypoint);
    

    
    float r = 0.61;

    for (float phi=(180-11.25)/180*PI; phi > 11.25/180*PI;)
    {
        motion::waypoint_flag_mutex.lock();
        if (motion::checkWaypointStatus())
        {
            phi -= 22.5/180*PI;
            current_waypoint.x = 1.5-r*cos(phi);
            current_waypoint.y = 2-r*sin(phi);
            current_waypoint.theta = constrainAngle(phi+PI/2);
            motion::clearWaypointReached();
            motion::setNewWaypoint(&current_waypoint);
        }
        motion::waypoint_flag_mutex.unlock();            
        
        Thread::wait(50);
    }
}

} //namespace