Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 1 | #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" |
| 7 | #include "y2014/autonomous/auto.h" |
| 8 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 9 | int main(int /*argc*/, char * /*argv*/[]) { |
Brian Silverman | 5090c43 | 2016-01-02 14:44:26 -0800 | [diff] [blame] | 10 | ::aos::Init(-1); |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 11 | |
| 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 Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame^] | 25 | ::aos::monotonic_clock::time_point start_time = |
| 26 | ::aos::monotonic_clock::now(); |
Brian Silverman | b601d89 | 2015-12-20 18:24:38 -0500 | [diff] [blame] | 27 | ::y2014::autonomous::HandleAuto(); |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 28 | |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame^] | 29 | auto elapsed_time = ::aos::monotonic_clock::now() - start_time; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 30 | 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^] | 31 | ::std::chrono::duration_cast<::std::chrono::duration<double>>( |
| 32 | elapsed_time) |
| 33 | .count()); |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 34 | while (::frc971::autonomous::autonomous->run_auto) { |
| 35 | ::frc971::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 | |