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
+32
View File
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 121 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

@@ -8,16 +8,35 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc4388.robot.Constants.ClimberConstants; import frc4388.robot.Constants.ClimberConstants;
import com.ctre.phoenix.motorcontrol.LimitSwitchNormal;
import com.ctre.phoenix.motorcontrol.LimitSwitchSource;
public class Climber extends SubsystemBase { public class Climber extends SubsystemBase {
private WPI_TalonFX elbow; private WPI_TalonFX elbow;
/** Creates a new Climber */ /** Creates a new Climber */
public Climber(WPI_TalonFX elbow) { this.elbow = elbow; } public Climber(WPI_TalonFX elbow) {
this.elbow = elbow;
public void setEncoders(double value) { this.elbow.setSelectedSensorPosition(value); } elbow.configReverseLimitSwitchSource(LimitSwitchSource.FeedbackConnector, LimitSwitchNormal.NormallyOpen);
public double getCurrent() { return this.elbow.getSupplyCurrent(); } elbow.overrideLimitSwitchesEnable(true);
public void setMotors(double elbowOutput) { this.elbow.set(elbowOutput * ClimberConstants.INPUT_MULTIPLIER); }
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 @Override
public void periodic() {} public void periodic() {
}
} }