blob: 7966d971e8f56da8ace98b429ca2d48f6fe36ecf [file] [log] [blame]
Comran Morshede9b12922015-11-04 19:46:48 +00001#include <stdio.h>
2
3#include "aos/common/time.h"
4#include "aos/linux_code/init.h"
5#include "aos/common/logging/logging.h"
Comran Morshed41ed7c22015-11-04 21:03:37 +00006#include "y2014_bot3/autonomous/auto.q.h"
7#include "y2014_bot3/autonomous/auto.h"
Comran Morshede9b12922015-11-04 19:46:48 +00008
9using ::aos::time::Time;
10
11int main(int /*argc*/, char * /*argv*/[]) {
12 ::aos::Init();
13
Comran Morshed41ed7c22015-11-04 21:03:37 +000014 LOG(INFO, "Auto main started.\n");
15 ::y2014_bot3::autonomous::autonomous.FetchLatest();
16 while (!::y2014_bot3::autonomous::autonomous.get()) {
17 ::y2014_bot3::autonomous::autonomous.FetchNextBlocking();
Comran Morshede9b12922015-11-04 19:46:48 +000018 LOG(INFO, "Got another auto packet\n");
19 }
20
21 while (true) {
Comran Morshed41ed7c22015-11-04 21:03:37 +000022 while (!::y2014_bot3::autonomous::autonomous->run_auto) {
23 ::y2014_bot3::autonomous::autonomous.FetchNextBlocking();
Comran Morshede9b12922015-11-04 19:46:48 +000024 LOG(INFO, "Got another auto packet\n");
25 }
26 LOG(INFO, "Starting auto mode\n");
27 ::aos::time::Time start_time = ::aos::time::Time::Now();
Comran Morshed41ed7c22015-11-04 21:03:37 +000028 ::y2014_bot3::autonomous::HandleAuto();
Comran Morshede9b12922015-11-04 19:46:48 +000029
30 ::aos::time::Time elapsed_time = ::aos::time::Time::Now() - start_time;
31 LOG(INFO, "Auto mode exited in %f, waiting for it to finish.\n",
32 elapsed_time.ToSeconds());
Comran Morshed41ed7c22015-11-04 21:03:37 +000033 while (::y2014_bot3::autonomous::autonomous->run_auto) {
34 ::y2014_bot3::autonomous::autonomous.FetchNextBlocking();
Comran Morshede9b12922015-11-04 19:46:48 +000035 LOG(INFO, "Got another auto packet\n");
36 }
37 LOG(INFO, "Waiting for auto to start back up.\n");
38 }
39 ::aos::Cleanup();
40 return 0;
41}
42