added limit switch and soft limit

-ryan
This commit is contained in:
nathanrsxtn
2022-03-24 06:53:40 -06:00
parent b17ab324e4
commit d11949bcae
3 changed files with 57 additions and 6 deletions
@@ -8,16 +8,35 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc4388.robot.Constants.ClimberConstants;
import com.ctre.phoenix.motorcontrol.LimitSwitchNormal;
import com.ctre.phoenix.motorcontrol.LimitSwitchSource;
public class Climber extends SubsystemBase {
private WPI_TalonFX elbow;
/** Creates a new Climber */
public Climber(WPI_TalonFX elbow) { this.elbow = elbow; }
public void setEncoders(double value) { this.elbow.setSelectedSensorPosition(value); }
public double getCurrent() { return this.elbow.getSupplyCurrent(); }
public void setMotors(double elbowOutput) { this.elbow.set(elbowOutput * ClimberConstants.INPUT_MULTIPLIER); }
public Climber(WPI_TalonFX elbow) {
this.elbow = elbow;
elbow.configReverseLimitSwitchSource(LimitSwitchSource.FeedbackConnector, LimitSwitchNormal.NormallyOpen);
elbow.overrideLimitSwitchesEnable(true);
elbow.configForwardSoftLimitThreshold(ClimberConstants.ELBOW_FORWARD_SOFT_LIMIT);
elbow.configForwardSoftLimitEnable(true);
}
public void setEncoders(double value) {
this.elbow.setSelectedSensorPosition(value);
}
public double getCurrent() {
return this.elbow.getSupplyCurrent();
}
public void setMotors(double elbowOutput) {
this.elbow.set(elbowOutput * ClimberConstants.INPUT_MULTIPLIER);
}
@Override
public void periodic() {}
public void periodic() {
}
}