blob: 9ea6a1a4ba579bd85a7fd4d25a4e2d91ad9a3262 [file] [log] [blame]
Yash Chainani4b91ff12023-03-14 19:56:07 -07001#include <sys/resource.h>
2#include <sys/time.h>
3
Austin Schuh99f7c6a2024-06-25 22:07:44 -07004#include "absl/flags/flag.h"
Philipp Schrader790cb542023-07-05 21:06:52 -07005
Yash Chainani4b91ff12023-03-14 19:56:07 -07006#include "aos/configuration.h"
Yash Chainani4b91ff12023-03-14 19:56:07 -07007#include "aos/events/shm_event_loop.h"
8#include "aos/flatbuffer_merge.h"
9#include "aos/init.h"
10#include "frc971/input/joystick_state_generated.h"
Yash Chainani4b91ff12023-03-14 19:56:07 -070011
Austin Schuh99f7c6a2024-06-25 22:07:44 -070012ABSL_FLAG(std::string, config, "aos_config.json", "Config file to use.");
Yash Chainani4b91ff12023-03-14 19:56:07 -070013
14int main(int argc, char *argv[]) {
15 aos::InitGoogle(&argc, &argv);
16
17 aos::FlatbufferDetachedBuffer<aos::Configuration> config =
Austin Schuh99f7c6a2024-06-25 22:07:44 -070018 aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
Yash Chainani4b91ff12023-03-14 19:56:07 -070019 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}