2014 Eurobot fork
Dependencies: mbed-rtos mbed QEI
Processes/AI/ai.cpp@49:665bdca0f2cd, 2013-04-12 (annotated)
- Committer:
- madcowswe
- Date:
- Fri Apr 12 21:07:00 2013 +0000
- Revision:
- 49:665bdca0f2cd
- Parent:
- 39:44d3dea4adcc
- Child:
- 50:937e860f4621
Kalman online phase estimation works but is SOOO hacked together
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rsavitski | 30:791739422122 | 1 | #include "ai.h" |
rsavitski | 30:791739422122 | 2 | |
rsavitski | 30:791739422122 | 3 | namespace AI |
rsavitski | 30:791739422122 | 4 | { |
rsavitski | 30:791739422122 | 5 | |
rsavitski | 30:791739422122 | 6 | void ailayer(void const *dummy) |
rsavitski | 30:791739422122 | 7 | { |
rsavitski | 39:44d3dea4adcc | 8 | Waypoint *current_waypoint = new Waypoint[5]; |
rsavitski | 39:44d3dea4adcc | 9 | /* |
rsavitski | 38:c9058a401410 | 10 | current_waypoint[0].x = 1; |
rsavitski | 38:c9058a401410 | 11 | current_waypoint[0].y = 1; |
rsavitski | 38:c9058a401410 | 12 | current_waypoint[0].theta = 0.0; |
rsavitski | 38:c9058a401410 | 13 | current_waypoint[0].pos_threshold = 0.05; |
rsavitski | 38:c9058a401410 | 14 | current_waypoint[0].angle_threshold = 0.05*PI; |
rsavitski | 38:c9058a401410 | 15 | |
rsavitski | 38:c9058a401410 | 16 | current_waypoint[1].x = 2.2; |
rsavitski | 38:c9058a401410 | 17 | current_waypoint[1].y = 1.5; |
rsavitski | 38:c9058a401410 | 18 | current_waypoint[1].theta = PI/2; |
rsavitski | 38:c9058a401410 | 19 | current_waypoint[1].pos_threshold = 0.05; |
rsavitski | 38:c9058a401410 | 20 | current_waypoint[1].angle_threshold = 0.05*PI; |
rsavitski | 38:c9058a401410 | 21 | |
rsavitski | 38:c9058a401410 | 22 | current_waypoint[2].x = -999; |
rsavitski | 39:44d3dea4adcc | 23 | */ |
rsavitski | 38:c9058a401410 | 24 | |
rsavitski | 39:44d3dea4adcc | 25 | current_waypoint[0].x = 0.5; |
madcowswe | 49:665bdca0f2cd | 26 | current_waypoint[0].y = 0.5; |
rsavitski | 39:44d3dea4adcc | 27 | current_waypoint[0].theta = 0.0; |
rsavitski | 39:44d3dea4adcc | 28 | current_waypoint[0].pos_threshold = 0.05; |
rsavitski | 39:44d3dea4adcc | 29 | current_waypoint[0].angle_threshold = 0.05*PI; |
rsavitski | 39:44d3dea4adcc | 30 | |
madcowswe | 49:665bdca0f2cd | 31 | current_waypoint[1].x = 2.5; |
madcowswe | 49:665bdca0f2cd | 32 | current_waypoint[1].y = 0.5; |
rsavitski | 39:44d3dea4adcc | 33 | current_waypoint[1].theta = 0; |
madcowswe | 49:665bdca0f2cd | 34 | current_waypoint[1].pos_threshold = 0.05; |
madcowswe | 49:665bdca0f2cd | 35 | current_waypoint[1].angle_threshold = 0.05*PI; |
rsavitski | 39:44d3dea4adcc | 36 | |
rsavitski | 39:44d3dea4adcc | 37 | current_waypoint[2].x = -999; |
rsavitski | 38:c9058a401410 | 38 | /* |
rsavitski | 30:791739422122 | 39 | //TODO: temp current waypoint hack |
rsavitski | 30:791739422122 | 40 | current_waypoint = new Waypoint; |
rsavitski | 30:791739422122 | 41 | current_waypoint->x = 0.5; |
rsavitski | 30:791739422122 | 42 | current_waypoint->y = 0.7; |
rsavitski | 30:791739422122 | 43 | current_waypoint->theta = 0.0; |
rsavitski | 30:791739422122 | 44 | current_waypoint->pos_threshold = 0.05; |
rsavitski | 38:c9058a401410 | 45 | current_waypoint->angle_threshold = 0.05*PI; |
rsavitski | 30:791739422122 | 46 | |
rsavitski | 30:791739422122 | 47 | Waypoint* secondwp = new Waypoint; |
rsavitski | 38:c9058a401410 | 48 | secondwp->x = 1.20; |
rsavitski | 38:c9058a401410 | 49 | secondwp->y = 0.18; |
rsavitski | 30:791739422122 | 50 | secondwp->theta = PI; |
rsavitski | 38:c9058a401410 | 51 | secondwp->pos_threshold = 0.01; |
rsavitski | 38:c9058a401410 | 52 | secondwp->angle_threshold = 0.00001; |
rsavitski | 38:c9058a401410 | 53 | */ |
rsavitski | 39:44d3dea4adcc | 54 | motion::setNewWaypoint(current_waypoint); |
madcowswe | 49:665bdca0f2cd | 55 | |
madcowswe | 49:665bdca0f2cd | 56 | int currwptidx = 0; |
rsavitski | 30:791739422122 | 57 | while(1) |
rsavitski | 30:791739422122 | 58 | { |
rsavitski | 35:f8e7f0a72a3d | 59 | Thread::wait(50); |
rsavitski | 30:791739422122 | 60 | |
rsavitski | 39:44d3dea4adcc | 61 | motion::waypoint_flag_mutex.lock(); |
rsavitski | 39:44d3dea4adcc | 62 | if (motion::checkWaypointStatus()) |
rsavitski | 30:791739422122 | 63 | { |
rsavitski | 39:44d3dea4adcc | 64 | |
madcowswe | 49:665bdca0f2cd | 65 | motion::setNewWaypoint(¤t_waypoint[++currwptidx % 2]); |
madcowswe | 49:665bdca0f2cd | 66 | motion::clearWaypointReached(); |
rsavitski | 30:791739422122 | 67 | } |
rsavitski | 39:44d3dea4adcc | 68 | motion::waypoint_flag_mutex.unlock(); |
rsavitski | 30:791739422122 | 69 | } |
rsavitski | 30:791739422122 | 70 | } |
rsavitski | 30:791739422122 | 71 | |
rsavitski | 30:791739422122 | 72 | } //namespace |