Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
remove ntPositions from climber and elevator
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen756 committed Feb 23, 2024
1 parent af79a70 commit f39c024
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
9 changes: 1 addition & 8 deletions src/main/java/frc/robot/climber/ClimberSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
import frc.robot.util.scheduling.LifecycleSubsystem;
import frc.robot.util.scheduling.SubsystemPriority;
import org.littletonrobotics.junction.Logger;
import org.littletonrobotics.junction.networktables.LoggedDashboardNumber;

public class ClimberSubsystem extends LifecycleSubsystem {
private static final ClimberConfig CONFIG = RobotConfig.get().climber();
private final TalonFX leftMotor;
private final TalonFX rightMotor;
private StrictFollower followRequest;
private LinearFilter currentFilter = LinearFilter.movingAverage(CONFIG.currentTaps());
private final LoggedDashboardNumber ntDistance =
new LoggedDashboardNumber("Climber/PositionOverride", -1);
private double goalDistance = 0.0;
private PositionVoltage positionRequest = new PositionVoltage(goalDistance);
private VoltageOut voltageRequest = new VoltageOut(0.0);
Expand Down Expand Up @@ -88,12 +85,8 @@ public void robotPeriodic() {
default:
break;
}
double usedGoalDistance = clamp(ntDistance.get() == -1 ? goalDistance : ntDistance.get());

Logger.recordOutput("Climber/UsedGoalDistance", usedGoalDistance);

leftMotor.setControl(
positionRequest.withPosition(inchesToRotations(usedGoalDistance).getRotations()));
positionRequest.withPosition(inchesToRotations(clamp(goalDistance)).getRotations()));
rightMotor.setControl(followRequest);

break;
Expand Down
24 changes: 8 additions & 16 deletions src/main/java/frc/robot/elevator/ElevatorSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
import frc.robot.util.scheduling.LifecycleSubsystem;
import frc.robot.util.scheduling.SubsystemPriority;
import org.littletonrobotics.junction.Logger;
import org.littletonrobotics.junction.networktables.LoggedDashboardNumber;

public class ElevatorSubsystem extends LifecycleSubsystem {
private final TalonFX motor;

private final StaticBrake brakeNeutralRequest = new StaticBrake();
private final CoastOut coastNeutralRequest = new CoastOut();
private final PositionVoltage positionRequest = new PositionVoltage(ElevatorPositions.STOWED);
private final LoggedDashboardNumber ntDistance =
new LoggedDashboardNumber("Elevator/DistanceOverride", -1);

// Homing
private boolean preMatchHomingOccured = false;
Expand Down Expand Up @@ -74,19 +71,14 @@ public void robotPeriodic() {
}
break;
case HOMED:
{
double usedGoalPosition =
clampHeight(ntDistance.get() == -1 ? goalHeight : ntDistance.get());
int slot = goalHeight == RobotConfig.get().elevator().minHeight() ? 1 : 0;
Logger.recordOutput("Elevator/UsedGoalPosition", usedGoalPosition);

motor.setControl(
positionRequest
.withSlot(slot)
.withPosition(inchesToRotations(usedGoalPosition).getRotations()));

break;
}
int slot = goalHeight == RobotConfig.get().elevator().minHeight() ? 1 : 0;

motor.setControl(
positionRequest
.withSlot(slot)
.withPosition(inchesToRotations(clampHeight(goalHeight)).getRotations()));

break;
case MID_MATCH_HOMING:
throw new IllegalStateException("Elevator can't do mid match homing");
}
Expand Down

0 comments on commit f39c024

Please sign in to comment.