Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 1 | #include <unistd.h> |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 2 | |
Tyler Chatow | bf0609c | 2021-07-31 16:13:27 -0700 | [diff] [blame] | 3 | #include <cmath> |
| 4 | #include <cstdio> |
| 5 | #include <cstring> |
| 6 | |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 7 | #include "aos/actions/actions.h" |
John Park | 398c74a | 2018-10-20 21:17:39 -0700 | [diff] [blame] | 8 | #include "aos/init.h" |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 9 | #include "aos/logging/logging.h" |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 10 | #include "aos/time/time.h" |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 11 | #include "aos/util/log_interval.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 12 | #include "frc971/autonomous/auto_generated.h" |
| 13 | #include "frc971/control_loops/drivetrain/drivetrain_goal_generated.h" |
| 14 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 15 | #include "frc971/input/action_joystick_input.h" |
| 16 | #include "frc971/input/driver_station_data.h" |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 17 | #include "y2016/actors/autonomous_actor.h" |
| 18 | #include "y2016/actors/superstructure_actor.h" |
| 19 | #include "y2016/actors/vision_align_actor.h" |
| 20 | #include "y2016/constants.h" |
| 21 | #include "y2016/control_loops/drivetrain/drivetrain_base.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 22 | #include "y2016/control_loops/shooter/shooter_goal_generated.h" |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 23 | #include "y2016/control_loops/superstructure/superstructure.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 24 | #include "y2016/control_loops/superstructure/superstructure_goal_generated.h" |
| 25 | #include "y2016/control_loops/superstructure/superstructure_status_generated.h" |
| 26 | #include "y2016/queues/ball_detector_generated.h" |
| 27 | #include "y2016/vision/vision_generated.h" |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 28 | |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 29 | using ::frc971::input::driver_station::ButtonLocation; |
| 30 | using ::frc971::input::driver_station::ControlBit; |
| 31 | using ::frc971::input::driver_station::JoystickAxis; |
| 32 | using ::frc971::input::driver_station::POVLocation; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 33 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 34 | namespace y2016::input::joysticks { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 35 | |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 36 | namespace { |
| 37 | |
| 38 | constexpr double kMaxIntakeAngleBeforeArmInterference = control_loops:: |
| 39 | superstructure::CollisionAvoidance::kMaxIntakeAngleBeforeArmInterference; |
| 40 | |
| 41 | } // namespace |
| 42 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 43 | const JoystickAxis kSteeringWheel(1, 1), kDriveThrottle(2, 2); |
Campbell Crowley | 5b27f02 | 2016-02-20 16:55:35 -0800 | [diff] [blame] | 44 | const ButtonLocation kShiftHigh(2, 3), kShiftHigh2(2, 2), kShiftLow(2, 1); |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 45 | const ButtonLocation kQuickTurn(1, 5); |
| 46 | |
Austin Schuh | 781cdcc | 2016-03-12 13:03:12 -0800 | [diff] [blame] | 47 | const ButtonLocation kTurn1(1, 7); |
| 48 | const ButtonLocation kTurn2(1, 11); |
| 49 | |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 50 | // Buttons on the lexan driver station to get things running on bring-up day. |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 51 | const ButtonLocation kIntakeDown(3, 11); |
| 52 | const POVLocation kFrontLong(3, 180); |
| 53 | const POVLocation kBackLong(3, 0); |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 54 | const POVLocation kBackFender(3, 90); |
| 55 | const POVLocation kFrontFender(3, 270); |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 56 | const ButtonLocation kIntakeIn(3, 12); |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 57 | const ButtonLocation kFire(3, 3); |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 58 | const ButtonLocation kIntakeOut(3, 9); |
Austin Schuh | 843412b | 2016-03-20 16:48:46 -0700 | [diff] [blame] | 59 | const ButtonLocation kPortcullis(3, 7); |
| 60 | const ButtonLocation kChevalDeFrise(3, 8); |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 61 | |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 62 | const ButtonLocation kVisionAlign(3, 4); |
Austin Schuh | 1879911 | 2016-03-16 22:09:54 -0700 | [diff] [blame] | 63 | |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 64 | const ButtonLocation kExpand(3, 6); |
| 65 | const ButtonLocation kWinch(3, 5); |
| 66 | |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 67 | class Reader : public ::frc971::input::ActionJoystickInput { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 68 | public: |
Austin Schuh | 3e45c75 | 2019-02-02 12:19:11 -0800 | [diff] [blame] | 69 | Reader(::aos::EventLoop *event_loop) |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 70 | : ::frc971::input::ActionJoystickInput( |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 71 | event_loop, control_loops::drivetrain::GetDrivetrainConfig(), |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 72 | ::frc971::input::DrivetrainInputReader::InputType::kSteeringWheel, |
| 73 | {}), |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 74 | vision_status_fetcher_( |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 75 | event_loop->MakeFetcher<::y2016::vision::VisionStatus>("/vision")), |
Austin Schuh | 4b652c9 | 2019-05-27 13:22:27 -0700 | [diff] [blame] | 76 | ball_detector_fetcher_( |
| 77 | event_loop->MakeFetcher<::y2016::sensors::BallDetector>( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 78 | "/superstructure")), |
Austin Schuh | ae023fb | 2019-06-29 17:11:45 -0700 | [diff] [blame] | 79 | shooter_goal_sender_( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 80 | event_loop->MakeSender<::y2016::control_loops::shooter::Goal>( |
| 81 | "/shooter")), |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 82 | superstructure_status_fetcher_( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 83 | event_loop |
| 84 | ->MakeFetcher<::y2016::control_loops::superstructure::Status>( |
| 85 | "/superstructure")), |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 86 | superstructure_goal_sender_( |
| 87 | event_loop |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 88 | ->MakeSender<::y2016::control_loops::superstructure::Goal>( |
| 89 | "/superstructure")), |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 90 | drivetrain_goal_fetcher_( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 91 | event_loop->MakeFetcher<::frc971::control_loops::drivetrain::Goal>( |
| 92 | "/drivetrain")), |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 93 | drivetrain_status_fetcher_( |
| 94 | event_loop |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 95 | ->MakeFetcher<::frc971::control_loops::drivetrain::Status>( |
| 96 | "/drivetrain")), |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 97 | intake_goal_(0.0), |
| 98 | shoulder_goal_(M_PI / 2.0), |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 99 | wrist_goal_(0.0), |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 100 | vision_align_action_factory_( |
| 101 | actors::VisionAlignActor::MakeFactory(event_loop)), |
| 102 | superstructure_action_factory_( |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 103 | actors::SuperstructureActor::MakeFactory(event_loop)) { |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 104 | set_vision_align_fn( |
| 105 | [this](const ::frc971::input::driver_station::Data &data) { |
| 106 | return VisionAlign(data); |
| 107 | }); |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 108 | } |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 109 | |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 110 | // Returns true when we are vision aligning |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 111 | bool VisionAlign(const ::frc971::input::driver_station::Data &data) { |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 112 | vision_valid_ = false; |
| 113 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 114 | vision_status_fetcher_.Fetch(); |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 115 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 116 | if (vision_status_fetcher_.get()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 117 | vision_valid_ = (vision_status_fetcher_->left_image_valid() && |
| 118 | vision_status_fetcher_->right_image_valid()); |
| 119 | last_angle_ = vision_status_fetcher_->horizontal_angle(); |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Austin Schuh | 974cf65 | 2016-04-20 20:18:13 -0700 | [diff] [blame] | 122 | if (data.IsPressed(kVisionAlign)) { |
| 123 | if (vision_valid_ && !vision_action_running_) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 124 | actors::vision_align_action::VisionAlignActionParamsT params; |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 125 | EnqueueAction(vision_align_action_factory_.Make(params)); |
Austin Schuh | 974cf65 | 2016-04-20 20:18:13 -0700 | [diff] [blame] | 126 | vision_action_running_ = true; |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 127 | AOS_LOG(INFO, "Starting vision align\n"); |
Austin Schuh | 974cf65 | 2016-04-20 20:18:13 -0700 | [diff] [blame] | 128 | } else { |
| 129 | if (!vision_valid_) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 130 | AOS_LOG(INFO, "Vision align but not valid\n"); |
Austin Schuh | 974cf65 | 2016-04-20 20:18:13 -0700 | [diff] [blame] | 131 | } |
| 132 | } |
Austin Schuh | 1879911 | 2016-03-16 22:09:54 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | if (data.NegEdge(kVisionAlign)) { |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 136 | CancelAllActions(); |
Austin Schuh | 1879911 | 2016-03-16 22:09:54 -0700 | [diff] [blame] | 137 | } |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 138 | if (!data.IsPressed(kVisionAlign)) { |
| 139 | vision_action_running_ = false; |
| 140 | } |
Austin Schuh | 1879911 | 2016-03-16 22:09:54 -0700 | [diff] [blame] | 141 | |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 142 | return vision_action_running_; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 143 | } |
| 144 | |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 145 | void HandleTeleop(const ::frc971::input::driver_station::Data &data) { |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 146 | if (!data.GetControlBit(ControlBit::kEnabled)) { |
| 147 | // If we are not enabled, reset the waiting for zero bit. |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 148 | AOS_LOG(DEBUG, "Waiting for zero.\n"); |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 149 | waiting_for_zero_ = true; |
| 150 | } |
| 151 | |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 152 | float voltage_climber = 0.0; |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 153 | // Default the intake to up. |
| 154 | intake_goal_ = constants::Values::kIntakeRange.upper - 0.04; |
| 155 | |
| 156 | bool force_lights_on = false; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 157 | if (!data.GetControlBit(ControlBit::kEnabled)) { |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 158 | CancelAllActions(); |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 159 | AOS_LOG(DEBUG, "Canceling\n"); |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 160 | } |
| 161 | |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 162 | superstructure_status_fetcher_.Fetch(); |
| 163 | if (!superstructure_status_fetcher_.get()) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 164 | AOS_LOG(ERROR, "Got no superstructure status packet.\n"); |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 167 | if (superstructure_status_fetcher_.get() && |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 168 | superstructure_status_fetcher_->zeroed()) { |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 169 | if (waiting_for_zero_) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 170 | AOS_LOG(DEBUG, "Zeroed! Starting teleop mode.\n"); |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 171 | waiting_for_zero_ = false; |
| 172 | } |
| 173 | } else { |
| 174 | waiting_for_zero_ = true; |
| 175 | } |
| 176 | |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 177 | double intake_when_shooting = kMaxIntakeAngleBeforeArmInterference; |
| 178 | bool use_slow_profile = false; |
| 179 | if (vision_action_running_) { |
| 180 | use_slow_profile = true; |
| 181 | if (vision_valid_) { |
| 182 | intake_when_shooting -= 0.5; |
| 183 | } |
| 184 | } |
| 185 | |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 186 | if (data.IsPressed(kFrontLong)) { |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 187 | // Forwards shot |
Austin Schuh | 3d79cc0 | 2016-03-20 21:08:53 -0700 | [diff] [blame] | 188 | shoulder_goal_ = M_PI / 2.0 + 0.1; |
Austin Schuh | 6a871ff | 2016-05-01 12:31:23 -0700 | [diff] [blame] | 189 | wrist_goal_ = M_PI + 0.41 + 0.02 - 0.005; |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 190 | drivetrain_status_fetcher_.Fetch(); |
| 191 | if (drivetrain_status_fetcher_.get()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 192 | wrist_goal_ += drivetrain_status_fetcher_->ground_angle(); |
Austin Schuh | b009964 | 2016-04-03 21:37:27 -0700 | [diff] [blame] | 193 | } |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 194 | shooter_velocity_ = 640.0; |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 195 | intake_goal_ = intake_when_shooting; |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 196 | } else if (data.IsPressed(kBackLong)) { |
| 197 | // Backwards shot |
Austin Schuh | 3d79cc0 | 2016-03-20 21:08:53 -0700 | [diff] [blame] | 198 | shoulder_goal_ = M_PI / 2.0 - 0.4; |
Austin Schuh | e153c5a | 2016-04-20 20:18:42 -0700 | [diff] [blame] | 199 | wrist_goal_ = -0.62 - 0.02; |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 200 | drivetrain_status_fetcher_.Fetch(); |
| 201 | if (drivetrain_status_fetcher_.get()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 202 | wrist_goal_ += drivetrain_status_fetcher_->ground_angle(); |
Austin Schuh | b009964 | 2016-04-03 21:37:27 -0700 | [diff] [blame] | 203 | } |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 204 | shooter_velocity_ = 640.0; |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 205 | intake_goal_ = intake_when_shooting; |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 206 | } else if (data.IsPressed(kBackFender)) { |
Adam Snaider | a3271fe | 2016-10-26 21:03:38 -0700 | [diff] [blame] | 207 | // Backwards shot no IMU |
| 208 | shoulder_goal_ = M_PI / 2.0 - 0.4; |
| 209 | wrist_goal_ = -0.62 - 0.02; |
| 210 | shooter_velocity_ = 640.0; |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 211 | intake_goal_ = intake_when_shooting; |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 212 | } else if (data.IsPressed(kFrontFender)) { |
Adam Snaider | a3271fe | 2016-10-26 21:03:38 -0700 | [diff] [blame] | 213 | // Forwards shot no IMU |
Austin Schuh | 6a871ff | 2016-05-01 12:31:23 -0700 | [diff] [blame] | 214 | shoulder_goal_ = M_PI / 2.0 + 0.1; |
Adam Snaider | a3271fe | 2016-10-26 21:03:38 -0700 | [diff] [blame] | 215 | wrist_goal_ = M_PI + 0.41 + 0.02 - 0.005; |
Austin Schuh | 6a871ff | 2016-05-01 12:31:23 -0700 | [diff] [blame] | 216 | shooter_velocity_ = 640.0; |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 217 | intake_goal_ = intake_when_shooting; |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 218 | } else if (data.IsPressed(kExpand) || data.IsPressed(kWinch)) { |
| 219 | // Set the goals to the hanging position so when the actor finishes, we |
| 220 | // will still be at the right spot. |
| 221 | shoulder_goal_ = 1.2; |
Austin Schuh | fef64ac | 2016-04-24 19:08:01 -0700 | [diff] [blame] | 222 | wrist_goal_ = 1.0; |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 223 | intake_goal_ = 0.0; |
| 224 | if (data.PosEdge(kExpand)) { |
| 225 | is_expanding_ = true; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 226 | actors::superstructure_action::SuperstructureActionParamsT params; |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 227 | params.partial_angle = 0.3; |
| 228 | params.delay_time = 0.7; |
| 229 | params.full_angle = shoulder_goal_; |
Austin Schuh | fef64ac | 2016-04-24 19:08:01 -0700 | [diff] [blame] | 230 | params.shooter_angle = wrist_goal_; |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 231 | EnqueueAction(superstructure_action_factory_.Make(params)); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 232 | } |
| 233 | if (data.IsPressed(kWinch)) { |
| 234 | voltage_climber = 12.0; |
| 235 | } |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 236 | } else { |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 237 | wrist_goal_ = 0.0; |
Austin Schuh | 3f0b119 | 2016-03-12 13:03:56 -0800 | [diff] [blame] | 238 | shoulder_goal_ = -0.010; |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 239 | shooter_velocity_ = 0.0; |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 240 | } |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 241 | if (data.NegEdge(kExpand) || voltage_climber > 1.0) { |
| 242 | is_expanding_ = false; |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 243 | CancelAllActions(); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 244 | } |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 245 | |
Comran Morshed | aa0573c | 2016-03-05 19:05:54 +0000 | [diff] [blame] | 246 | bool ball_detected = false; |
Austin Schuh | 4b652c9 | 2019-05-27 13:22:27 -0700 | [diff] [blame] | 247 | ball_detector_fetcher_.Fetch(); |
| 248 | if (ball_detector_fetcher_.get()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 249 | ball_detected = ball_detector_fetcher_->voltage() > 2.5; |
Comran Morshed | aa0573c | 2016-03-05 19:05:54 +0000 | [diff] [blame] | 250 | } |
| 251 | if (data.PosEdge(kIntakeIn)) { |
| 252 | saw_ball_when_started_intaking_ = ball_detected; |
| 253 | } |
| 254 | |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 255 | if (data.IsPressed(kIntakeIn)) { |
| 256 | is_intaking_ = (!ball_detected || saw_ball_when_started_intaking_); |
| 257 | if (ball_detected) { |
| 258 | force_lights_on = true; |
| 259 | } |
| 260 | } else { |
| 261 | is_intaking_ = false; |
| 262 | } |
| 263 | |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 264 | fire_ = false; |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 265 | if (data.IsPressed(kFire) && shooter_velocity_ != 0.0) { |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 266 | if (data.IsPressed(kVisionAlign)) { |
| 267 | // Make sure that we are lined up. |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 268 | drivetrain_status_fetcher_.Fetch(); |
| 269 | drivetrain_goal_fetcher_.Fetch(); |
| 270 | if (drivetrain_status_fetcher_.get() && |
| 271 | drivetrain_goal_fetcher_.get()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 272 | const double left_goal = drivetrain_goal_fetcher_->left_goal(); |
| 273 | const double right_goal = drivetrain_goal_fetcher_->right_goal(); |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 274 | const double left_current = |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 275 | drivetrain_status_fetcher_->estimated_left_position(); |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 276 | const double right_current = |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 277 | drivetrain_status_fetcher_->estimated_right_position(); |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 278 | const double left_velocity = |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 279 | drivetrain_status_fetcher_->estimated_left_velocity(); |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 280 | const double right_velocity = |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 281 | drivetrain_status_fetcher_->estimated_right_velocity(); |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 282 | if (vision_action_running_ && ::std::abs(last_angle_) < 0.02 && |
| 283 | ::std::abs((left_goal - right_goal) - |
| 284 | (left_current - right_current)) / |
Austin Schuh | a250b2d | 2019-05-27 16:14:02 -0700 | [diff] [blame] | 285 | dt_config().robot_radius / 2.0 < |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 286 | 0.02 && |
| 287 | ::std::abs(left_velocity - right_velocity) < 0.01) { |
| 288 | ++ready_to_fire_; |
| 289 | } else { |
| 290 | ready_to_fire_ = 0; |
| 291 | } |
Austin Schuh | 3d79cc0 | 2016-03-20 21:08:53 -0700 | [diff] [blame] | 292 | if (ready_to_fire_ > 9) { |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 293 | fire_ = true; |
| 294 | } |
| 295 | } |
| 296 | } else { |
| 297 | fire_ = true; |
| 298 | } |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 299 | } |
| 300 | |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 301 | is_outtaking_ = data.IsPressed(kIntakeOut); |
Austin Schuh | 5a6db4d | 2016-02-28 22:02:42 -0800 | [diff] [blame] | 302 | |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 303 | if (is_intaking_ || is_outtaking_) { |
| 304 | recently_intaking_accumulator_ = 20; |
| 305 | } |
| 306 | |
| 307 | if (data.IsPressed(kIntakeDown)) { |
| 308 | if (recently_intaking_accumulator_) { |
| 309 | intake_goal_ = 0.1; |
| 310 | } else { |
| 311 | intake_goal_ = -0.05; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | if (recently_intaking_accumulator_ > 0) { |
| 316 | --recently_intaking_accumulator_; |
| 317 | } |
| 318 | |
Austin Schuh | 843412b | 2016-03-20 16:48:46 -0700 | [diff] [blame] | 319 | if (data.IsPressed(kPortcullis)) { |
| 320 | traverse_unlatched_ = true; |
| 321 | traverse_down_ = true; |
| 322 | } else if (data.IsPressed(kChevalDeFrise)) { |
| 323 | traverse_unlatched_ = false; |
| 324 | traverse_down_ = true; |
| 325 | } else { |
| 326 | traverse_unlatched_ = true; |
| 327 | traverse_down_ = false; |
| 328 | } |
| 329 | |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 330 | if (!waiting_for_zero_) { |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 331 | if (!is_expanding_) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 332 | auto builder = superstructure_goal_sender_.MakeBuilder(); |
Austin Schuh | 3f0b119 | 2016-03-12 13:03:56 -0800 | [diff] [blame] | 333 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 334 | ::y2016::control_loops::superstructure::Goal::Builder |
| 335 | superstructure_builder = builder.MakeBuilder< |
| 336 | ::y2016::control_loops::superstructure::Goal>(); |
| 337 | superstructure_builder.add_angle_intake(intake_goal_); |
| 338 | superstructure_builder.add_angle_shoulder(shoulder_goal_); |
| 339 | superstructure_builder.add_angle_wrist(wrist_goal_); |
| 340 | |
| 341 | superstructure_builder.add_max_angular_velocity_intake(7.0); |
| 342 | superstructure_builder.add_max_angular_velocity_shoulder(4.0); |
| 343 | superstructure_builder.add_max_angular_velocity_wrist(10.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 344 | if (use_slow_profile) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 345 | superstructure_builder.add_max_angular_acceleration_intake(10.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 346 | } else { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 347 | superstructure_builder.add_max_angular_acceleration_intake(40.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 348 | } |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 349 | superstructure_builder.add_max_angular_acceleration_shoulder(10.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 350 | if (shoulder_goal_ > 1.0) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 351 | superstructure_builder.add_max_angular_acceleration_wrist(45.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 352 | } else { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 353 | superstructure_builder.add_max_angular_acceleration_wrist(25.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 354 | } |
Austin Schuh | 3f0b119 | 2016-03-12 13:03:56 -0800 | [diff] [blame] | 355 | |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 356 | // Granny mode |
| 357 | /* |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 358 | superstructure_builder.add_max_angular_velocity_intake(0.2); |
| 359 | superstructure_builder.add_max_angular_velocity_shoulder(0.2); |
| 360 | superstructure_builder.add_max_angular_velocity_wrist(0.2); |
| 361 | superstructure_builder.add_max_angular_acceleration_intake(1.0); |
| 362 | superstructure_builder.add_max_angular_acceleration_shoulder(1.0); |
| 363 | superstructure_builder.add_max_angular_acceleration_wrist(1.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 364 | */ |
| 365 | if (is_intaking_) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 366 | superstructure_builder.add_voltage_top_rollers(12.0); |
| 367 | superstructure_builder.add_voltage_bottom_rollers(12.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 368 | } else if (is_outtaking_) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 369 | superstructure_builder.add_voltage_top_rollers(-12.0); |
| 370 | superstructure_builder.add_voltage_bottom_rollers(-7.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 371 | } else { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 372 | superstructure_builder.add_voltage_top_rollers(0.0); |
| 373 | superstructure_builder.add_voltage_bottom_rollers(0.0); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 374 | } |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 375 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 376 | superstructure_builder.add_traverse_unlatched(traverse_unlatched_); |
| 377 | superstructure_builder.add_unfold_climber(false); |
| 378 | superstructure_builder.add_voltage_climber(voltage_climber); |
| 379 | superstructure_builder.add_traverse_down(traverse_down_); |
| 380 | superstructure_builder.add_force_intake(true); |
Austin Schuh | 843412b | 2016-03-20 16:48:46 -0700 | [diff] [blame] | 381 | |
milind | 1f1dca3 | 2021-07-03 13:50:07 -0700 | [diff] [blame] | 382 | if (builder.Send(superstructure_builder.Finish()) != |
| 383 | aos::RawSender::Error::kOk) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 384 | AOS_LOG(ERROR, "Sending superstructure goal failed.\n"); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 385 | } else { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 386 | AOS_LOG(DEBUG, "sending goals: intake: %f, shoulder: %f, wrist: %f\n", |
| 387 | intake_goal_, shoulder_goal_, wrist_goal_); |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 388 | } |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 389 | } |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 390 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 391 | { |
| 392 | auto builder = shooter_goal_sender_.MakeBuilder(); |
| 393 | y2016::control_loops::shooter::Goal::Builder shooter_builder = |
| 394 | builder.MakeBuilder<y2016::control_loops::shooter::Goal>(); |
| 395 | shooter_builder.add_angular_velocity(shooter_velocity_); |
| 396 | shooter_builder.add_clamp_open(is_intaking_ || is_outtaking_); |
| 397 | shooter_builder.add_push_to_shooter(fire_); |
| 398 | shooter_builder.add_force_lights_on(force_lights_on); |
| 399 | shooter_builder.add_shooting_forwards(wrist_goal_ > 0); |
Austin Schuh | ae023fb | 2019-06-29 17:11:45 -0700 | [diff] [blame] | 400 | |
milind | 1f1dca3 | 2021-07-03 13:50:07 -0700 | [diff] [blame] | 401 | if (builder.Send(shooter_builder.Finish()) != |
| 402 | aos::RawSender::Error::kOk) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 403 | AOS_LOG(ERROR, "Sending shooter goal failed.\n"); |
| 404 | } |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 405 | } |
| 406 | } |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 409 | private: |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 410 | ::aos::Fetcher<::y2016::vision::VisionStatus> vision_status_fetcher_; |
Austin Schuh | 4b652c9 | 2019-05-27 13:22:27 -0700 | [diff] [blame] | 411 | ::aos::Fetcher<::y2016::sensors::BallDetector> ball_detector_fetcher_; |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 412 | ::aos::Sender<::y2016::control_loops::shooter::Goal> shooter_goal_sender_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 413 | ::aos::Fetcher<::y2016::control_loops::superstructure::Status> |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 414 | superstructure_status_fetcher_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 415 | ::aos::Sender<::y2016::control_loops::superstructure::Goal> |
Austin Schuh | 9481d0d | 2019-06-29 21:56:17 -0700 | [diff] [blame] | 416 | superstructure_goal_sender_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 417 | ::aos::Fetcher<::frc971::control_loops::drivetrain::Goal> |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 418 | drivetrain_goal_fetcher_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 419 | ::aos::Fetcher<::frc971::control_loops::drivetrain::Status> |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 420 | drivetrain_status_fetcher_; |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 421 | |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 422 | // Whatever these are set to are our default goals to send out after zeroing. |
| 423 | double intake_goal_; |
| 424 | double shoulder_goal_; |
| 425 | double wrist_goal_; |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 426 | double shooter_velocity_ = 0.0; |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 427 | |
Austin Schuh | 843412b | 2016-03-20 16:48:46 -0700 | [diff] [blame] | 428 | bool traverse_unlatched_ = false; |
| 429 | bool traverse_down_ = false; |
| 430 | |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 431 | // If we're waiting for the subsystems to zero. |
| 432 | bool waiting_for_zero_ = true; |
| 433 | |
Comran Morshed | aa0573c | 2016-03-05 19:05:54 +0000 | [diff] [blame] | 434 | // If true, the ball was present when the intaking button was pressed. |
| 435 | bool saw_ball_when_started_intaking_ = false; |
| 436 | |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 437 | bool is_intaking_ = false; |
Austin Schuh | 5a6db4d | 2016-02-28 22:02:42 -0800 | [diff] [blame] | 438 | bool is_outtaking_ = false; |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 439 | bool fire_ = false; |
| 440 | |
Austin Schuh | add6d79 | 2016-03-19 01:20:01 -0700 | [diff] [blame] | 441 | bool vision_action_running_ = false; |
| 442 | bool vision_valid_ = false; |
| 443 | |
Austin Schuh | d52df77 | 2016-03-19 15:38:41 -0700 | [diff] [blame] | 444 | int recently_intaking_accumulator_ = 0; |
| 445 | double last_angle_ = 100; |
| 446 | |
| 447 | int ready_to_fire_ = 0; |
| 448 | |
Diana Vandenberg | 9cc9ab6 | 2016-04-20 21:27:47 -0700 | [diff] [blame] | 449 | bool is_expanding_ = false; |
| 450 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 451 | actors::VisionAlignActor::Factory vision_align_action_factory_; |
| 452 | actors::SuperstructureActor::Factory superstructure_action_factory_; |
| 453 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 454 | ::aos::util::SimpleLogInterval no_drivetrain_status_ = |
Austin Schuh | 61bdc60 | 2016-12-04 19:10:10 -0800 | [diff] [blame] | 455 | ::aos::util::SimpleLogInterval(::std::chrono::milliseconds(200), WARNING, |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 456 | "no drivetrain status"); |
| 457 | }; |
| 458 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 459 | } // namespace y2016::input::joysticks |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 460 | |
Austin Schuh | 094d09b | 2020-11-20 23:26:52 -0800 | [diff] [blame] | 461 | int main(int argc, char **argv) { |
| 462 | ::aos::InitGoogle(&argc, &argv); |
Austin Schuh | 9fe68f7 | 2019-08-10 19:32:03 -0700 | [diff] [blame] | 463 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 464 | aos::FlatbufferDetachedBuffer<aos::Configuration> config = |
Austin Schuh | c5fa6d9 | 2022-02-25 14:36:28 -0800 | [diff] [blame] | 465 | aos::configuration::ReadConfig("aos_config.json"); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 466 | |
| 467 | ::aos::ShmEventLoop event_loop(&config.message()); |
Austin Schuh | 3e45c75 | 2019-02-02 12:19:11 -0800 | [diff] [blame] | 468 | ::y2016::input::joysticks::Reader reader(&event_loop); |
Austin Schuh | 9fe68f7 | 2019-08-10 19:32:03 -0700 | [diff] [blame] | 469 | |
| 470 | event_loop.Run(); |
| 471 | |
Austin Schuh | ae87e31 | 2020-08-01 16:15:01 -0700 | [diff] [blame] | 472 | return 0; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 473 | } |