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

Fix Climber state softlock (。_。) #271

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ public static class constCoralOuttake {
public static class constClimber {
public static final double CLIMBER_MOTOR_DEPLOYING_VELOCITY = 0.5;
public static final double CLIMBER_RETRACT_VELOCITY = -0.1;
public static final Angle VALID_NONE_STATE_THRESHOLD = Units.Degrees.of(15);

public static TalonFXConfiguration CLIMBER_CONFIG = new TalonFXConfiguration();
static {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ private void configureDriverBindings(SN_XboxController controller) {
.onFalse(TRY_NONE);

controller.btn_Y
.whileTrue(TRY_CLIMBER_RETRACTING)
.onFalse(TRY_NONE);
.whileTrue(TRY_CLIMBER_RETRACTING);

controller.btn_North
.onTrue(Commands.runOnce(() -> subDrivetrain.resetPoseToPose(Pose2d.kZero)));
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/frc/robot/subsystems/Climber.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import edu.wpi.first.units.Units;
import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.units.measure.Distance;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.epilogue.Logged;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
Expand All @@ -41,8 +40,8 @@ public void setClimberMotorVelocity(double velocity) {
climberMotor2.set(-velocity);
}

public Distance getClimberPosition() {
return Units.Inches.of(climberMotor.get());
public Angle getClimberPosition() {
return climberMotor.getPosition().getValue();
}

public void setPosition(Angle angle) {
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/frc/robot/subsystems/StateMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

package frc.robot.subsystems;

import static edu.wpi.first.units.Units.Rotations;

import com.frcteam3255.joystick.SN_XboxController;

import edu.wpi.first.epilogue.Logged;
import edu.wpi.first.epilogue.NotLogged;
import frc.robot.Constants.constClimber;
import frc.robot.Constants.constElevator;
import edu.wpi.first.wpilibj2.command.*;
import frc.robot.commands.states.*;
Expand Down Expand Up @@ -79,10 +82,15 @@ public Command tryState(RobotState desiredState) {
case CLEANING_L3:
case SCORING_CORAL:
case SCORING_ALGAE:
case CLIMBER_DEPLOYING:
case CLIMBER_RETRACTING:
return new None(subStateMachine, subCoralOuttake, subHopper, subAlgaeIntake, subClimber, subElevator,
subLED);
case CLIMBER_DEPLOYING:
if (subClimber.getClimberPosition().lte(constClimber.VALID_NONE_STATE_THRESHOLD)) {
return new None(subStateMachine, subCoralOuttake, subHopper, subAlgaeIntake, subClimber, subElevator,
subLED);
} else {
Commands.print("Climber is too far down!!! Not safe to return to NONE >____<");
}
}
break;

Expand Down