blob: f125cc23af31928ad604770a964883c4e66a5b04 [file] [log] [blame]
Brian Silverman17f503e2015-08-02 18:17:18 -07001#include <stdio.h>
2
John Park398c74a2018-10-20 21:17:39 -07003#include "aos/init.h"
John Park33858a32018-09-28 23:05:48 -07004#include "aos/logging/logging.h"
James Kuszmaul651fc3f2019-05-15 21:14:25 -07005#include "aos/time/time.h"
Brian Silverman17f503e2015-08-02 18:17:18 -07006#include "frc971/autonomous/auto.q.h"
7#include "y2014/autonomous/auto.h"
8
James Kuszmaul651fc3f2019-05-15 21:14:25 -07009int main(int /*argc*/, char * /*argv*/ []) {
Brian Silverman5090c432016-01-02 14:44:26 -080010 ::aos::Init(-1);
Brian Silverman17f503e2015-08-02 18:17:18 -070011
12 LOG(INFO, "Auto main started\n");
13 ::frc971::autonomous::autonomous.FetchLatest();
14 while (!::frc971::autonomous::autonomous.get()) {
15 ::frc971::autonomous::autonomous.FetchNextBlocking();
16 LOG(INFO, "Got another auto packet\n");
17 }
18
19 while (true) {
20 while (!::frc971::autonomous::autonomous->run_auto) {
21 ::frc971::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 ::aos::monotonic_clock::time_point start_time =
26 ::aos::monotonic_clock::now();
Brian Silvermanb601d892015-12-20 18:24:38 -050027 ::y2014::autonomous::HandleAuto();
Brian Silverman17f503e2015-08-02 18:17:18 -070028
Austin Schuhf2a50ba2016-12-24 16:16:26 -080029 auto elapsed_time = ::aos::monotonic_clock::now() - start_time;
Brian Silverman17f503e2015-08-02 18:17:18 -070030 LOG(INFO, "Auto mode exited in %f, waiting for it to finish.\n",
James Kuszmaul651fc3f2019-05-15 21:14:25 -070031 ::aos::time::DurationInSeconds(elapsed_time));
Brian Silverman17f503e2015-08-02 18:17:18 -070032 while (::frc971::autonomous::autonomous->run_auto) {
33 ::frc971::autonomous::autonomous.FetchNextBlocking();
34 LOG(INFO, "Got another auto packet\n");
35 }
36 LOG(INFO, "Waiting for auto to start back up.\n");
37 }
38 ::aos::Cleanup();
39 return 0;
40}