blob: 55c7c054cb2d991ca16d044081a0b3a0eb5badc3 [file] [log] [blame]
Comran Morshede9b12922015-11-04 19:46:48 +00001#include <stdio.h>
2
John Park33858a32018-09-28 23:05:48 -07003#include "aos/time/time.h"
John Park398c74a2018-10-20 21:17:39 -07004#include "aos/init.h"
John Park33858a32018-09-28 23:05:48 -07005#include "aos/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
Comran Morshede9b12922015-11-04 19:46:48 +00009int main(int /*argc*/, char * /*argv*/[]) {
Brian Silverman5090c432016-01-02 14:44:26 -080010 ::aos::Init(-1);
Comran Morshede9b12922015-11-04 19:46:48 +000011
Comran Morshed41ed7c22015-11-04 21:03:37 +000012 LOG(INFO, "Auto main started.\n");
13 ::y2014_bot3::autonomous::autonomous.FetchLatest();
14 while (!::y2014_bot3::autonomous::autonomous.get()) {
15 ::y2014_bot3::autonomous::autonomous.FetchNextBlocking();
Comran Morshede9b12922015-11-04 19:46:48 +000016 LOG(INFO, "Got another auto packet\n");
17 }
18
19 while (true) {
Comran Morshed41ed7c22015-11-04 21:03:37 +000020 while (!::y2014_bot3::autonomous::autonomous->run_auto) {
21 ::y2014_bot3::autonomous::autonomous.FetchNextBlocking();
Comran Morshede9b12922015-11-04 19:46:48 +000022 LOG(INFO, "Got another auto packet\n");
23 }
24 LOG(INFO, "Starting auto mode\n");
Austin Schuhf2a50ba2016-12-24 16:16:26 -080025 ::aos::monotonic_clock::time_point start_time =
26 ::aos::monotonic_clock::now();
Comran Morshed41ed7c22015-11-04 21:03:37 +000027 ::y2014_bot3::autonomous::HandleAuto();
Comran Morshede9b12922015-11-04 19:46:48 +000028
Austin Schuhf2a50ba2016-12-24 16:16:26 -080029 auto elapsed_time = ::aos::monotonic_clock::now() - start_time;
Comran Morshede9b12922015-11-04 19:46:48 +000030 LOG(INFO, "Auto mode exited in %f, waiting for it to finish.\n",
Austin Schuhf2a50ba2016-12-24 16:16:26 -080031 ::std::chrono::duration_cast<::std::chrono::duration<double>>(
32 elapsed_time)
33 .count());
Comran Morshed41ed7c22015-11-04 21:03:37 +000034 while (::y2014_bot3::autonomous::autonomous->run_auto) {
35 ::y2014_bot3::autonomous::autonomous.FetchNextBlocking();
Comran Morshede9b12922015-11-04 19:46:48 +000036 LOG(INFO, "Got another auto packet\n");
37 }
38 LOG(INFO, "Waiting for auto to start back up.\n");
39 }
40 ::aos::Cleanup();
41 return 0;
42}
43