Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame^] | 1 | #include "absl/flags/flag.h" |
| 2 | |
Ravago Jones | b84f206 | 2023-01-29 13:46:59 -0800 | [diff] [blame] | 3 | #include "aos/events/shm_event_loop.h" |
| 4 | #include "aos/init.h" |
James Kuszmaul | d67f6d2 | 2023-02-05 17:37:25 -0800 | [diff] [blame] | 5 | #include "frc971/constants/constants_sender_lib.h" |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 6 | #include "y2023/vision/aprilrobotics.h" |
Ravago Jones | b84f206 | 2023-01-29 13:46:59 -0800 | [diff] [blame] | 7 | |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame^] | 8 | ABSL_FLAG(std::string, config, "aos_config.json", |
| 9 | "Path to the config file to use."); |
Ravago Jones | b84f206 | 2023-01-29 13:46:59 -0800 | [diff] [blame] | 10 | |
| 11 | namespace y2023::vision { |
| 12 | void AprilViewerMain() { |
| 13 | aos::FlatbufferDetachedBuffer<aos::Configuration> config = |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame^] | 14 | aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config)); |
Ravago Jones | b84f206 | 2023-01-29 13:46:59 -0800 | [diff] [blame] | 15 | |
James Kuszmaul | d67f6d2 | 2023-02-05 17:37:25 -0800 | [diff] [blame] | 16 | frc971::constants::WaitForConstants<Constants>(&config.message()); |
| 17 | |
Ravago Jones | b84f206 | 2023-01-29 13:46:59 -0800 | [diff] [blame] | 18 | aos::ShmEventLoop event_loop(&config.message()); |
| 19 | |
| 20 | AprilRoboticsDetector detector(&event_loop, "/camera"); |
| 21 | |
| 22 | detector.SetWorkerpoolAffinities(); |
| 23 | |
| 24 | event_loop.SetRuntimeAffinity(aos::MakeCpusetFromCpus({5})); |
| 25 | |
| 26 | struct sched_param param; |
| 27 | param.sched_priority = 21; |
| 28 | PCHECK(sched_setscheduler(0, SCHED_FIFO, ¶m) == 0); |
| 29 | |
| 30 | event_loop.Run(); |
| 31 | } |
| 32 | |
| 33 | } // namespace y2023::vision |
| 34 | |
| 35 | int main(int argc, char **argv) { |
| 36 | aos::InitGoogle(&argc, &argv); |
| 37 | y2023::vision::AprilViewerMain(); |
| 38 | |
| 39 | return 0; |
| 40 | } |