Skip to content

Commit

Permalink
add the digital-input stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajwen61 committed Nov 29, 2023
1 parent 0617e12 commit 8650d5f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/java/frc/robot/subsystems/ElevatorSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.math.filter.LinearFilter;
import edu.wpi.first.wpilibj.DigitalInput;
// import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
Expand Down Expand Up @@ -63,6 +64,7 @@ public enum Modes {
// stator limits
private LinearFilter elevatorFilter;
private LinearFilter wristFilter;
private DigitalInput digitalinput;

public static record ElevatorState(double extension, double angle) {}

Expand All @@ -73,6 +75,7 @@ public ElevatorSubsystem() {
leftMotor = new TalonFX(Constants.Elevator.Ports.ELEVATOR_LEFT_MOTOR_PORT);
rightMotor = new TalonFX(Constants.Elevator.Ports.ELEVATOR_RIGHT_MOTOR_PORT);
wristMotor = new TalonFX(Constants.Elevator.Ports.WRIST_MOTOR_PORT);
TalonFX digitalinput = new TalonFX(2);

leftMotor.follow(rightMotor);

Expand Down Expand Up @@ -254,7 +257,7 @@ private double applySlowZoneToElevatorPercent(double elevatorPercentControl) {
}

private void percentDrivePeriodic() {
if (elevatorFilterOutput > Elevator.STATOR_LIMIT) {
if (elevatorFilterOutput > Elevator.STATOR_LIMIT || digitalinput.get()) {
rightMotor.set(TalonFXControlMode.PercentOutput, 0);
} else {
rightMotor.set(
Expand All @@ -269,6 +272,16 @@ private void percentDrivePeriodic() {
wristMotor.set(TalonFXControlMode.PercentOutput, MathUtil.clamp(wristPercentControl, -1, 1));
}
}
/*
public void autonomousPeriodic() {
// Runs the motor forwards at half speed, unless the limit is pressed
if(!limit.get()) {
spark.set(.5);
} else {
spark.set(0);
}
} */

private void positionDrivePeriodic() {
// if (filterOutput < statorCurrentLimit) {
Expand Down

0 comments on commit 8650d5f

Please sign in to comment.