Comran Morshed | e9b1292 | 2015-11-04 19:46:48 +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" |
Comran Morshed | 41ed7c2 | 2015-11-04 21:03:37 +0000 | [diff] [blame] | 6 | #include "y2014_bot3/autonomous/auto.q.h" |
| 7 | #include "y2014_bot3/autonomous/auto.h" |
Comran Morshed | e9b1292 | 2015-11-04 19:46:48 +0000 | [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); |
Comran Morshed | e9b1292 | 2015-11-04 19:46:48 +0000 | [diff] [blame] | 13 | |
Comran Morshed | 41ed7c2 | 2015-11-04 21:03:37 +0000 | [diff] [blame] | 14 | LOG(INFO, "Auto main started.\n"); |
| 15 | ::y2014_bot3::autonomous::autonomous.FetchLatest(); |
| 16 | while (!::y2014_bot3::autonomous::autonomous.get()) { |
| 17 | ::y2014_bot3::autonomous::autonomous.FetchNextBlocking(); |
Comran Morshed | e9b1292 | 2015-11-04 19:46:48 +0000 | [diff] [blame] | 18 | LOG(INFO, "Got another auto packet\n"); |
| 19 | } |
| 20 | |
| 21 | while (true) { |
Comran Morshed | 41ed7c2 | 2015-11-04 21:03:37 +0000 | [diff] [blame] | 22 | while (!::y2014_bot3::autonomous::autonomous->run_auto) { |
| 23 | ::y2014_bot3::autonomous::autonomous.FetchNextBlocking(); |
Comran Morshed | e9b1292 | 2015-11-04 19:46:48 +0000 | [diff] [blame] | 24 | LOG(INFO, "Got another auto packet\n"); |
| 25 | } |
| 26 | LOG(INFO, "Starting auto mode\n"); |
| 27 | ::aos::time::Time start_time = ::aos::time::Time::Now(); |
Comran Morshed | 41ed7c2 | 2015-11-04 21:03:37 +0000 | [diff] [blame] | 28 | ::y2014_bot3::autonomous::HandleAuto(); |
Comran Morshed | e9b1292 | 2015-11-04 19:46:48 +0000 | [diff] [blame] | 29 | |
| 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()); |
Comran Morshed | 41ed7c2 | 2015-11-04 21:03:37 +0000 | [diff] [blame] | 33 | while (::y2014_bot3::autonomous::autonomous->run_auto) { |
| 34 | ::y2014_bot3::autonomous::autonomous.FetchNextBlocking(); |
Comran Morshed | e9b1292 | 2015-11-04 19:46:48 +0000 | [diff] [blame] | 35 | LOG(INFO, "Got another auto packet\n"); |
| 36 | } |
| 37 | LOG(INFO, "Waiting for auto to start back up.\n"); |
| 38 | } |
| 39 | ::aos::Cleanup(); |
| 40 | return 0; |
| 41 | } |
| 42 | |