Skip to content

Commit

Permalink
Add gyro set on houndbrian
Browse files Browse the repository at this point in the history
  • Loading branch information
superpenguin612 committed Mar 21, 2024
1 parent 756cfa4 commit 968e812
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/HoundBrian.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public class HoundBrian {
public HoundBrian(Drivetrain drivetrain, Intake intake, ShooterTilt shooterTilt, Climber climber, NoteLift noteLift,
LEDs leds) {

new Trigger(drivetrainButton::get).negate()
// .and(new Trigger(intakeButton::get).negate().debounce(2,
// DebounceType.kFalling))
.and(DriverStation::isDisabled)
.onTrue(drivetrain.resetGyroCommand().ignoringDisable(true));
new Trigger(intakeButton::get).negate()
// .and(new Trigger(intakeButton::get).negate().debounce(2,
// DebounceType.kFalling))
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ public RobotContainer() {
climber.resetControllersCommand()).withName("resetControllers"));

new Trigger(() -> {
return intake.getInitialized()
return drivetrain.getInitialized()
&& intake.getInitialized()
&& shooterTilt.getInitialized()
&& climber.getInitialized()
&& noteLift.getInitialized();
Expand All @@ -172,6 +173,7 @@ public RobotContainer() {

leds.requestStateCommand(LEDState.INITIALIZATION_BLACK_BACKGROUND).until(GlobalStates.INITIALIZED::enabled)
.schedule();
leds.requestStateCommand(LEDState.DRIVETRAIN_GYRO_UNINITIALIZED).until(drivetrain::getInitialized).schedule();
leds.requestStateCommand(LEDState.INTAKE_UNINITIALIZED).until(intake::getInitialized).schedule();
leds.requestStateCommand(LEDState.SHOOTER_TILT_UNINITIALIZED).until(shooterTilt::getInitialized).schedule();
leds.requestStateCommand(LEDState.CLIMBER_UNINITIALIZED).until(climber::getInitialized).schedule();
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/frc/robot/subsystems/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ public class Drivetrain extends SubsystemBase implements BaseSwerveDrive {
@Log
private int failedDaqs = 0;

private boolean initialized = false;

/** Initializes the drivetrain. */
public Drivetrain() {
poseEstimator = new SwerveDrivePoseEstimator(
Expand Down Expand Up @@ -574,7 +576,8 @@ public void resetPoseEstimator(Pose2d pose) {

@Override
public void resetGyro() {
pigeon.setYaw(0);
pigeon.setYaw(DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Blue ? 180 : 0);
initialized = true;
}

@Override
Expand Down Expand Up @@ -1074,4 +1077,7 @@ public Pose3d calculateEffectiveTargetLocation() {
getFieldRelativeAccelerations());
}

public boolean getInitialized() {
return initialized;
}
}
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/subsystems/LEDs.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public enum LEDState {
breathe(Color.kRed, 3, 0, 255, LEDSection.SHOOTER_RIGHT_BOTTOM)),
SHOOTER_TILT_UNINITIALIZED(
breathe(Color.kRed, 3, 0, 255, LEDSection.SHOOTER_LEFT_TOP),
breathe(Color.kRed, 3, 0, 255, LEDSection.SHOOTER_RIGHT_TOP),
breathe(Color.kRed, 3, 0, 255, LEDSection.SHOOTER_RIGHT_TOP)),
DRIVETRAIN_GYRO_UNINITIALIZED(
breathe(Color.kRed, 3, 0, 255, LEDSection.SHOOTER_TOP)),
INITIALIZATION_BLACK_BACKGROUND(solid(Color.kBlack, LEDSection.ALL)),
INITIALIZED_CONFIRM(breathe(Color.kGreen, 2, 0, 255, LEDSection.ALL)),
Expand Down

0 comments on commit 968e812

Please sign in to comment.