blob: 1357d7cb2d5176fb2c45945c343fde2de919ba3c [file] [log] [blame]
Austin Schuh6d1ee0c2015-11-21 14:36:04 -08001#include <stdio.h>
2
3#include "aos/common/time.h"
4#include "aos/linux_code/init.h"
5#include "aos/common/logging/logging.h"
6#include "y2015_bot3/autonomous/auto.q.h"
7#include "y2015_bot3/autonomous/auto.h"
8
Austin Schuh6d1ee0c2015-11-21 14:36:04 -08009int main(int /*argc*/, char * /*argv*/[]) {
Brian Silverman5090c432016-01-02 14:44:26 -080010 ::aos::Init(-1);
Austin Schuh6d1ee0c2015-11-21 14:36:04 -080011
12 LOG(INFO, "Auto main started\n");
13 ::y2015_bot3::autonomous::autonomous.FetchLatest();
14 while (!::y2015_bot3::autonomous::autonomous.get()) {
15 ::y2015_bot3::autonomous::autonomous.FetchNextBlocking();
16 LOG(INFO, "Got another auto packet\n");
17 }
18
19 while (true) {
20 while (!::y2015_bot3::autonomous::autonomous->run_auto) {
21 ::y2015_bot3::autonomous::autonomous.FetchNextBlocking();
22 LOG(INFO, "Got another auto packet\n");
23 }
24 LOG(INFO, "Starting auto mode\n");
Austin Schuhf2a50ba2016-12-24 16:16:26 -080025 const ::aos::monotonic_clock::time_point start_time =
26 ::aos::monotonic_clock::now();
Austin Schuh6d1ee0c2015-11-21 14:36:04 -080027 ::y2015_bot3::autonomous::HandleAuto();
28
Austin Schuhf2a50ba2016-12-24 16:16:26 -080029 const auto elapsed_time = ::aos::monotonic_clock::now() - start_time;
Austin Schuh6d1ee0c2015-11-21 14:36:04 -080030 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());
Austin Schuh6d1ee0c2015-11-21 14:36:04 -080034 while (::y2015_bot3::autonomous::autonomous->run_auto) {
35 ::y2015_bot3::autonomous::autonomous.FetchNextBlocking();
36 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