Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [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" |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame^] | 7 | #include "y2016/autonomous/auto.h" |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 8 | |
| 9 | using ::aos::time::Time; |
| 10 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame^] | 11 | int main(int /*argc*/, char * /*argv*/ []) { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 12 | ::aos::Init(-1); |
| 13 | |
| 14 | LOG(INFO, "Auto main started\n"); |
| 15 | ::frc971::autonomous::autonomous.FetchLatest(); |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame^] | 16 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 17 | 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 Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame^] | 27 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 28 | LOG(INFO, "Starting auto mode\n"); |
| 29 | ::aos::time::Time start_time = ::aos::time::Time::Now(); |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame^] | 30 | ::y2016::autonomous::HandleAuto(); |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 31 | |
| 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 Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame^] | 35 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 36 | while (::frc971::autonomous::autonomous->run_auto) { |
| 37 | ::frc971::autonomous::autonomous.FetchNextBlocking(); |
| 38 | LOG(INFO, "Got another auto packet\n"); |
| 39 | } |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame^] | 40 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 41 | LOG(INFO, "Waiting for auto to start back up.\n"); |
| 42 | } |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame^] | 43 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 44 | ::aos::Cleanup(); |
| 45 | return 0; |
| 46 | } |