Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset all subsystems on teleop init #24

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading