Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 1 | #include "y2020/actors/autonomous_actor.h" |
| 2 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 3 | #include <chrono> |
Tyler Chatow | bf0609c | 2021-07-31 16:13:27 -0700 | [diff] [blame] | 4 | #include <cinttypes> |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 5 | #include <cmath> |
| 6 | |
| 7 | #include "aos/logging/logging.h" |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 8 | #include "aos/util/math.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 9 | #include "frc971/control_loops/drivetrain/localizer_generated.h" |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 10 | #include "y2020/actors/auto_splines.h" |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 11 | #include "y2020/control_loops/drivetrain/drivetrain_base.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 12 | |
Austin Schuh | 3fb9e42 | 2021-03-31 20:11:32 -0700 | [diff] [blame] | 13 | DEFINE_bool(spline_auto, false, "If true, define a spline autonomous mode"); |
Ravago Jones | 8c5737e | 2021-10-16 15:36:12 -0700 | [diff] [blame] | 14 | DEFINE_bool(target_aligned, false, |
Ravago Jones | a7b3c82 | 2021-08-26 12:36:03 -0700 | [diff] [blame] | 15 | "If true, run the Infinite Recharge autonomous that starts aligned " |
| 16 | "with the target"); |
Ravago Jones | 8c5737e | 2021-10-16 15:36:12 -0700 | [diff] [blame] | 17 | DEFINE_bool(target_offset, false, |
Ravago Jones | a7b3c82 | 2021-08-26 12:36:03 -0700 | [diff] [blame] | 18 | "If true, run the Infinite Recharge autonomous that starts offset " |
| 19 | "from the target"); |
| 20 | DEFINE_bool(just_shoot, false, |
| 21 | "If true, run the autonomous that just shoots balls."); |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 22 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 23 | namespace y2020 { |
| 24 | namespace actors { |
| 25 | |
| 26 | using ::aos::monotonic_clock; |
| 27 | using ::frc971::ProfileParametersT; |
| 28 | using frc971::control_loops::drivetrain::LocalizerControl; |
| 29 | namespace chrono = ::std::chrono; |
| 30 | |
| 31 | AutonomousActor::AutonomousActor(::aos::EventLoop *event_loop) |
| 32 | : frc971::autonomous::BaseAutonomousActor( |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 33 | event_loop, control_loops::drivetrain::GetDrivetrainConfig()), |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 34 | localizer_control_sender_( |
| 35 | event_loop->MakeSender< |
| 36 | ::frc971::control_loops::drivetrain::LocalizerControl>( |
| 37 | "/drivetrain")), |
Austin Schuh | 67e127e | 2021-03-27 13:25:23 -0700 | [diff] [blame] | 38 | superstructure_goal_sender_( |
| 39 | event_loop->MakeSender<control_loops::superstructure::Goal>( |
| 40 | "/superstructure")), |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 41 | joystick_state_fetcher_( |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 42 | event_loop->MakeFetcher<aos::JoystickState>("/aos")), |
Ravago Jones | 1f32d62 | 2021-08-26 12:20:36 -0700 | [diff] [blame] | 43 | superstructure_status_fetcher_( |
| 44 | event_loop->MakeFetcher<y2020::control_loops::superstructure::Status>( |
| 45 | "/superstructure")), |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 46 | auto_splines_() { |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 47 | set_max_drivetrain_voltage(2.0); |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 48 | replan_timer_ = event_loop->AddTimer([this]() { Replan(); }); |
| 49 | event_loop->OnRun([this, event_loop]() { |
| 50 | replan_timer_->Setup(event_loop->monotonic_now()); |
| 51 | }); |
| 52 | } |
| 53 | |
| 54 | void AutonomousActor::Replan() { |
Ravago Jones | 8c5737e | 2021-10-16 15:36:12 -0700 | [diff] [blame] | 55 | if (FLAGS_spline_auto) { |
Tyler Chatow | bf0609c | 2021-07-31 16:13:27 -0700 | [diff] [blame] | 56 | test_spline_ = PlanSpline(std::bind(&AutonomousSplines::TestSpline, |
| 57 | &auto_splines_, std::placeholders::_1), |
| 58 | SplineDirection::kForward); |
Ravago Jones | 8c5737e | 2021-10-16 15:36:12 -0700 | [diff] [blame] | 59 | } else if (FLAGS_target_offset) { |
Ravago Jones | a7b3c82 | 2021-08-26 12:36:03 -0700 | [diff] [blame] | 60 | target_offset_splines_ = { |
| 61 | PlanSpline(std::bind(&AutonomousSplines::TargetOffset1, &auto_splines_, |
| 62 | std::placeholders::_1), |
| 63 | SplineDirection::kForward), |
| 64 | PlanSpline(std::bind(&AutonomousSplines::TargetOffset2, &auto_splines_, |
| 65 | std::placeholders::_1), |
| 66 | SplineDirection::kBackward)}; |
Ravago Jones | 8c5737e | 2021-10-16 15:36:12 -0700 | [diff] [blame] | 67 | } else if (FLAGS_target_aligned) { |
Ravago Jones | a7b3c82 | 2021-08-26 12:36:03 -0700 | [diff] [blame] | 68 | target_aligned_splines_ = { |
| 69 | PlanSpline(std::bind(&AutonomousSplines::TargetAligned1, &auto_splines_, |
| 70 | std::placeholders::_1), |
| 71 | SplineDirection::kForward), |
| 72 | PlanSpline(std::bind(&AutonomousSplines::TargetAligned2, &auto_splines_, |
| 73 | std::placeholders::_1), |
| 74 | SplineDirection::kBackward)}; |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 75 | } |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 76 | } |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 77 | |
| 78 | void AutonomousActor::Reset() { |
| 79 | InitializeEncoders(); |
| 80 | ResetDrivetrain(); |
milind upadhyay | b2e840a | 2021-03-27 13:54:49 -0700 | [diff] [blame] | 81 | RetractIntake(); |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 82 | |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 83 | joystick_state_fetcher_.Fetch(); |
| 84 | CHECK(joystick_state_fetcher_.get() != nullptr) |
| 85 | << "Expect at least one JoystickState message before running auto..."; |
| 86 | alliance_ = joystick_state_fetcher_->alliance(); |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | bool AutonomousActor::RunAction( |
Austin Schuh | 6fb0a6d | 2021-01-23 15:43:17 -0800 | [diff] [blame] | 90 | const ::frc971::autonomous::AutonomousActionParams *params) { |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 91 | Reset(); |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 92 | |
| 93 | // Queue up a replan to occur as soon as this action completes. |
| 94 | // TODO(james): Modify this so we don't replan during teleop. |
| 95 | replan_timer_->Setup(monotonic_now()); |
| 96 | |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 97 | AOS_LOG(INFO, "Params are %d\n", params->mode()); |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 98 | if (alliance_ == aos::Alliance::kInvalid) { |
| 99 | AOS_LOG(INFO, "Aborting autonomous due to invalid alliance selection."); |
| 100 | return false; |
| 101 | } |
Ravago Jones | 8c5737e | 2021-10-16 15:36:12 -0700 | [diff] [blame] | 102 | if (FLAGS_target_aligned) { |
Ravago Jones | a7b3c82 | 2021-08-26 12:36:03 -0700 | [diff] [blame] | 103 | TargetAligned(); |
Ravago Jones | 8c5737e | 2021-10-16 15:36:12 -0700 | [diff] [blame] | 104 | } else if (FLAGS_target_offset) { |
Ravago Jones | a7b3c82 | 2021-08-26 12:36:03 -0700 | [diff] [blame] | 105 | TargetOffset(); |
| 106 | } else if (FLAGS_just_shoot) { |
| 107 | JustShoot(); |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 108 | } else if (FLAGS_spline_auto) { |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 109 | SplineAuto(); |
| 110 | } else { |
| 111 | return DriveFwd(); |
| 112 | } |
| 113 | return true; |
| 114 | } |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 115 | |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 116 | void AutonomousActor::SendStartingPosition(const Eigen::Vector3d &start) { |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 117 | // Set up the starting position for the blue alliance. |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 118 | |
| 119 | // TODO(james): Resetting the localizer breaks the left/right statespace |
| 120 | // controller. That is a bug, but we can fix that later by not resetting. |
| 121 | auto builder = localizer_control_sender_.MakeBuilder(); |
| 122 | |
| 123 | LocalizerControl::Builder localizer_control_builder = |
| 124 | builder.MakeBuilder<LocalizerControl>(); |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 125 | localizer_control_builder.add_x(start(0)); |
| 126 | localizer_control_builder.add_y(start(1)); |
| 127 | localizer_control_builder.add_theta(start(2)); |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 128 | localizer_control_builder.add_theta_uncertainty(0.00001); |
| 129 | if (!builder.Send(localizer_control_builder.Finish())) { |
| 130 | AOS_LOG(ERROR, "Failed to reset localizer.\n"); |
| 131 | } |
| 132 | } |
| 133 | |
Ravago Jones | a7b3c82 | 2021-08-26 12:36:03 -0700 | [diff] [blame] | 134 | void AutonomousActor::TargetAligned() { |
| 135 | CHECK(target_aligned_splines_); |
| 136 | auto &splines = *target_aligned_splines_; |
| 137 | SendStartingPosition(splines[0].starting_position()); |
| 138 | |
| 139 | // shoot pre-loaded balls |
| 140 | set_shooter_tracking(true); |
| 141 | set_shooting(true); |
| 142 | SendSuperstructureGoal(); |
| 143 | |
| 144 | if (!WaitForBallsShot(3)) return; |
| 145 | |
| 146 | set_shooting(false); |
| 147 | SendSuperstructureGoal(); |
| 148 | |
| 149 | ExtendIntake(); |
| 150 | |
| 151 | // pickup 3 more balls |
| 152 | if (!splines[0].WaitForPlan()) return; |
| 153 | splines[0].Start(); |
| 154 | |
| 155 | if (!splines[0].WaitForSplineDistanceRemaining(0.02)) return; |
| 156 | RetractIntake(); |
| 157 | |
| 158 | if (!splines[1].WaitForPlan()) return; |
| 159 | splines[1].Start(); |
| 160 | |
| 161 | if (!splines[1].WaitForSplineDistanceRemaining(0.02)) return; |
| 162 | |
| 163 | // shoot the new balls in front of the goal. |
| 164 | set_shooting(true); |
| 165 | SendSuperstructureGoal(); |
| 166 | |
| 167 | if (!WaitForBallsShot(3)) return; |
| 168 | |
| 169 | set_shooting(false); |
| 170 | set_shooter_tracking(false); |
| 171 | SendSuperstructureGoal(); |
| 172 | } |
| 173 | |
| 174 | void AutonomousActor::JustShoot() { |
| 175 | // shoot pre-loaded balls |
| 176 | set_shooter_tracking(true); |
| 177 | set_shooting(true); |
| 178 | SendSuperstructureGoal(); |
| 179 | |
| 180 | if (!WaitForBallsShot(3)) return; |
| 181 | |
| 182 | set_shooting(false); |
| 183 | set_shooter_tracking(true); |
| 184 | SendSuperstructureGoal(); |
| 185 | } |
| 186 | |
| 187 | void AutonomousActor::TargetOffset() { |
| 188 | CHECK(target_offset_splines_); |
| 189 | auto &splines = *target_offset_splines_; |
| 190 | SendStartingPosition(splines[0].starting_position()); |
| 191 | |
| 192 | // spin up shooter |
| 193 | set_shooter_tracking(true); |
| 194 | SendSuperstructureGoal(); |
| 195 | ExtendIntake(); |
| 196 | |
| 197 | // pickup 2 more balls in front of the trench run |
| 198 | if (!splines[0].WaitForPlan()) return; |
| 199 | splines[0].Start(); |
| 200 | |
| 201 | if (!splines[0].WaitForSplineDistanceRemaining(0.02)) return; |
| 202 | RetractIntake(); |
| 203 | |
| 204 | if (!splines[1].WaitForPlan()) return; |
| 205 | splines[1].Start(); |
| 206 | |
| 207 | if (!splines[1].WaitForSplineDistanceRemaining(0.02)) return; |
| 208 | |
| 209 | // shoot the balls from in front of the goal. |
| 210 | set_shooting(true); |
| 211 | SendSuperstructureGoal(); |
| 212 | |
| 213 | if (!WaitForBallsShot(5)) return; |
| 214 | |
| 215 | set_shooting(false); |
| 216 | set_shooter_tracking(false); |
| 217 | SendSuperstructureGoal(); |
| 218 | } |
| 219 | |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 220 | void AutonomousActor::SplineAuto() { |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 221 | CHECK(test_spline_); |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 222 | |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 223 | SendStartingPosition(test_spline_->starting_position()); |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 224 | |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 225 | if (!test_spline_->WaitForPlan()) return; |
| 226 | test_spline_->Start(); |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 227 | |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 228 | if (!test_spline_->WaitForSplineDistanceRemaining(0.02)) return; |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 229 | } |
| 230 | |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 231 | ProfileParametersT MakeProfileParametersT(const float max_velocity, |
| 232 | const float max_acceleration) { |
| 233 | ProfileParametersT params; |
| 234 | params.max_velocity = max_velocity; |
| 235 | params.max_acceleration = max_acceleration; |
| 236 | return params; |
| 237 | } |
| 238 | |
| 239 | bool AutonomousActor::DriveFwd() { |
James Kuszmaul | 99af8b5 | 2021-03-28 10:50:15 -0700 | [diff] [blame] | 240 | SendStartingPosition({0, 0, 0}); |
Austin Schuh | fd1715f | 2021-01-30 16:58:24 -0800 | [diff] [blame] | 241 | const ProfileParametersT kDrive = MakeProfileParametersT(0.3f, 1.0f); |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 242 | const ProfileParametersT kTurn = MakeProfileParametersT(5.0f, 15.0f); |
Austin Schuh | fd1715f | 2021-01-30 16:58:24 -0800 | [diff] [blame] | 243 | StartDrive(1.0, 0.0, kDrive, kTurn); |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 244 | return WaitForDriveDone(); |
| 245 | } |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 246 | |
| 247 | void AutonomousActor::SendSuperstructureGoal() { |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 248 | auto builder = superstructure_goal_sender_.MakeBuilder(); |
| 249 | |
| 250 | flatbuffers::Offset<StaticZeroingSingleDOFProfiledSubsystemGoal> |
| 251 | intake_offset; |
milind upadhyay | b9dec71 | 2021-03-20 15:47:51 -0700 | [diff] [blame] | 252 | |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 253 | { |
| 254 | StaticZeroingSingleDOFProfiledSubsystemGoal::Builder intake_builder = |
| 255 | builder.MakeBuilder<StaticZeroingSingleDOFProfiledSubsystemGoal>(); |
| 256 | |
milind upadhyay | b9dec71 | 2021-03-20 15:47:51 -0700 | [diff] [blame] | 257 | frc971::ProfileParameters::Builder profile_params_builder = |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 258 | builder.MakeBuilder<frc971::ProfileParameters>(); |
Austin Schuh | b39a21c | 2021-03-31 20:12:18 -0700 | [diff] [blame] | 259 | profile_params_builder.add_max_velocity(20.0); |
| 260 | profile_params_builder.add_max_acceleration(60.0); |
milind upadhyay | b9dec71 | 2021-03-20 15:47:51 -0700 | [diff] [blame] | 261 | flatbuffers::Offset<frc971::ProfileParameters> profile_params_offset = |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 262 | profile_params_builder.Finish(); |
| 263 | intake_builder.add_unsafe_goal(intake_goal_); |
| 264 | intake_builder.add_profile_params(profile_params_offset); |
| 265 | intake_offset = intake_builder.Finish(); |
| 266 | } |
| 267 | |
| 268 | superstructure::Goal::Builder superstructure_builder = |
Tyler Chatow | bf0609c | 2021-07-31 16:13:27 -0700 | [diff] [blame] | 269 | builder.MakeBuilder<superstructure::Goal>(); |
milind upadhyay | b9dec71 | 2021-03-20 15:47:51 -0700 | [diff] [blame] | 270 | |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 271 | superstructure_builder.add_intake(intake_offset); |
Ravago Jones | f8b7bfe | 2021-10-09 16:25:29 -0700 | [diff] [blame] | 272 | superstructure_builder.add_intake_preloading(intake_preloading_); |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 273 | superstructure_builder.add_roller_voltage(roller_voltage_); |
Tyler Chatow | bf0609c | 2021-07-31 16:13:27 -0700 | [diff] [blame] | 274 | superstructure_builder.add_roller_speed_compensation( |
| 275 | kRollerSpeedCompensation); |
Ravago Jones | a7b3c82 | 2021-08-26 12:36:03 -0700 | [diff] [blame] | 276 | superstructure_builder.add_hood_tracking(shooter_tracking_); |
| 277 | superstructure_builder.add_turret_tracking(shooter_tracking_); |
| 278 | superstructure_builder.add_shooter_tracking(shooter_tracking_); |
| 279 | superstructure_builder.add_shooting(shooting_); |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 280 | |
| 281 | if (!builder.Send(superstructure_builder.Finish())) { |
| 282 | AOS_LOG(ERROR, "Sending superstructure goal failed.\n"); |
| 283 | } |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 284 | } |
milind upadhyay | 5e589d7 | 2021-03-27 13:47:18 -0700 | [diff] [blame] | 285 | |
Ravago Jones | a7b3c82 | 2021-08-26 12:36:03 -0700 | [diff] [blame] | 286 | void AutonomousActor::ExtendIntake() { |
| 287 | set_intake_goal(1.25); |
| 288 | set_roller_voltage(12.0); |
| 289 | set_intake_preloading(true); |
| 290 | SendSuperstructureGoal(); |
| 291 | } |
| 292 | |
milind upadhyay | 5e589d7 | 2021-03-27 13:47:18 -0700 | [diff] [blame] | 293 | void AutonomousActor::RetractIntake() { |
| 294 | set_intake_goal(-0.89); |
| 295 | set_roller_voltage(0.0); |
Ravago Jones | f8b7bfe | 2021-10-09 16:25:29 -0700 | [diff] [blame] | 296 | set_intake_preloading(false); |
milind upadhyay | 5e589d7 | 2021-03-27 13:47:18 -0700 | [diff] [blame] | 297 | SendSuperstructureGoal(); |
| 298 | } |
| 299 | |
Ravago Jones | 1f32d62 | 2021-08-26 12:20:36 -0700 | [diff] [blame] | 300 | bool AutonomousActor::WaitForBallsShot(int num_wanted) { |
| 301 | superstructure_status_fetcher_.Fetch(); |
| 302 | CHECK(superstructure_status_fetcher_.get() != nullptr); |
| 303 | const int initial_balls_shot = |
| 304 | superstructure_status_fetcher_->shooter()->balls_shot(); |
| 305 | int balls_shot = initial_balls_shot; |
| 306 | |
| 307 | ::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency, |
| 308 | event_loop()->monotonic_now(), |
| 309 | frc971::controls::kLoopFrequency / 2); |
| 310 | while (true) { |
| 311 | if (ShouldCancel()) { |
| 312 | return false; |
| 313 | } |
| 314 | phased_loop.SleepUntilNext(); |
| 315 | superstructure_status_fetcher_.Fetch(); |
| 316 | balls_shot = superstructure_status_fetcher_->shooter()->balls_shot(); |
| 317 | if ((balls_shot - initial_balls_shot) >= num_wanted) { |
| 318 | return true; |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 323 | } // namespace actors |
| 324 | } // namespace y2020 |