Henry Speiser | 0b9b005 | 2022-03-02 23:07:40 -0800 | [diff] [blame^] | 1 | #include "aos/events/shm_event_loop.h" |
| 2 | #include "aos/init.h" |
| 3 | #include "gflags/gflags.h" |
| 4 | #include "glog/logging.h" |
| 5 | #include "y2022/constants.h" |
| 6 | #include "y2022/setpoint_generated.h" |
| 7 | |
| 8 | DEFINE_double(catapult_position, |
| 9 | y2022::constants::Values::kDefaultCatapultShotPosition(), |
| 10 | "Catapult shot position"); |
| 11 | DEFINE_double(catapult_velocity, |
| 12 | y2022::constants::Values::kDefaultCatapultShotVelocity(), |
| 13 | "Catapult shot velocity"); |
| 14 | DEFINE_double(turret, 0.0, "Turret setpoint"); |
| 15 | |
| 16 | using y2022::input::joysticks::Setpoint; |
| 17 | |
| 18 | int main(int argc, char **argv) { |
| 19 | aos::InitGoogle(&argc, &argv); |
| 20 | |
| 21 | aos::FlatbufferDetachedBuffer<aos::Configuration> config = |
| 22 | aos::configuration::ReadConfig("config.json"); |
| 23 | |
| 24 | aos::ShmEventLoop event_loop(&config.message()); |
| 25 | |
| 26 | auto setpoint_sender = event_loop.MakeSender<Setpoint>("/superstructure"); |
| 27 | |
| 28 | aos::Sender<Setpoint>::Builder builder = setpoint_sender.MakeBuilder(); |
| 29 | |
| 30 | Setpoint::Builder setpoint_builder = builder.MakeBuilder<Setpoint>(); |
| 31 | |
| 32 | setpoint_builder.add_catapult_position(FLAGS_catapult_position); |
| 33 | setpoint_builder.add_catapult_velocity(FLAGS_catapult_velocity); |
| 34 | setpoint_builder.add_turret(FLAGS_turret); |
| 35 | builder.CheckOk(builder.Send(setpoint_builder.Finish())); |
| 36 | |
| 37 | return 0; |
| 38 | } |