Austin Schuh | 8d5fff4 | 2018-05-30 20:44:12 -0700 | [diff] [blame] | 1 | #include <netdb.h> |
| 2 | |
Austin Schuh | 300f2f6 | 2019-05-27 13:49:23 -0700 | [diff] [blame^] | 3 | #include "aos/events/shm-event-loop.h" |
| 4 | #include "aos/init.h" |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 5 | #include "aos/logging/logging.h" |
| 6 | #include "aos/logging/queue_logging.h" |
| 7 | #include "aos/time/time.h" |
Austin Schuh | 8d5fff4 | 2018-05-30 20:44:12 -0700 | [diff] [blame] | 8 | #include "aos/vision/events/udp.h" |
| 9 | #include "y2018/vision.pb.h" |
| 10 | #include "y2018/vision/vision.q.h" |
| 11 | |
| 12 | namespace y2018 { |
| 13 | namespace vision { |
| 14 | |
| 15 | using aos::monotonic_clock; |
| 16 | |
| 17 | int Main() { |
| 18 | ::aos::events::RXUdpSocket video_rx(5001); |
| 19 | char data[65507]; |
| 20 | ::y2018::VisionStatus status; |
Austin Schuh | 300f2f6 | 2019-05-27 13:49:23 -0700 | [diff] [blame^] | 21 | ::aos::ShmEventLoop event_loop; |
| 22 | ::aos::Sender<::y2018::vision::VisionStatus> vision_status_sender_ = |
| 23 | event_loop.MakeSender<::y2018::vision::VisionStatus>( |
| 24 | ".y2018.vision.vision_status"); |
Austin Schuh | 8d5fff4 | 2018-05-30 20:44:12 -0700 | [diff] [blame] | 25 | |
| 26 | while (true) { |
| 27 | const ssize_t rx_size = video_rx.Recv(data, sizeof(data)); |
| 28 | if (rx_size > 0) { |
| 29 | status.ParseFromArray(data, rx_size); |
Austin Schuh | 300f2f6 | 2019-05-27 13:49:23 -0700 | [diff] [blame^] | 30 | auto new_vision_status = vision_status_sender_.MakeMessage(); |
Austin Schuh | 8d5fff4 | 2018-05-30 20:44:12 -0700 | [diff] [blame] | 31 | new_vision_status->high_frame_count = status.high_frame_count(); |
| 32 | new_vision_status->low_frame_count = status.low_frame_count(); |
| 33 | LOG_STRUCT(DEBUG, "vision", *new_vision_status); |
| 34 | if (!new_vision_status.Send()) { |
| 35 | LOG(ERROR, "Failed to send vision information\n"); |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | } // namespace vision |
| 42 | } // namespace y2018 |
| 43 | |
| 44 | int main(int /*argc*/, char ** /*argv*/) { |
| 45 | ::aos::InitNRT(); |
| 46 | ::y2018::vision::Main(); |
| 47 | } |