Skip to content

Commit 1936633

Browse files
committed
added d side neutral stuff
1 parent fb79c23 commit 1936633

4 files changed

Lines changed: 50 additions & 7 deletions

File tree

src/main/java/frc/robot/RobotContainer.java

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import frc.robot.commands.ResetPose;
2727
import frc.robot.constants.ChoreoTraj;
2828
import frc.robot.constants.ConstAuto;
29+
import frc.robot.constants.ConstField;
2930
import frc.robot.constants.ConstSystem;
3031
import frc.robot.constants.ConstSystem.constControllers;
3132
import frc.robot.subsystems.DriverStateMachine;
@@ -220,11 +221,29 @@ public void configAutonomous() {
220221
driverStateMachineInstance // The drive subsystem
221222
);
222223

223-
Command AutoPIDTuning = Commands.sequence(runPath(ChoreoTraj.AutoPIDTuning));
224+
Command AutoPIDTuning = Commands.sequence(runPath(ChoreoTraj.AutoPIDTuning).asProxy());
225+
224226
Command DoNothing = Commands.none();
225227

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+
226245
// 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.:\
228247
// autoChooser.addOption("Score and Leave", runPath("ScoreAndLeave"));
229248
autoChooser.setDefaultOption("Do Nothing", DoNothing);
230249
autoChooser.addOption("AutoPIDTuning", AutoPIDTuning);
@@ -274,6 +293,27 @@ Command ShootingOnMove(ChoreoTraj shootingPath, Time shootingTime) {
274293
TRY_NONE.asProxy());
275294
}
276295

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+
277317
public Command runPath(ChoreoTraj path) {
278318
return autoFactory.trajectoryCmd(path.name()).asProxy()
279319
.alongWith(Commands.runOnce(() -> {

src/main/java/frc/robot/constants/ChoreoVars.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import edu.wpi.first.math.geometry.Rotation2d;
55
import edu.wpi.first.units.Units;
66
import edu.wpi.first.units.measure.*;
7-
import edu.wpi.first.wpilibj2.command.Command;
87

98
/**
109
* Generated file containing variables defined in Choreo.

src/main/java/frc/robot/constants/ConstAuto.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
package frc.robot.constants;
66

7+
import static edu.wpi.first.units.Units.Seconds;
8+
9+
import edu.wpi.first.units.measure.Time;
10+
711
/** Add your docs here. */
812
public class ConstAuto {
913
public static final double PREP_SHOOT_TIMEOUT = 4;
10-
14+
public static final Time SHOOTING_TIMEOUT = Seconds.of(4.5);
1115
}

src/main/java/frc/robot/constants/ConstField.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public List<Pose2d> getAlliancePoses() {
110110
}
111111
}
112112

113-
public static final Distance FIELD_LENGTH = Units.Inches.of(651.2); // TODO: Update from game manual
114-
public static final Distance FIELD_WIDTH = Units.Inches.of(317.7); // TODO: Update from game manual
113+
public static final Distance FIELD_LENGTH = Units.Inches.of(651.2);
114+
public static final Distance FIELD_WIDTH = Units.Inches.of(317.7);
115115

116116
/**
117117
* Boolean that controls when the path will be mirrored for the red
@@ -133,7 +133,7 @@ public static boolean isRedAlliance() {
133133
public static class FieldElements {
134134
// TODO: Replace with actual measurement
135135
private static final Pose2d RESET_POSE = new Pose2d(0, 0, new Rotation2d());
136-
136+
public static final Distance ALLIANCE_LINE = Units.Meters.of(4.008662700653076);
137137
}
138138

139139
public static class FieldElementGroups {

0 commit comments

Comments
 (0)