Skip to content

Commit 3879745

Browse files
added major changes to hood, hub tracking and added a right corner passing mode.
1 parent 722acca commit 3879745

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/main/java/com/swrobotics/robot/control/AimCalc.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ public class AimCalc {
2828
private static final double kHubObstacleRadiusMeters = Units.inchesToMeters(41.0);
2929

3030
// TUNE THESE: The coordinates of the corner in front of the HP station
31-
private static final Translation2d kBlueHumanPlayerCorner = new Translation2d(1.6, 1.45);
32-
private static final Translation2d kRedHumanPlayerCorner = new Translation2d(15, 6.6);
31+
private static final Translation2d kBlueHumanPlayerRightCorner = new Translation2d(1.6, 1.45);
32+
private static final Translation2d kBlueHumanPlayerLeftCorner = new Translation2d(1.6, 6.6);
33+
34+
private static final Translation2d kRedHumanPlayerLeftCorner = new Translation2d(15, 1.45);
35+
private static final Translation2d kRedHumanPlayerRightCorner = new Translation2d(15, 6.6);
3336

3437
// TUNE THESE: Turret physical soft limits to prevent infinite spinning/wire damage
3538
private static final double kTurretMinAngleDeg = -270.0;
@@ -184,7 +187,6 @@ private Rotation2d wrapTurretAngle(Rotation2d rawTargetAngle, Rotation2d current
184187

185188
double currentDeg = currentAngle.getDegrees();
186189

187-
// The turret might have a range > 360. Check which equivalent angle is closest.
188190
double[] possibleAngles = {
189191
normalizedTarget - 360.0,
190192
normalizedTarget,
@@ -205,16 +207,13 @@ private Rotation2d wrapTurretAngle(Rotation2d rawTargetAngle, Rotation2d current
205207
}
206208
}
207209

208-
// Fallback constraint just in case all angles are somehow out of bounds
209210
if (minError == Double.MAX_VALUE) {
210211
bestAngle = MathUtil.clamp(normalizedTarget, kTurretMinAngleDeg, kTurretMaxAngleDeg);
211212
}
212213

213214
return Rotation2d.fromDegrees(bestAngle);
214215
}
215-
216-
// Overloaded to maintain backwards compatibility if currentTurretAngle isn't wired yet.
217-
// NOTE: Call the other update method to get wrap logic working correctly.
216+
218217
public void update(Pose2d robotPose, ChassisSpeeds fieldSpeeds) {
219218
update(robotPose, fieldSpeeds, new Rotation2d());
220219
}
@@ -224,7 +223,7 @@ public void update(Pose2d robotPose, ChassisSpeeds fieldSpeeds, Rotation2d curre
224223
Translation2d hub = FieldPositions.getAllianceHubPose(alliance).getTranslation();
225224

226225
Translation2d target = passingMode ?
227-
(alliance == DriverStation.Alliance.Blue ? kBlueHumanPlayerCorner : kRedHumanPlayerCorner)
226+
(alliance == DriverStation.Alliance.Blue ? kBlueHumanPlayerRightCorner : kRedHumanPlayerRightCorner)
228227
: hub;
229228

230229
Translation2d shooterPos = robotPose.getTranslation().plus(

src/main/java/com/swrobotics/robot/control/ControlBoard.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ private void configureControls() {
8989
driver.leftTrigger().whileTrue(robot.intake.commandSetState(IntakeSubsystem.State.INTAKE));
9090
driver.leftBumper().whileTrue(robot.indexer.commandSetState(IndexerSubsystem.State.RINDEX));
9191

92-
driver.rightTrigger().whileTrue(DriveCommands.shootOnTheMove(robot.drive,
93-
() -> -driver.getLeftY(),
94-
() -> -driver.getLeftX()
95-
).withTimeout(.5).andThen(robot.indexer.commandSetState(IndexerSubsystem.State.FEED)
96-
.alongWith(robot.expansion.commandShoot())));
92+
driver.rightTrigger().whileTrue(robot.shooter.commandSetState(ShooterSubsystem.State.AUTO)
93+
.alongWith(robot.hood.setMode(HoodSubsystem.HoodState.AUTO_TRACK))
94+
.withTimeout(.5)
95+
.andThen(robot.indexer.commandSetState(IndexerSubsystem.State.FEED)
96+
.alongWith(robot.expansion.commandShoot())));
9797

9898
driver.rightBumper()
99-
.whileTrue(commandSetRoboState(ControlBoard.RoboState.PASS)
99+
.whileTrue(robot.shooter.commandSetState(ShooterSubsystem.State.PASS)
100+
.alongWith(robot.hood.setMode(HoodSubsystem.HoodState.PASSING))
100101
.withTimeout(.75)
101102
.andThen(robot.indexer.commandSetState(IndexerSubsystem.State.FEED)
102103
.alongWith(robot.expansion.commandShoot())));

src/main/java/com/swrobotics/robot/subsystems/shooter/ShooterSubsystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public ShooterSubsystem() {
4242

4343
config.apply(motorL, motorR);
4444
motorR.setControl(new Follower(motorL.getDeviceID(), MotorAlignmentValue.Opposed));
45-
setDefaultCommand(commandSetState(State.PASS));
45+
setDefaultCommand(commandSetState(State.IDLE));
4646
}
4747

4848
@Override

src/main/java/com/swrobotics/robot/subsystems/shooter/hood/HoodSubsystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class HoodSubsystem extends SubsystemBase {
2424
private final VoltageOut voltageControl = new VoltageOut(0);
2525

2626
public enum HoodState { HOMING, IDLE, AUTO_TRACK, PASSING, MANUAL }
27-
private HoodState state = HoodState.PASSING;
27+
private HoodState state = HoodState.HOMING;
2828

2929
private double targetRotations = kMinAngleRot;
3030
private final Timer homingTimer = new Timer();

0 commit comments

Comments
 (0)