Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 1 | #include "y2020/actors/autonomous_actor.h" |
| 2 | |
| 3 | #include <inttypes.h> |
| 4 | |
| 5 | #include <chrono> |
| 6 | #include <cmath> |
| 7 | |
| 8 | #include "aos/logging/logging.h" |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 9 | #include "aos/util/math.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 10 | #include "frc971/control_loops/drivetrain/localizer_generated.h" |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 11 | #include "frc971/control_loops/drivetrain/spline.h" |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 12 | #include "y2020/actors/auto_splines.h" |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 13 | #include "y2020/control_loops/drivetrain/drivetrain_base.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 14 | |
Austin Schuh | fd1715f | 2021-01-30 16:58:24 -0800 | [diff] [blame] | 15 | DEFINE_bool(spline_auto, true, "If true, define a spline autonomous mode"); |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 16 | DEFINE_bool(galactic_search, false, |
| 17 | "If true, do the galactic search autonomous"); |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 18 | DEFINE_bool(bounce, false, "If true, run the AutoNav Bounce autonomous"); |
| 19 | DEFINE_bool(barrel, false, "If true, run the AutoNav Barrel autonomous"); |
| 20 | DEFINE_bool(slalom, false, "If true, run the AutoNav Slalom autonomous"); |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 21 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 22 | namespace y2020 { |
| 23 | namespace actors { |
| 24 | |
| 25 | using ::aos::monotonic_clock; |
| 26 | using ::frc971::ProfileParametersT; |
| 27 | using frc971::control_loops::drivetrain::LocalizerControl; |
| 28 | namespace chrono = ::std::chrono; |
| 29 | |
| 30 | AutonomousActor::AutonomousActor(::aos::EventLoop *event_loop) |
| 31 | : frc971::autonomous::BaseAutonomousActor( |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 32 | event_loop, control_loops::drivetrain::GetDrivetrainConfig()), |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 33 | localizer_control_sender_( |
| 34 | event_loop->MakeSender< |
| 35 | ::frc971::control_loops::drivetrain::LocalizerControl>( |
| 36 | "/drivetrain")), |
Austin Schuh | 67e127e | 2021-03-27 13:25:23 -0700 | [diff] [blame] | 37 | superstructure_goal_sender_( |
| 38 | event_loop->MakeSender<control_loops::superstructure::Goal>( |
| 39 | "/superstructure")), |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 40 | joystick_state_fetcher_( |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 41 | event_loop->MakeFetcher<aos::JoystickState>("/aos")), |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 42 | path_fetcher_(event_loop->MakeFetcher<y2020::vision::GalacticSearchPath>( |
Austin Schuh | c6442fc | 2021-03-27 13:25:42 -0700 | [diff] [blame] | 43 | "/pi2/camera")), |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 44 | auto_splines_() { |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 45 | set_max_drivetrain_voltage(2.0); |
| 46 | } |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 47 | |
| 48 | void AutonomousActor::Reset() { |
| 49 | InitializeEncoders(); |
| 50 | ResetDrivetrain(); |
milind upadhyay | b2e840a | 2021-03-27 13:54:49 -0700 | [diff] [blame] | 51 | RetractIntake(); |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 52 | |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 53 | joystick_state_fetcher_.Fetch(); |
| 54 | CHECK(joystick_state_fetcher_.get() != nullptr) |
| 55 | << "Expect at least one JoystickState message before running auto..."; |
| 56 | alliance_ = joystick_state_fetcher_->alliance(); |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | bool AutonomousActor::RunAction( |
Austin Schuh | 6fb0a6d | 2021-01-23 15:43:17 -0800 | [diff] [blame] | 60 | const ::frc971::autonomous::AutonomousActionParams *params) { |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 61 | Reset(); |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 62 | AOS_LOG(INFO, "Params are %d\n", params->mode()); |
James Kuszmaul | ddd2ba6 | 2020-03-08 22:17:13 -0700 | [diff] [blame] | 63 | if (alliance_ == aos::Alliance::kInvalid) { |
| 64 | AOS_LOG(INFO, "Aborting autonomous due to invalid alliance selection."); |
| 65 | return false; |
| 66 | } |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 67 | if (FLAGS_galactic_search) { |
| 68 | GalacticSearch(); |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 69 | } else if (FLAGS_bounce) { |
| 70 | AutoNavBounce(); |
| 71 | } else if (FLAGS_barrel) { |
| 72 | AutoNavBarrel(); |
| 73 | } else if (FLAGS_slalom) { |
| 74 | AutoNavSlalom(); |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 75 | } else if (FLAGS_spline_auto) { |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 76 | SplineAuto(); |
| 77 | } else { |
| 78 | return DriveFwd(); |
| 79 | } |
| 80 | return true; |
| 81 | } |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 82 | |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 83 | void AutonomousActor::SendStartingPosition(double x, double y, double theta) { |
| 84 | // Set up the starting position for the blue alliance. |
| 85 | double starting_heading = theta; |
| 86 | |
| 87 | // TODO(james): Resetting the localizer breaks the left/right statespace |
| 88 | // controller. That is a bug, but we can fix that later by not resetting. |
| 89 | auto builder = localizer_control_sender_.MakeBuilder(); |
| 90 | |
| 91 | LocalizerControl::Builder localizer_control_builder = |
| 92 | builder.MakeBuilder<LocalizerControl>(); |
| 93 | localizer_control_builder.add_x(x); |
| 94 | localizer_control_builder.add_y(y); |
| 95 | localizer_control_builder.add_theta(starting_heading); |
| 96 | localizer_control_builder.add_theta_uncertainty(0.00001); |
| 97 | if (!builder.Send(localizer_control_builder.Finish())) { |
| 98 | AOS_LOG(ERROR, "Failed to reset localizer.\n"); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | void AutonomousActor::GalacticSearch() { |
| 103 | path_fetcher_.Fetch(); |
| 104 | CHECK(path_fetcher_.get() != nullptr) |
| 105 | << "Expect at least one GalacticSearchPath message before running " |
| 106 | "auto..."; |
| 107 | if (path_fetcher_->alliance() == y2020::vision::Alliance::kUnknown) { |
| 108 | AOS_LOG(ERROR, "The galactic search path is unknown, doing nothing."); |
| 109 | } else { |
| 110 | SplineHandle spline1 = PlanSpline( |
James Kuszmaul | 75a18c5 | 2021-03-10 22:02:07 -0800 | [diff] [blame] | 111 | [this]( |
| 112 | aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder |
| 113 | *builder) { |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 114 | flatbuffers::Offset<frc971::MultiSpline> target_spline; |
| 115 | if (path_fetcher_->alliance() == y2020::vision::Alliance::kRed) { |
| 116 | if (path_fetcher_->letter() == y2020::vision::Letter::kA) { |
Austin Schuh | c8ba53a | 2021-03-27 13:26:04 -0700 | [diff] [blame] | 117 | LOG(INFO) << "Red A"; |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 118 | target_spline = auto_splines_.SplineRedA(builder); |
| 119 | } else { |
Austin Schuh | c8ba53a | 2021-03-27 13:26:04 -0700 | [diff] [blame] | 120 | LOG(INFO) << "Red B"; |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 121 | CHECK(path_fetcher_->letter() == y2020::vision::Letter::kB); |
| 122 | target_spline = auto_splines_.SplineRedB(builder); |
| 123 | } |
| 124 | } else { |
| 125 | if (path_fetcher_->letter() == y2020::vision::Letter::kA) { |
Austin Schuh | c8ba53a | 2021-03-27 13:26:04 -0700 | [diff] [blame] | 126 | LOG(INFO) << "Blue A"; |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 127 | target_spline = auto_splines_.SplineBlueA(builder); |
| 128 | } else { |
Austin Schuh | c8ba53a | 2021-03-27 13:26:04 -0700 | [diff] [blame] | 129 | LOG(INFO) << "Blue B"; |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 130 | CHECK(path_fetcher_->letter() == y2020::vision::Letter::kB); |
| 131 | target_spline = auto_splines_.SplineBlueB(builder); |
| 132 | } |
| 133 | } |
| 134 | const frc971::MultiSpline *const spline = |
| 135 | flatbuffers::GetTemporaryPointer(*builder->fbb(), target_spline); |
| 136 | |
| 137 | SendStartingPosition(CHECK_NOTNULL(spline)); |
| 138 | |
| 139 | return target_spline; |
| 140 | }, |
| 141 | SplineDirection::kForward); |
| 142 | |
milind upadhyay | b9dec71 | 2021-03-20 15:47:51 -0700 | [diff] [blame] | 143 | set_intake_goal(1.2); |
| 144 | set_roller_voltage(7.0); |
| 145 | SendSuperstructureGoal(); |
| 146 | |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 147 | if (!spline1.WaitForPlan()) return; |
| 148 | spline1.Start(); |
| 149 | |
| 150 | if (!spline1.WaitForSplineDistanceRemaining(0.02)) return; |
milind upadhyay | 5e589d7 | 2021-03-27 13:47:18 -0700 | [diff] [blame] | 151 | RetractIntake(); |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 152 | } |
| 153 | } |
| 154 | |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 155 | void AutonomousActor::AutoNavBounce() { |
| 156 | SplineHandle spline1 = PlanSpline( |
James Kuszmaul | 75a18c5 | 2021-03-10 22:02:07 -0800 | [diff] [blame] | 157 | [this](aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 158 | *builder) { |
| 159 | flatbuffers::Offset<frc971::MultiSpline> target_spline = |
| 160 | auto_splines_.AutoNavBounce1(builder); |
| 161 | const frc971::MultiSpline *const spline = |
| 162 | flatbuffers::GetTemporaryPointer(*builder->fbb(), target_spline); |
| 163 | SendStartingPosition(CHECK_NOTNULL(spline)); |
| 164 | return target_spline; |
| 165 | }, |
| 166 | SplineDirection::kForward); |
| 167 | |
| 168 | if (!spline1.WaitForPlan()) return; |
| 169 | spline1.Start(); |
| 170 | |
| 171 | SplineHandle spline2 = PlanSpline( |
James Kuszmaul | 75a18c5 | 2021-03-10 22:02:07 -0800 | [diff] [blame] | 172 | [this](aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 173 | *builder) { return auto_splines_.AutoNavBounce2(builder); }, |
| 174 | SplineDirection::kBackward); |
| 175 | |
| 176 | if (!spline1.WaitForSplineDistanceRemaining(0.02)) return; |
| 177 | |
| 178 | if (!spline2.WaitForPlan()) return; |
| 179 | spline2.Start(); |
| 180 | |
| 181 | SplineHandle spline3 = PlanSpline( |
James Kuszmaul | 75a18c5 | 2021-03-10 22:02:07 -0800 | [diff] [blame] | 182 | [this](aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 183 | *builder) { return auto_splines_.AutoNavBounce3(builder); }, |
| 184 | SplineDirection::kForward); |
| 185 | |
| 186 | if (!spline2.WaitForSplineDistanceRemaining(0.02)) return; |
| 187 | |
| 188 | if (!spline3.WaitForPlan()) return; |
| 189 | spline3.Start(); |
| 190 | |
| 191 | SplineHandle spline4 = PlanSpline( |
James Kuszmaul | 75a18c5 | 2021-03-10 22:02:07 -0800 | [diff] [blame] | 192 | [this](aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 193 | *builder) { return auto_splines_.AutoNavBounce4(builder); }, |
| 194 | SplineDirection::kBackward); |
| 195 | |
| 196 | if (!spline3.WaitForSplineDistanceRemaining(0.02)) return; |
| 197 | |
| 198 | if (!spline4.WaitForPlan()) return; |
| 199 | spline4.Start(); |
| 200 | |
| 201 | if (!spline4.WaitForSplineDistanceRemaining(0.02)) return; |
| 202 | } |
| 203 | |
| 204 | void AutonomousActor::AutoNavBarrel() { |
| 205 | SplineHandle spline1 = PlanSpline( |
James Kuszmaul | 75a18c5 | 2021-03-10 22:02:07 -0800 | [diff] [blame] | 206 | [this](aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 207 | *builder) { |
| 208 | flatbuffers::Offset<frc971::MultiSpline> target_spline; |
| 209 | target_spline = auto_splines_.AutoNavBarrel(builder); |
| 210 | const frc971::MultiSpline *const spline = |
| 211 | flatbuffers::GetTemporaryPointer(*builder->fbb(), target_spline); |
| 212 | SendStartingPosition(CHECK_NOTNULL(spline)); |
| 213 | return target_spline; |
| 214 | }, |
| 215 | SplineDirection::kForward); |
| 216 | |
| 217 | if (!spline1.WaitForPlan()) return; |
| 218 | spline1.Start(); |
| 219 | |
| 220 | if (!spline1.WaitForSplineDistanceRemaining(0.02)) return; |
| 221 | } |
| 222 | |
| 223 | void AutonomousActor::AutoNavSlalom() { |
| 224 | SplineHandle spline1 = PlanSpline( |
James Kuszmaul | 75a18c5 | 2021-03-10 22:02:07 -0800 | [diff] [blame] | 225 | [this](aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder |
Ravago Jones | 9c326f5 | 2021-03-20 15:00:16 -0700 | [diff] [blame] | 226 | *builder) { |
| 227 | flatbuffers::Offset<frc971::MultiSpline> target_spline; |
| 228 | target_spline = auto_splines_.AutoNavSlalom(builder); |
| 229 | const frc971::MultiSpline *const spline = |
| 230 | flatbuffers::GetTemporaryPointer(*builder->fbb(), target_spline); |
| 231 | SendStartingPosition(CHECK_NOTNULL(spline)); |
| 232 | return target_spline; |
| 233 | }, |
| 234 | SplineDirection::kForward); |
| 235 | |
| 236 | if (!spline1.WaitForPlan()) return; |
| 237 | spline1.Start(); |
| 238 | |
| 239 | if (!spline1.WaitForSplineDistanceRemaining(0.02)) return; |
| 240 | } |
| 241 | |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 242 | void AutonomousActor::SplineAuto() { |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 243 | SplineHandle spline1 = PlanSpline( |
James Kuszmaul | 75a18c5 | 2021-03-10 22:02:07 -0800 | [diff] [blame] | 244 | [this](aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 245 | *builder) { |
| 246 | flatbuffers::Offset<frc971::MultiSpline> target_spline; |
| 247 | target_spline = auto_splines_.TestSpline(builder); |
| 248 | const frc971::MultiSpline *const spline = |
| 249 | flatbuffers::GetTemporaryPointer(*builder->fbb(), target_spline); |
| 250 | SendStartingPosition(CHECK_NOTNULL(spline)); |
| 251 | return target_spline; |
| 252 | }, |
Ravago Jones | c2a0802 | 2021-02-06 17:40:54 -0800 | [diff] [blame] | 253 | SplineDirection::kForward); |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 254 | |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 255 | if (!spline1.WaitForPlan()) return; |
James Kuszmaul | 5f6d1d4 | 2020-03-01 18:10:07 -0800 | [diff] [blame] | 256 | spline1.Start(); |
| 257 | |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 258 | if (!spline1.WaitForSplineDistanceRemaining(0.02)) return; |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 259 | } |
| 260 | |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 261 | void AutonomousActor::SendStartingPosition( |
| 262 | const frc971::MultiSpline *const spline) { |
| 263 | float x = spline->spline_x()->Get(0); |
| 264 | float y = spline->spline_y()->Get(0); |
| 265 | |
| 266 | Eigen::Matrix<double, 2, 6> control_points; |
| 267 | for (size_t ii = 0; ii < 6; ++ii) { |
| 268 | control_points(0, ii) = spline->spline_x()->Get(ii); |
| 269 | control_points(1, ii) = spline->spline_y()->Get(ii); |
| 270 | } |
| 271 | |
| 272 | frc971::control_loops::drivetrain::Spline spline_object(control_points); |
| 273 | |
| 274 | SendStartingPosition(x, y, spline_object.Theta(0)); |
| 275 | } |
| 276 | |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 277 | ProfileParametersT MakeProfileParametersT(const float max_velocity, |
| 278 | const float max_acceleration) { |
| 279 | ProfileParametersT params; |
| 280 | params.max_velocity = max_velocity; |
| 281 | params.max_acceleration = max_acceleration; |
| 282 | return params; |
| 283 | } |
| 284 | |
| 285 | bool AutonomousActor::DriveFwd() { |
kyle | 96c406e | 2021-02-27 14:07:22 -0800 | [diff] [blame] | 286 | SendStartingPosition(0, 0, 0); |
Austin Schuh | fd1715f | 2021-01-30 16:58:24 -0800 | [diff] [blame] | 287 | const ProfileParametersT kDrive = MakeProfileParametersT(0.3f, 1.0f); |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 288 | const ProfileParametersT kTurn = MakeProfileParametersT(5.0f, 15.0f); |
Austin Schuh | fd1715f | 2021-01-30 16:58:24 -0800 | [diff] [blame] | 289 | StartDrive(1.0, 0.0, kDrive, kTurn); |
milind upadhyay | 47a0ab3 | 2020-11-25 19:34:41 -0800 | [diff] [blame] | 290 | return WaitForDriveDone(); |
| 291 | } |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 292 | |
| 293 | void AutonomousActor::SendSuperstructureGoal() { |
| 294 | |
| 295 | auto builder = superstructure_goal_sender_.MakeBuilder(); |
| 296 | |
| 297 | flatbuffers::Offset<StaticZeroingSingleDOFProfiledSubsystemGoal> |
| 298 | intake_offset; |
milind upadhyay | b9dec71 | 2021-03-20 15:47:51 -0700 | [diff] [blame] | 299 | |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 300 | { |
| 301 | StaticZeroingSingleDOFProfiledSubsystemGoal::Builder intake_builder = |
| 302 | builder.MakeBuilder<StaticZeroingSingleDOFProfiledSubsystemGoal>(); |
| 303 | |
milind upadhyay | b9dec71 | 2021-03-20 15:47:51 -0700 | [diff] [blame] | 304 | frc971::ProfileParameters::Builder profile_params_builder = |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 305 | builder.MakeBuilder<frc971::ProfileParameters>(); |
Sabina Leaver | 8302e3c | 2021-03-20 16:36:05 -0700 | [diff] [blame] | 306 | profile_params_builder.add_max_velocity(10.0); |
| 307 | profile_params_builder.add_max_acceleration(30.0); |
milind upadhyay | b9dec71 | 2021-03-20 15:47:51 -0700 | [diff] [blame] | 308 | flatbuffers::Offset<frc971::ProfileParameters> profile_params_offset = |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 309 | profile_params_builder.Finish(); |
| 310 | intake_builder.add_unsafe_goal(intake_goal_); |
| 311 | intake_builder.add_profile_params(profile_params_offset); |
| 312 | intake_offset = intake_builder.Finish(); |
| 313 | } |
| 314 | |
| 315 | superstructure::Goal::Builder superstructure_builder = |
| 316 | builder.MakeBuilder<superstructure::Goal>(); |
milind upadhyay | b9dec71 | 2021-03-20 15:47:51 -0700 | [diff] [blame] | 317 | |
Sabina Leaver | a0b43b4 | 2021-03-03 20:30:04 -0800 | [diff] [blame] | 318 | superstructure_builder.add_intake(intake_offset); |
| 319 | superstructure_builder.add_roller_voltage(roller_voltage_); |
| 320 | superstructure_builder.add_roller_speed_compensation(kRollerSpeedCompensation); |
| 321 | |
| 322 | if (!builder.Send(superstructure_builder.Finish())) { |
| 323 | AOS_LOG(ERROR, "Sending superstructure goal failed.\n"); |
| 324 | } |
| 325 | |
| 326 | } |
milind upadhyay | 5e589d7 | 2021-03-27 13:47:18 -0700 | [diff] [blame] | 327 | |
| 328 | void AutonomousActor::RetractIntake() { |
| 329 | set_intake_goal(-0.89); |
| 330 | set_roller_voltage(0.0); |
| 331 | SendSuperstructureGoal(); |
| 332 | } |
| 333 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 334 | } // namespace actors |
| 335 | } // namespace y2020 |