|
26 | 26 | import frc.robot.commands.ResetPose; |
27 | 27 | import frc.robot.constants.ChoreoTraj; |
28 | 28 | import frc.robot.constants.ConstAuto; |
| 29 | +import frc.robot.constants.ConstField; |
29 | 30 | import frc.robot.constants.ConstSystem; |
30 | 31 | import frc.robot.constants.ConstSystem.constControllers; |
31 | 32 | import frc.robot.subsystems.DriverStateMachine; |
@@ -220,11 +221,29 @@ public void configAutonomous() { |
220 | 221 | driverStateMachineInstance // The drive subsystem |
221 | 222 | ); |
222 | 223 |
|
223 | | - Command AutoPIDTuning = Commands.sequence(runPath(ChoreoTraj.AutoPIDTuning)); |
| 224 | + Command AutoPIDTuning = Commands.sequence(runPath(ChoreoTraj.AutoPIDTuning).asProxy()); |
| 225 | + |
224 | 226 | Command DoNothing = Commands.none(); |
225 | 227 |
|
| 228 | + Command DSideNeutral = Commands.sequence( |
| 229 | + CollectAndScore(ChoreoTraj.DSideTrenchToNeutral, |
| 230 | + ChoreoTraj.FirstDSideNeutralToAlliance, |
| 231 | + ChoreoTraj.DSideAllianceToDepot, |
| 232 | + ConstAuto.SHOOTING_TIMEOUT)); |
| 233 | + |
| 234 | + Command DSideDoubleNeutral = Commands.sequence( |
| 235 | + DSideNeutral.asProxy(), |
| 236 | + CollectAndScore(ChoreoTraj.DSideTrenchToNeutral, |
| 237 | + ChoreoTraj.SecondDSideNeutralToAlliance, |
| 238 | + ChoreoTraj.DSideAllianceToTrench, |
| 239 | + ConstAuto.SHOOTING_TIMEOUT)); |
| 240 | + |
| 241 | + // Command DSideNeutralWithDepot = Commands.sequence( |
| 242 | + // DSideNeutral.asProxy(), |
| 243 | + // CollectAndScore(null, null, null, null)); |
| 244 | + |
226 | 245 | // Example: Add autonomous routines to the chooser |
227 | | - // Add more autonomous routines as needed, e.g.: |
| 246 | + // Add more autonomous routines as needed, e.g.:\ |
228 | 247 | // autoChooser.addOption("Score and Leave", runPath("ScoreAndLeave")); |
229 | 248 | autoChooser.setDefaultOption("Do Nothing", DoNothing); |
230 | 249 | autoChooser.addOption("AutoPIDTuning", AutoPIDTuning); |
@@ -274,6 +293,27 @@ Command ShootingOnMove(ChoreoTraj shootingPath, Time shootingTime) { |
274 | 293 | TRY_NONE.asProxy()); |
275 | 294 | } |
276 | 295 |
|
| 296 | + Command CollectAndScore(ChoreoTraj intakingPath, ChoreoTraj returnToAlliancePath, ChoreoTraj shootingPath, |
| 297 | + Time shootingTime) { |
| 298 | + return Commands.sequence( |
| 299 | + Commands.runOnce(() -> stateMachineInstance.setRobotState(RobotState.NONE)).asProxy(), |
| 300 | + runPath(intakingPath).asProxy().deadlineFor(TRY_INTAKING.asProxy()), |
| 301 | + Commands.parallel( |
| 302 | + runPath(returnToAlliancePath).asProxy(), |
| 303 | + Commands.sequence( |
| 304 | + // TRY_INTAKING is a deferred/instant command that finishes immediately after |
| 305 | + // requesting the state. Using .until(...) on it will therefore end right away. |
| 306 | + // Instead, explicitly request the INTAKING state once and then wait until the |
| 307 | + // drivetrain is behind the horizontal line before continuing to prep shooting. |
| 308 | + TRY_INTAKING.asProxy(), |
| 309 | + Commands |
| 310 | + .waitUntil(() -> drivetrainInstance.isBehindHorizontalLine(ConstField.FieldElements.ALLIANCE_LINE, |
| 311 | + ConstField.isRedAlliance(), ConstField.FIELD_LENGTH)), |
| 312 | + TRY_SHOOTING_ON_FLY.asProxy().withTimeout(ConstAuto.PREP_SHOOT_TIMEOUT))), |
| 313 | + runPath(intakingPath).asProxy().alongWith(TRY_SHOOTING_ON_FLY.asProxy().withTimeout(shootingTime)), |
| 314 | + TRY_NONE.asProxy()); |
| 315 | + } |
| 316 | + |
277 | 317 | public Command runPath(ChoreoTraj path) { |
278 | 318 | return autoFactory.trajectoryCmd(path.name()).asProxy() |
279 | 319 | .alongWith(Commands.runOnce(() -> { |
|
0 commit comments