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