This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
Processes/AI/ai.cpp
- Committer:
- rsavitski
- Date:
- 2013-04-10
- Revision:
- 38:c9058a401410
- Parent:
- 37:6ecf0d21e492
- Child:
- 39:44d3dea4adcc
File content as of revision 38:c9058a401410:
#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) { current_waypoint = new Waypoint[5]; current_waypoint[0].x = 1; current_waypoint[0].y = 1; current_waypoint[0].theta = 0.0; current_waypoint[0].pos_threshold = 0.05; current_waypoint[0].angle_threshold = 0.05*PI; current_waypoint[1].x = 2.2; current_waypoint[1].y = 1.5; current_waypoint[1].theta = PI/2; current_waypoint[1].pos_threshold = 0.05; current_waypoint[1].angle_threshold = 0.05*PI; current_waypoint[2].x = -999; /* //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.05*PI; Waypoint* secondwp = new Waypoint; secondwp->x = 1.20; secondwp->y = 0.18; secondwp->theta = PI; secondwp->pos_threshold = 0.01; secondwp->angle_threshold = 0.00001; */ while(1) { Thread::wait(50); waypoint_flag_mutex.lock(); if (checkWaypointStatus()) { clearWaypointReached(); if ((current_waypoint+1)->x != -999) current_waypoint++; } waypoint_flag_mutex.unlock(); } } void setWaypointReached() { waypoint_reached = true; } void clearWaypointReached() { waypoint_reached = false; } bool checkWaypointStatus() { return waypoint_reached; } } //namespace