Skip to content

Commit

Permalink
Reset all subsystems on teleop init
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammingSR committed Mar 4, 2024
1 parent bf9b429 commit af2c2d1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public void teleopInit() {
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
}

m_robotContainer.resetAllSubsystems();
}

/** This function is called periodically during operator control. */
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ private void configureBindings() {
.onFalse(new IntakeArmPositionCommand(m_intakeSubsystem, ArmPosition.Retracted));
}

/**
* Reset all subsystems on teleop init
*/
public void resetAllSubsystems() {
m_intakeSubsystem.reset();
m_shooterSubsystem.reset();
m_robotDrive.reset();
}

/**
* Use this to pass the autonomous command to the main {@link Robot} class.
*
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/subsystems/DriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public void periodic() {
setModuleStates(swerveModuleStates);
}

public void reset() {
swerveModuleStates = new SwerveModuleState[] { new SwerveModuleState(), new SwerveModuleState(), new SwerveModuleState(), new SwerveModuleState() };
}

/**
* Returns the currently-estimated pose of the robot.
*
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/frc/robot/subsystems/IntakeSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public IntakeSubsystem() {
m_armSetpoint = m_armEncoder.getDistance();
}

public void reset() {
m_intakeMotor.set(0);
m_armMotor.set(0);

m_intakeSpeed = 0;
m_armSetpoint = getDistanceSensor();
}

public void setArmPosition(ArmPosition position) {
switch (position) {
case Amp:
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/frc/robot/subsystems/ShooterSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public ShooterSubsystem() {
m_top.setInverted(true);
}

public void reset() {
m_topSpeed = 0;
m_bottomSpeed = 0;

m_top.set(0);
m_bottom.set(0);
}

public void setShootingSpeed(ShootSpeed speed) {
switch (speed) {
case Shooting:
Expand Down

0 comments on commit af2c2d1

Please sign in to comment.