mirror of
https://github.com/Team4388/2025RidgeScape.git
synced 2026-06-09 00:38:02 -06:00
Limit to beam break
Changed limit switch basin to beam break basin
This commit is contained in:
@@ -398,13 +398,14 @@ public final class Constants {
|
|||||||
public static final CanDevice ENDEFFECTOR_ID = new CanDevice("Endeffector", 15);
|
public static final CanDevice ENDEFFECTOR_ID = new CanDevice("Endeffector", 15);
|
||||||
public static final CanDevice ELEVATOR_ID = new CanDevice("Elevator", 16);
|
public static final CanDevice ELEVATOR_ID = new CanDevice("Elevator", 16);
|
||||||
|
|
||||||
public static final int BASIN_LIMIT_SWITCH = 0; // TODO: FIND
|
public static final int BASIN_LIMIT_SWITCH = 8; // TODO: FIND
|
||||||
public static final int ENDEFFECTOR_LIMIT_SWITCH = 1; // TODO: FIND
|
public static final int ENDEFFECTOR_LIMIT_SWITCH = 9; // TODO: FIND
|
||||||
|
|
||||||
public static final double GEAR_RATIO_ELEVATOR = 9.0;
|
public static final double GEAR_RATIO_ELEVATOR = -9.0;
|
||||||
|
|
||||||
public static final double GROUND_POSITION_ELEVATOR = 0 * GEAR_RATIO_ELEVATOR;
|
public static final double GROUND_POSITION_ELEVATOR = 0 * GEAR_RATIO_ELEVATOR;
|
||||||
public static final double WAITING_POSITION_ELEVATOR = 2 * GEAR_RATIO_ELEVATOR; // TODO: find 4-6 off the ground
|
public static final double WAITING_POSITION_ELEVATOR = 2 * GEAR_RATIO_ELEVATOR; // TODO: find 2-4 in off the pipe
|
||||||
|
public static final double WAITING_POSITION_BEAM_BREAK_ELEVATOR = 2 * GEAR_RATIO_ELEVATOR; // TODO: find on the pipe
|
||||||
public static final double MAX_POSITION_ELEVATOR = 4.5 * GEAR_RATIO_ELEVATOR; // TODO: find MAX position
|
public static final double MAX_POSITION_ELEVATOR = 4.5 * GEAR_RATIO_ELEVATOR; // TODO: find MAX position
|
||||||
|
|
||||||
public static final double GEAR_RATIO_ENDEFECTOR = 100.0;
|
public static final double GEAR_RATIO_ENDEFECTOR = 100.0;
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import com.ctre.phoenix6.controls.PositionVoltage;
|
|||||||
import com.ctre.phoenix6.hardware.TalonFX;
|
import com.ctre.phoenix6.hardware.TalonFX;
|
||||||
import com.ctre.phoenix6.signals.NeutralModeValue;
|
import com.ctre.phoenix6.signals.NeutralModeValue;
|
||||||
|
|
||||||
|
import edu.wpi.first.networktables.NetworkTable;
|
||||||
import edu.wpi.first.wpilibj.DigitalInput;
|
import edu.wpi.first.wpilibj.DigitalInput;
|
||||||
|
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
|
||||||
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
import frc4388.robot.Constants.ElevatorConstants;
|
import frc4388.robot.Constants.ElevatorConstants;
|
||||||
|
|
||||||
@@ -18,12 +21,13 @@ public class Elevator extends SubsystemBase {
|
|||||||
private TalonFX elevatorMotor;
|
private TalonFX elevatorMotor;
|
||||||
private TalonFX endefectorMotor;
|
private TalonFX endefectorMotor;
|
||||||
|
|
||||||
private DigitalInput basinLimitSwitch;
|
private DigitalInput basinBeamBreak;
|
||||||
private DigitalInput endefectorLimitSwitch;
|
private DigitalInput endefectorLimitSwitch;
|
||||||
|
|
||||||
public enum CoordinationState {
|
public enum CoordinationState {
|
||||||
Waiting, // for coral into the though
|
Waiting, // for coral into the though
|
||||||
Ready, // Has coral in enefector
|
WatingBeamTriped, //once the beam break trips
|
||||||
|
Ready, // Has coral in endefector
|
||||||
PrimedThree, // Arm and elevator Waiting to score in the level 3 position
|
PrimedThree, // Arm and elevator Waiting to score in the level 3 position
|
||||||
ScoringThree, // Arm and elevator in the level three position
|
ScoringThree, // Arm and elevator in the level three position
|
||||||
PrimedFour, // Arm and elevator Waiting to score in the level 4 position
|
PrimedFour, // Arm and elevator Waiting to score in the level 4 position
|
||||||
@@ -40,7 +44,7 @@ public class Elevator extends SubsystemBase {
|
|||||||
elevatorMotor = elevatorTalonFX;
|
elevatorMotor = elevatorTalonFX;
|
||||||
endefectorMotor = endefectorTalonFX;
|
endefectorMotor = endefectorTalonFX;
|
||||||
|
|
||||||
this.basinLimitSwitch = basinLimitSwitch;
|
this.basinBeamBreak = basinLimitSwitch;
|
||||||
this.endefectorLimitSwitch = endefectorLimitSwitch;
|
this.endefectorLimitSwitch = endefectorLimitSwitch;
|
||||||
|
|
||||||
elevatorMotor.setNeutralMode(NeutralModeValue.Brake);
|
elevatorMotor.setNeutralMode(NeutralModeValue.Brake);
|
||||||
@@ -75,6 +79,12 @@ public class Elevator extends SubsystemBase {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WatingBeamTriped: {
|
||||||
|
PIDPosition(elevatorMotor, ElevatorConstants.WAITING_POSITION_BEAM_BREAK_ELEVATOR);
|
||||||
|
PIDPosition(endefectorMotor, ElevatorConstants.COMPLETLY_DOWN_ENDEFECTOR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case Ready: {
|
case Ready: {
|
||||||
PIDPosition(elevatorMotor, ElevatorConstants.GROUND_POSITION_ELEVATOR);
|
PIDPosition(elevatorMotor, ElevatorConstants.GROUND_POSITION_ELEVATOR);
|
||||||
PIDPosition(endefectorMotor, ElevatorConstants.COMPLETLY_DOWN_ENDEFECTOR);
|
PIDPosition(endefectorMotor, ElevatorConstants.COMPLETLY_DOWN_ENDEFECTOR);
|
||||||
@@ -97,7 +107,11 @@ public class Elevator extends SubsystemBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void periodicWaiting() {
|
private void periodicWaiting() {
|
||||||
if (basinLimitSwitch.get()) transitionState(CoordinationState.Ready);
|
if (basinBeamBreak.get()) transitionState(CoordinationState.WatingBeamTriped);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void periodicWaitingTripped() {
|
||||||
|
if (basinBeamBreak.get()) transitionState(CoordinationState.Ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void periodicScoring() {
|
private void periodicScoring() {
|
||||||
@@ -107,8 +121,13 @@ public class Elevator extends SubsystemBase {
|
|||||||
@Override
|
@Override
|
||||||
public void periodic() {
|
public void periodic() {
|
||||||
// This method will be called once per scheduler run
|
// This method will be called once per scheduler run
|
||||||
// if (currentState == CoordinationState.Waiting) {
|
SmartDashboard.putNumber("Basin", basinBeamBreak.get() ? 1 : 0);
|
||||||
// periodicWaiting();
|
SmartDashboard.putNumber("endefector", basinBeamBreak.get() ? 1 : 0);
|
||||||
|
if (currentState == CoordinationState.Waiting) {
|
||||||
|
periodicWaiting();
|
||||||
|
} else if (currentState == CoordinationState.WatingBeamTriped) {
|
||||||
|
periodicWaitingTripped();
|
||||||
|
}
|
||||||
// } else if (currentState == CoordinationState.ScoringThree || currentState == CoordinationState.ScoringFour) {
|
// } else if (currentState == CoordinationState.ScoringThree || currentState == CoordinationState.ScoringFour) {
|
||||||
// periodicScoring();
|
// periodicScoring();
|
||||||
// }
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user