Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 1 | #include "absl/flags/flag.h" |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 2 | |
| 3 | #include "aos/events/shm_event_loop.h" |
| 4 | #include "aos/init.h" |
Henry Speiser | 0b9b005 | 2022-03-02 23:07:40 -0800 | [diff] [blame] | 5 | #include "y2022/setpoint_generated.h" |
| 6 | |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 7 | ABSL_FLAG(double, catapult_position, 0.03, "Catapult shot position"); |
| 8 | ABSL_FLAG(double, catapult_velocity, 18.0, "Catapult shot velocity"); |
| 9 | ABSL_FLAG(double, turret, 0.0, "Turret setpoint"); |
Henry Speiser | 0b9b005 | 2022-03-02 23:07:40 -0800 | [diff] [blame] | 10 | |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 11 | ABSL_FLAG(std::string, config, "aos_config.json", |
| 12 | "Path to the config file to use."); |
James Kuszmaul | 1f6099e | 2022-03-12 18:25:59 -0800 | [diff] [blame] | 13 | |
Henry Speiser | 0b9b005 | 2022-03-02 23:07:40 -0800 | [diff] [blame] | 14 | using y2022::input::joysticks::Setpoint; |
| 15 | |
| 16 | int main(int argc, char **argv) { |
| 17 | aos::InitGoogle(&argc, &argv); |
| 18 | |
| 19 | aos::FlatbufferDetachedBuffer<aos::Configuration> config = |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 20 | aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config)); |
Henry Speiser | 0b9b005 | 2022-03-02 23:07:40 -0800 | [diff] [blame] | 21 | |
| 22 | aos::ShmEventLoop event_loop(&config.message()); |
| 23 | |
| 24 | auto setpoint_sender = event_loop.MakeSender<Setpoint>("/superstructure"); |
| 25 | |
| 26 | aos::Sender<Setpoint>::Builder builder = setpoint_sender.MakeBuilder(); |
| 27 | |
| 28 | Setpoint::Builder setpoint_builder = builder.MakeBuilder<Setpoint>(); |
| 29 | |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 30 | setpoint_builder.add_catapult_position( |
| 31 | absl::GetFlag(FLAGS_catapult_position)); |
| 32 | setpoint_builder.add_catapult_velocity( |
| 33 | absl::GetFlag(FLAGS_catapult_velocity)); |
| 34 | setpoint_builder.add_turret(absl::GetFlag(FLAGS_turret)); |
Henry Speiser | 0b9b005 | 2022-03-02 23:07:40 -0800 | [diff] [blame] | 35 | builder.CheckOk(builder.Send(setpoint_builder.Finish())); |
| 36 | |
| 37 | return 0; |
| 38 | } |