Yash Chainani | 4b91ff1 | 2023-03-14 19:56:07 -0700 | [diff] [blame] | 1 | #include <sys/resource.h> |
| 2 | #include <sys/time.h> |
| 3 | |
| 4 | #include "aos/configuration.h" |
| 5 | #include "aos/init.h" |
| 6 | #include "aos/events/shm_event_loop.h" |
| 7 | #include "aos/flatbuffer_merge.h" |
| 8 | #include "aos/init.h" |
| 9 | #include "frc971/input/joystick_state_generated.h" |
| 10 | #include "glog/logging.h" |
| 11 | |
| 12 | DEFINE_string(config, "aos_config.json", "Config file to use."); |
| 13 | |
| 14 | int main(int argc, char *argv[]) { |
| 15 | aos::InitGoogle(&argc, &argv); |
| 16 | |
| 17 | aos::FlatbufferDetachedBuffer<aos::Configuration> config = |
| 18 | aos::configuration::ReadConfig(FLAGS_config); |
| 19 | aos::ShmEventLoop event_loop(&config.message()); |
| 20 | |
| 21 | aos::Sender<aos::JoystickState> sender( |
| 22 | event_loop.MakeSender<aos::JoystickState>("/imu/aos")); |
| 23 | |
| 24 | event_loop.MakeWatcher( |
| 25 | "/roborio/aos", [&](const aos::JoystickState &joystick_state) { |
| 26 | auto builder = sender.MakeBuilder(); |
| 27 | flatbuffers::Offset<aos::JoystickState> state_fbs = |
| 28 | aos::CopyFlatBuffer(&joystick_state, builder.fbb()); |
| 29 | builder.CheckOk(builder.Send(state_fbs)); |
| 30 | }); |
| 31 | |
| 32 | event_loop.Run(); |
| 33 | return 0; |
| 34 | } |