Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public final class Constants {

public static final double ELEVATOR_DEADBAND_VALUE = .6;
public static final double maxElevatorMotorSpeed = 0.3; //Normally .2
public static final double ELEVATOR_SPEED_MOD_REDUCED = 0.5;


public static final double MINIMUM_ELEVATOR_POSITION = 2.2;
public static final double restElevatorTargetPosition = 10.6;
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/frc/robot/subsystems/ElevatorSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public class ElevatorSubsystem extends SubsystemBase {
public double newPower;

public DigitalInput elevatorLimitSwitch;

public int previousDirection;

public double elevatorSpeedMod = 1;

public ElevatorSubsystem(ClawIntakeSubsystem intake)
{
Expand Down Expand Up @@ -70,6 +74,7 @@ public ElevatorSubsystem(ClawIntakeSubsystem intake)

public void setTargetPosition(double newTargetPosition, String reason) {
targetPosition = newTargetPosition;
previousDirection = (int) (Math.signum(targetPosition - potentiometer.get()));
}

private double getCappedPower(double desired)
Expand All @@ -86,6 +91,8 @@ public void setSpeed(double newSpeed) {

speed *= Constants.maxElevatorMotorSpeed;

speed *= elevatorSpeedMod;

speed = getCappedPower(speed);

double currentPower = elevatorMotorMain.get();
Expand Down Expand Up @@ -131,13 +138,22 @@ public void periodic() {
}
else {
setSpeed(0);
elevatorSpeedMod = 1;
}
}


if(previousDirection != Math.signum(targetPosition - potentiometer.get())) {
previousDirection = (int) (Math.signum(targetPosition - potentiometer.get()));
elevatorSpeedMod = Constants.ELEVATOR_SPEED_MOD_REDUCED;
}

if(potentiometer.get() < Constants.clawCloseThreshold && !clawThresholdOverridden
&& intake.clawGrabberLeft.get() != Value.kReverse && Robot.isEnabled)
intake.setSolenoid(Value.kReverse);




}

public boolean isInTarget() {
Expand Down