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

Commit

Permalink
Replace two step handoff with direct conveyor<->queuer handoff
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahsnider committed Feb 24, 2024
1 parent 4d2d266 commit 5650533
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 63 deletions.
1 change: 1 addition & 0 deletions src/main/java/frc/robot/conveyor/ConveyorState.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public enum ConveyorState {
IDLE,
INTAKE_TO_SELF,
INTAKE_TO_QUEUER,
CONVEYOR_TO_QUEUER,
CONVEYOR_TO_INTAKE,
QUEUER_TO_INTAKE,
WAITING_AMP_SHOT,
Expand Down
1 change: 1 addition & 0 deletions src/main/java/frc/robot/conveyor/ConveyorSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void enabledPeriodic() {
motor.setVoltage(-3);
break;
case CONVEYOR_TO_INTAKE:
case CONVEYOR_TO_QUEUER:
motor.setVoltage(3);
break;
case AMP_SHOT:
Expand Down
90 changes: 41 additions & 49 deletions src/main/java/frc/robot/note_manager/NoteManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@ public void robotPeriodic() {
case AMP_WAIT:
if (state == NoteState.IDLE_IN_CONVEYOR) {
// Do nothing, you are already idling with the note in the conveyor
} else if (state == NoteState.QUEUER_TO_INTAKE_FOR_CONVEYOR_FINAL
|| state == NoteState.INTAKE_TO_CONVEYOR) {
} else if (state == NoteState.QUEUER_TO_CONVEYOR_FOR_IDLE) {
// Do nothing, we are already in the handoff process
} else {
state = NoteState.QUEUER_TO_INTAKE_FOR_CONVEYOR;
state = NoteState.QUEUER_TO_CONVEYOR_FOR_IDLE;
}
break;
case IDLE_IN_QUEUER:
if (state == NoteState.IDLE_IN_CONVEYOR) {
state = NoteState.CONVEYOR_TO_INTAKE_FOR_QUEUER_IDLE;
} else if (state == NoteState.CONVEYOR_TO_INTAKE_FOR_QUEUER_IDLE) {
state = NoteState.CONVEYOR_TO_QUEUER_FOR_IDLE;
} else if (state == NoteState.CONVEYOR_TO_QUEUER_FOR_IDLE) {
// Do nothing, we are already in the handoff process
} else {
state = NoteState.IDLE_IN_QUEUER;
state = NoteState.CONVEYOR_TO_QUEUER_FOR_IDLE;
}
break;
case IDLE_NO_GP:
Expand All @@ -78,14 +77,14 @@ public void robotPeriodic() {
break;
case SHOOTER_OUTTAKE:
if (state == NoteState.IDLE_IN_CONVEYOR) {
state = NoteState.CONVEYOR_TO_INTAKE_FOR_SHOOTER_OUTTAKE;
state = NoteState.CONVEYOR_TO_QUEUER_FOR_SHOOTER_OUTTAKE;
} else {
state = NoteState.SHOOTER_OUTTAKING;
}
break;
case SHOOTER_SCORE:
if (state == NoteState.IDLE_IN_CONVEYOR) {
state = NoteState.CONVEYOR_TO_INTAKE_FOR_SHOOTER_SCORE;
state = NoteState.CONVEYOR_TO_QUEUER_FOR_SHOOTER_SCORE;
} else {
state = NoteState.SHOOTING;
}
Expand Down Expand Up @@ -118,42 +117,36 @@ public void robotPeriodic() {
state = NoteState.IDLE_IN_QUEUER;
}
break;
case INTAKE_TO_CONVEYOR:
if (conveyor.hasNote() && !intake.hasNote()) {
state = NoteState.IDLE_IN_CONVEYOR;
}
break;
case QUEUER_TO_INTAKE_FOR_CONVEYOR:
if (intake.hasNote() && !queuer.hasNote()) {
state = NoteState.QUEUER_TO_INTAKE_FOR_CONVEYOR_FINAL;
case CONVEYOR_TO_INTAKE_FOR_OUTTAKING:
if (!conveyor.hasNote() && intake.hasNote()) {
state = NoteState.OUTTAKING;
}
break;
case QUEUER_TO_INTAKE_FOR_CONVEYOR_FINAL:
if (!intake.hasNote()) {
state = NoteState.INTAKE_TO_CONVEYOR;
case QUEUER_TO_INTAKE_FOR_OUTTAKING:
if (!queuer.hasNote() && intake.hasNote()) {
state = NoteState.OUTTAKING;
}
break;
case CONVEYOR_TO_INTAKE_FOR_OUTTAKING:
if (!conveyor.hasNote() && intake.hasNote()) {
state = NoteState.OUTTAKING;
case CONVEYOR_TO_QUEUER_FOR_IDLE:
if (!conveyor.hasNote() && queuer.hasNote()) {
state = NoteState.IDLE_IN_QUEUER;
}
break;
case CONVEYOR_TO_INTAKE_FOR_QUEUER_IDLE:
if (!conveyor.hasNote() && intake.hasNote()) {
state = NoteState.CONVEYOR_TO_INTAKE_FOR_QUEUER_IDLE_FINAL;
case CONVEYOR_TO_QUEUER_FOR_SHOOTER_OUTTAKE:
if (!conveyor.hasNote() && queuer.hasNote()) {
state = NoteState.SHOOTER_OUTTAKING;
}
break;
case CONVEYOR_TO_INTAKE_FOR_QUEUER_IDLE_FINAL:
if (!intake.hasNote()) {
state = NoteState.INTAKE_TO_QUEUER;
case CONVEYOR_TO_QUEUER_FOR_SHOOTER_SCORE:
if (!conveyor.hasNote() && queuer.hasNote()) {
state = NoteState.SHOOTING;
}
break;
case QUEUER_TO_INTAKE_FOR_OUTTAKING:
if (!queuer.hasNote() && intake.hasNote()) {
state = NoteState.OUTTAKING;
case QUEUER_TO_CONVEYOR_FOR_IDLE:
if (!queuer.hasNote() && conveyor.hasNote()) {
state = NoteState.IDLE_IN_CONVEYOR;
}
break;
// TODO: Fix missing states
default:
break;
}
Expand All @@ -180,28 +173,11 @@ public void robotPeriodic() {
queuer.setState(QueuerState.IDLE);
break;
case CONVEYOR_TO_INTAKE_FOR_OUTTAKING:
case CONVEYOR_TO_INTAKE_FOR_QUEUER_IDLE:
case CONVEYOR_TO_INTAKE_FOR_QUEUER_IDLE_FINAL:
intake.setState(IntakeState.FROM_CONVEYOR);
conveyor.setState(ConveyorState.CONVEYOR_TO_INTAKE);
queuer.setState(QueuerState.IDLE);
break;
case OUTTAKING:
intake.setState(IntakeState.OUTTAKING);
conveyor.setState(ConveyorState.QUEUER_TO_INTAKE);
queuer.setState(QueuerState.PASS_TO_INTAKE);
break;
case QUEUER_TO_INTAKE_FOR_CONVEYOR:
case QUEUER_TO_INTAKE_FOR_CONVEYOR_FINAL:
intake.setState(IntakeState.FROM_QUEUER);
conveyor.setState(ConveyorState.QUEUER_TO_INTAKE);
queuer.setState(QueuerState.PASS_TO_INTAKE);
break;
case INTAKE_TO_CONVEYOR:
intake.setState(IntakeState.TO_CONVEYOR);
conveyor.setState(ConveyorState.INTAKE_TO_SELF);
queuer.setState(QueuerState.IDLE);
break;
case QUEUER_TO_INTAKE_FOR_OUTTAKING:
intake.setState(IntakeState.OUTTAKING);
conveyor.setState(ConveyorState.QUEUER_TO_INTAKE);
Expand All @@ -217,6 +193,22 @@ public void robotPeriodic() {
conveyor.setState(ConveyorState.INTAKE_TO_QUEUER);
queuer.setState(QueuerState.PASS_TO_SHOOTER);
break;
case CONVEYOR_TO_QUEUER_FOR_IDLE:
intake.setState(IntakeState.IDLE);
conveyor.setState(ConveyorState.CONVEYOR_TO_QUEUER);
queuer.setState(QueuerState.INTAKING);
break;
case CONVEYOR_TO_QUEUER_FOR_SHOOTER_OUTTAKE:
case CONVEYOR_TO_QUEUER_FOR_SHOOTER_SCORE:
intake.setState(IntakeState.IDLE);
conveyor.setState(ConveyorState.CONVEYOR_TO_QUEUER);
queuer.setState(QueuerState.PASS_TO_SHOOTER);
break;
case QUEUER_TO_CONVEYOR_FOR_IDLE:
intake.setState(IntakeState.IDLE);
conveyor.setState(ConveyorState.INTAKE_TO_SELF);
queuer.setState(QueuerState.PASS_TO_CONVEYOR);
break;
default:
break;
}
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/frc/robot/note_manager/NoteState.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ public enum NoteState {
INTAKE_TO_QUEUER,
IDLE_IN_QUEUER,

CONVEYOR_TO_INTAKE_FOR_QUEUER_IDLE,
CONVEYOR_TO_INTAKE_FOR_QUEUER_IDLE_FINAL,
CONVEYOR_TO_INTAKE_FOR_SHOOTER_OUTTAKE,
CONVEYOR_TO_INTAKE_FOR_SHOOTER_SCORE,
CONVEYOR_TO_QUEUER_FOR_IDLE,
CONVEYOR_TO_QUEUER_FOR_SHOOTER_OUTTAKE,
CONVEYOR_TO_QUEUER_FOR_SHOOTER_SCORE,

SHOOTING,
SHOOTER_OUTTAKING,

QUEUER_TO_INTAKE_FOR_CONVEYOR,
QUEUER_TO_INTAKE_FOR_CONVEYOR_FINAL,
INTAKE_TO_CONVEYOR,
QUEUER_TO_CONVEYOR_FOR_IDLE,
IDLE_IN_CONVEYOR,

AMP_SCORING,
Expand Down
1 change: 1 addition & 0 deletions src/main/java/frc/robot/queuer/QueuerState.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public enum QueuerState {
IDLE,
INTAKING,
PASS_TO_SHOOTER,
PASS_TO_CONVEYOR,
PASS_TO_INTAKE;
}
1 change: 1 addition & 0 deletions src/main/java/frc/robot/queuer/QueuerSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void enabledPeriodic() {
}
break;
case PASS_TO_INTAKE:
case PASS_TO_CONVEYOR:
motor.setVoltage(-1);
break;
case PASS_TO_SHOOTER:
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/frc/robot/robot_manager/RobotManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,6 @@ public void robotPeriodic() {
climber.setGoalMode(ClimberMode.IDLE);
noteManager.idleNoGPRequest();
break;
case PREPARE_IDLE_WITH_GP_FROM_CONVEYOR:
wrist.setAngle(WristPositions.STOWED);
elevator.setGoalHeight(ElevatorPositions.STOWED);
shooter.setGoalMode(ShooterMode.IDLE);
climber.setGoalMode(ClimberMode.IDLE);
noteManager.ampWaitRequest();
break;
case IDLE_WITH_GP:
wrist.setAngle(wristAngleForSpeaker);
elevator.setGoalHeight(ElevatorPositions.STOWED);
Expand Down Expand Up @@ -425,6 +418,7 @@ public void robotPeriodic() {
snaps.setEnabled(true);
snaps.cancelCurrentCommand();
break;
case PREPARE_IDLE_WITH_GP_FROM_CONVEYOR:
case PREPARE_WAITING_AMP_SHOT:
wrist.setAngle(WristPositions.STOWED);
elevator.setGoalHeight(ElevatorPositions.STOWED);
Expand Down

0 comments on commit 5650533

Please sign in to comment.