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

Reworked deep climb #149

Merged
merged 11 commits into from
Feb 1, 2025
8 changes: 6 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ private void configureBindings() {
// CORAL.and(leftDriveController.getTrigger()).whileTrue(alignToReef(9, 0));

// Climb Bindings
leftDriveController.getLeftThumb().whileTrue(climberSubsystem.moveClimberDown());
leftDriveController.getRightThumb().whileTrue(climberSubsystem.moveClimberUp());
leftDriveController.getLeftThumb().whileTrue(climberSubsystem.downPosition());
leftDriveController.getRightThumb().whileTrue(climberSubsystem.upPosition());

// Intake Bindings
rightDriveController.getLeftThumb().whileTrue(intakeSubsystem.intake());
Expand All @@ -302,6 +302,10 @@ private void configureBindings() {
ALGAE.and(rightDriveController.getTrigger()).whileTrue(gripperSubsystem.ejectSpinAlgae());

// Technical Bindings

leftDriveController.getLeftBottomMiddle().onTrue(climberSubsystem.zeroClimberCommand());
leftDriveController.getLeftTopMiddle().whileTrue(climberSubsystem.climberTuneable());

rightDriveController
.getLeftTopLeft()
.onTrue(Commands.runOnce(() -> drivetrain.seedFieldCentric()));
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/frc/robot/constants/ClimberConstants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package frc.robot.constants;

import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.MotionMagicConfigs;
import com.ctre.phoenix6.configs.Slot0Configs;

Expand All @@ -19,4 +20,14 @@ public class ClimberConstants {
.withMotionMagicAcceleration(4) // these are guesses, come back here
.withMotionMagicCruiseVelocity(4) // also guess
.withMotionMagicJerk(4);

public static final CurrentLimitsConfigs currentLimitsConfigs = new CurrentLimitsConfigs();

public static final double upperLimit = 100;

public static final double lowerLimit = 0;

public static final int id = 83;

public static final String CANbus = "CANivore";
}
159 changes: 0 additions & 159 deletions src/main/java/frc/robot/subsystems/TestBase.java

This file was deleted.

4 changes: 1 addition & 3 deletions src/main/java/frc/robot/subsystems/climber/ClimberIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public interface ClimberIO {

@AutoLog
public class ClimberIOInputs {

// public double voltage = 0;
public double position = 0;
public double speed = 0;
public double voltage;
Expand All @@ -21,5 +19,5 @@ public class ClimberIOInputs {

public void setVoltage(double voltage);

public double getPosition();
public void resetPosition(double position);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ public void setVoltage(double voltage) {
}

public void setPosition(double position) {

this.positionSetpoint = position;
}

public double getPosition() {
return position;
public void resetPosition(double position) {
this.position = position;
}
}
36 changes: 25 additions & 11 deletions src/main/java/frc/robot/subsystems/climber/ClimberIOTalonFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import com.ctre.phoenix6.configs.SoftwareLimitSwitchConfigs;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.configs.TalonFXConfigurator;
import com.ctre.phoenix6.controls.Follower;
import com.ctre.phoenix6.controls.MotionMagicVoltage;
import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.signals.NeutralModeValue;
import frc.robot.constants.ClimberConstants;

public class ClimberIOTalonFX implements ClimberIO {
// TBD: Hardcode IDs or add support to make changeable in method
private final TalonFX climbermotor = new TalonFX(83, "CANivore");
private final TalonFX climbermotor = new TalonFX(ClimberConstants.id, ClimberConstants.CANbus);
private final MotionMagicVoltage motionMagicVoltage = new MotionMagicVoltage(0);

public ClimberIOTalonFX() {
Expand All @@ -20,33 +20,47 @@ public ClimberIOTalonFX() {

TalonFXConfigurator talonConfig = climbermotor.getConfigurator();

SoftwareLimitSwitchConfigs softwareLimitSwitchConfigs = new SoftwareLimitSwitchConfigs();
SoftwareLimitSwitchConfigs softwareLimitSwitchConfigs =
new SoftwareLimitSwitchConfigs()
.withForwardSoftLimitEnable(true)
.withForwardSoftLimitThreshold(ClimberConstants.upperLimit)
.withReverseSoftLimitThreshold(ClimberConstants.lowerLimit)
.withReverseSoftLimitEnable(true);

talonConfig.apply(
new TalonFXConfiguration()
.withSoftwareLimitSwitch(softwareLimitSwitchConfigs)
.withSlot0(ClimberConstants.slot0Configs)
.withMotionMagic(ClimberConstants.motionMagicConfigs));
.withMotionMagic(ClimberConstants.motionMagicConfigs)
.withCurrentLimits(ClimberConstants.currentLimitsConfigs));

climbermotor.setControl(new Follower(climbermotor.getDeviceID(), false));
climbermotor.setNeutralMode(NeutralModeValue.Brake);
}

public void updateInputs(ClimberIOInputs inputs) {

inputs.position = climbermotor.getPosition().refresh().getValueAsDouble();
inputs.voltage = climbermotor.getMotorVoltage().refresh().getValueAsDouble();
inputs.speed = climbermotor.getVelocity().refresh().getValueAsDouble();
inputs.position = climbermotor.getPosition().getValueAsDouble();
inputs.voltage = climbermotor.getMotorVoltage().getValueAsDouble();
inputs.speed = climbermotor.getVelocity().getValueAsDouble();
inputs.temperature = climbermotor.getDeviceTemp().getValueAsDouble();
inputs.current = climbermotor.getStatorCurrent().getValueAsDouble();
}

public void setVoltage(double voltage) {
climbermotor.setVoltage(voltage);
}

public void setPosition(double position) {
if (position > ClimberConstants.upperLimit) {
position = ClimberConstants.upperLimit;
}
if (position < ClimberConstants.lowerLimit) {
position = ClimberConstants.lowerLimit;
}

climbermotor.setControl(motionMagicVoltage.withPosition(position));
}

public double getPosition() {
return climbermotor.getPosition().refresh().getValueAsDouble();
public void resetPosition(double position) {
climbermotor.setPosition(position);
}
}
Loading
Loading