Skip to content

Commit

Permalink
added auto aim back
Browse files Browse the repository at this point in the history
  • Loading branch information
cherriae committed Mar 14, 2024
1 parent 93cb321 commit 0bd71b5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public static class FieldConstants {
// FIELD WIDTH: 651.223 INCHES

// x: .2472 y: 5.5946 (USE THIS)
public static final Pose3d SPEAKER_POSE_BLUE = new Pose3d(0.25, 5.59, SPEAKER_HEIGHT, new Rotation3d(0, 0, 180));
public static final Pose3d SPEAKER_POSE_RED = new Pose3d(16.29, 5.59, SPEAKER_HEIGHT, new Rotation3d(0, 0, 0)); // TODO: fix X here
public static final Pose3d SPEAKER_POSE_BLUE = new Pose3d(0.17, 5.3, SPEAKER_HEIGHT, new Rotation3d(0, 0, 180));
public static final Pose3d SPEAKER_POSE_RED = new Pose3d(16.37, 5.3, SPEAKER_HEIGHT, new Rotation3d(0, 0, 0)); // TODO: fix X here
}

public static class LEDColors {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private void configureBindings() {
// driver bindings
_driveController.L1().onTrue(Commands.runOnce(_swerveSubsystem::toggleSpeed, _swerveSubsystem));
_driveController.R1().onTrue(Commands.runOnce(() -> _swerveSubsystem.fieldOriented = !_swerveSubsystem.fieldOriented, _swerveSubsystem));
_driveController.triangle().onTrue(Commands.runOnce(_swerveSubsystem::resetGyro, _swerveSubsystem));
_driveController.triangle().onTrue(Commands.runOnce(() -> _swerveSubsystem.resetGyro(), _swerveSubsystem));
_driveController.cross().whileTrue(new BrakeSwerve(_swerveSubsystem, _ledSubsystem));

// TESTING ONLY!!!
Expand All @@ -172,7 +172,7 @@ private void configureBindings() {
)
);

_driveController.R2().whileTrue(
_operatorController.R2().whileTrue(
new AutoAim(
_shooterSubsystem,
_elevatorSubsystem,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/commands/shooter/AutonShoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AutonShoot(
new ParallelRaceGroup(
new SpinShooter(shooter, ShooterState.SHOOT).withTimeout(1.5),
new AutoAim(shooter, elevator, leds, swerve, Presets.CLOSE_SHOOTER_ANGLE, Presets.CLOSE_ELEVATOR_HEIGHT, this::headingPreset).withTimeout(2),
new FeedActuate(intake, FeedMode.INTAKE).withTimeout(1)
new FeedActuate(intake, FeedMode.INTAKE).withTimeout(4)
).onlyIf(() -> !_preloadShot).andThen(() -> _preloadShot = true),

new FeedActuate(intake, FeedMode.OUTTAKE).withTimeout(1),
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/subsystems/SwerveDriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ public double getDriveCoeff() {
public void driveChassis(ChassisSpeeds chassisSpeeds) {
// IMPORTANT: X-axis and Y-axis are flipped (based on wpilib coord system)
if (fieldOriented) {
chassisSpeeds = ChassisSpeeds.fromFieldRelativeSpeeds(chassisSpeeds, getHeading());
double relativeHeading = getHeading().getDegrees() + (UtilFuncs.GetAlliance() == Alliance.Red ? 180 : 0);
chassisSpeeds = ChassisSpeeds.fromFieldRelativeSpeeds(chassisSpeeds, Rotation2d.fromDegrees(relativeHeading));
}

SwerveModuleState[] moduleStates = Constants.Physical.SWERVE_KINEMATICS.toSwerveModuleStates(chassisSpeeds,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/VisionSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Optional<Pose2d> getBotpose() {
int tags = (int) botpose_array[7];
double distance = botpose_array[9];

if (tags < 2) return Optional.empty();
// if (tags < 2) return Optional.empty();
if (distance > FieldConstants.TAG_DISTANCE_THRESHOLD) return Optional.empty();

double botposeX = _xFilter.calculate(botpose_array[0]); // to get rid of the weird origin outlier
Expand Down

0 comments on commit 0bd71b5

Please sign in to comment.