Daniel Petti | aece37f | 2014-10-25 17:13:44 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 2 | |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 3 | #include "aos/common/time.h" |
Brian Silverman | 14fd0fb | 2014-01-14 21:42:01 -0800 | [diff] [blame] | 4 | #include "aos/linux_code/init.h" |
Brian Silverman | 598800f | 2013-05-09 17:08:42 -0700 | [diff] [blame] | 5 | #include "aos/common/logging/logging.h" |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 6 | #include "frc971/autonomous/auto.q.h" |
Brian Silverman | b691f5e | 2015-08-02 11:37:55 -0700 | [diff] [blame] | 7 | #include "y2015/autonomous/auto.h" |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 8 | |
| 9 | using ::aos::time::Time; |
| 10 | |
| 11 | int main(int /*argc*/, char * /*argv*/[]) { |
Brian Silverman | 5090c43 | 2016-01-02 14:44:26 -0800 | [diff] [blame] | 12 | ::aos::Init(-1); |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 13 | |
Austin Schuh | a4faacc | 2014-03-09 00:50:50 -0800 | [diff] [blame] | 14 | LOG(INFO, "Auto main started\n"); |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 15 | ::frc971::autonomous::autonomous.FetchLatest(); |
| 16 | while (!::frc971::autonomous::autonomous.get()) { |
Austin Schuh | 6be011a | 2013-03-19 10:07:02 +0000 | [diff] [blame] | 17 | ::frc971::autonomous::autonomous.FetchNextBlocking(); |
| 18 | LOG(INFO, "Got another auto packet\n"); |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | while (true) { |
| 22 | while (!::frc971::autonomous::autonomous->run_auto) { |
| 23 | ::frc971::autonomous::autonomous.FetchNextBlocking(); |
Austin Schuh | 6be011a | 2013-03-19 10:07:02 +0000 | [diff] [blame] | 24 | LOG(INFO, "Got another auto packet\n"); |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 25 | } |
Austin Schuh | 6be011a | 2013-03-19 10:07:02 +0000 | [diff] [blame] | 26 | LOG(INFO, "Starting auto mode\n"); |
Austin Schuh | a4faacc | 2014-03-09 00:50:50 -0800 | [diff] [blame] | 27 | ::aos::time::Time start_time = ::aos::time::Time::Now(); |
Austin Schuh | 88af085 | 2016-12-04 20:31:32 -0800 | [diff] [blame] | 28 | ::y2015::autonomous::HandleAuto(); |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 29 | |
Austin Schuh | a4faacc | 2014-03-09 00:50:50 -0800 | [diff] [blame] | 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()); |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 33 | while (::frc971::autonomous::autonomous->run_auto) { |
| 34 | ::frc971::autonomous::autonomous.FetchNextBlocking(); |
Austin Schuh | 6be011a | 2013-03-19 10:07:02 +0000 | [diff] [blame] | 35 | LOG(INFO, "Got another auto packet\n"); |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 36 | } |
Austin Schuh | 6be011a | 2013-03-19 10:07:02 +0000 | [diff] [blame] | 37 | LOG(INFO, "Waiting for auto to start back up.\n"); |
Austin Schuh | 4701741 | 2013-03-10 11:50:46 -0700 | [diff] [blame] | 38 | } |
| 39 | ::aos::Cleanup(); |
| 40 | return 0; |
| 41 | } |
| 42 | |