blob: adf1bcacc73c9c2bb717c7d43770c71ba9eca585 [file] [log] [blame]
Comran Morshed9a9948c2016-01-16 15:58:04 +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"
6#include "frc971/autonomous/auto.q.h"
Comran Morshed6c6a0a92016-01-17 12:45:16 +00007#include "y2016/autonomous/auto.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +00008
9using ::aos::time::Time;
10
Comran Morshed6c6a0a92016-01-17 12:45:16 +000011int main(int /*argc*/, char * /*argv*/ []) {
Comran Morshed9a9948c2016-01-16 15:58:04 +000012 ::aos::Init(-1);
13
14 LOG(INFO, "Auto main started\n");
15 ::frc971::autonomous::autonomous.FetchLatest();
Comran Morshed6c6a0a92016-01-17 12:45:16 +000016
Comran Morshed9a9948c2016-01-16 15:58:04 +000017 while (!::frc971::autonomous::autonomous.get()) {
18 ::frc971::autonomous::autonomous.FetchNextBlocking();
19 LOG(INFO, "Got another auto packet\n");
20 }
21
22 while (true) {
23 while (!::frc971::autonomous::autonomous->run_auto) {
24 ::frc971::autonomous::autonomous.FetchNextBlocking();
25 LOG(INFO, "Got another auto packet\n");
26 }
Comran Morshed6c6a0a92016-01-17 12:45:16 +000027
Comran Morshed9a9948c2016-01-16 15:58:04 +000028 LOG(INFO, "Starting auto mode\n");
29 ::aos::time::Time start_time = ::aos::time::Time::Now();
Comran Morshed6c6a0a92016-01-17 12:45:16 +000030 ::y2016::autonomous::HandleAuto();
Comran Morshed9a9948c2016-01-16 15:58:04 +000031
32 ::aos::time::Time elapsed_time = ::aos::time::Time::Now() - start_time;
33 LOG(INFO, "Auto mode exited in %f, waiting for it to finish.\n",
34 elapsed_time.ToSeconds());
Comran Morshed6c6a0a92016-01-17 12:45:16 +000035
Comran Morshed9a9948c2016-01-16 15:58:04 +000036 while (::frc971::autonomous::autonomous->run_auto) {
37 ::frc971::autonomous::autonomous.FetchNextBlocking();
38 LOG(INFO, "Got another auto packet\n");
39 }
Comran Morshed6c6a0a92016-01-17 12:45:16 +000040
Comran Morshed9a9948c2016-01-16 15:58:04 +000041 LOG(INFO, "Waiting for auto to start back up.\n");
42 }
Comran Morshed6c6a0a92016-01-17 12:45:16 +000043
Comran Morshed9a9948c2016-01-16 15:58:04 +000044 ::aos::Cleanup();
45 return 0;
46}