Skip to content

Commit 5400f94

Browse files
authored
Merge pull request #67 from strykeforce/statesHotfixes
States hotfixes
2 parents d35b0e1 + e48835a commit 5400f94

21 files changed

+165
-86
lines changed

src/main/java/frc/robot/Robot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void robotPeriodic() {
6161

6262
@Override
6363
public void disabledInit() {
64-
m_robotContainer.stopTagAlign();
64+
m_robotContainer.stopTagAlignAndPathHandler();
6565
}
6666

6767
@Override

src/main/java/frc/robot/RobotContainer.java

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import edu.wpi.first.wpilibj2.command.InstantCommand;
2121
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
2222
import edu.wpi.first.wpilibj2.command.button.Trigger;
23+
import frc.robot.commands.algae.EjectAlgaeCommand;
2324
import frc.robot.commands.algae.IntakeAlgaeCommand;
2425
import frc.robot.commands.algae.OpenLoopAlgaeCommand;
2526
import frc.robot.commands.algae.ProcessorAlgaeCommand;
@@ -361,10 +362,13 @@ private void configureDriverBindings() {
361362

362363
new JoystickButton(driveJoystick, Button.M_SWE.id)
363364
.onTrue(
365+
// new ScoreAlgaeCommand(
366+
// robotStateSubsystem, elevatorSubsystem, biscuitSubsystem, algaeSubsystem));
364367
new ForceBargeCommand(
365-
robotStateSubsystem, elevatorSubsystem, biscuitSubsystem, algaeSubsystem));
366-
// new ForceBargeCommand(
367-
// robotStateSubsystem, elevatorSubsystem, biscuitSubsystem, algaeSubsystem)); // for easy
368+
robotStateSubsystem,
369+
elevatorSubsystem,
370+
biscuitSubsystem,
371+
algaeSubsystem)); // for easy
368372
// swapping
369373
Command floorAlgaeCommand =
370374
// new FloorAlgaeCommand(
@@ -439,29 +443,32 @@ private void configureOperatorBindings() {
439443
new Trigger(() -> robotStateSubsystem.isStuckAndMisaligned())
440444
.onTrue(new OperatorRumbleCommand(robotStateSubsystem, xboxController));
441445

442-
// Move biscuit
443-
new Trigger((() -> xboxController.getRightY() < -RobotConstants.kTestingDeadband))
444-
.onTrue(
445-
new JogBiscuitCommand(
446-
biscuitSubsystem, Angle.ofBaseUnits(BiscuitConstants.kJogAmountUp, Rotations)))
447-
.onFalse(new HoldBiscuitCommand(biscuitSubsystem));
448-
new Trigger((() -> xboxController.getRightY() > RobotConstants.kTestingDeadband))
449-
.onTrue(
450-
new JogBiscuitCommand(
451-
biscuitSubsystem, Angle.ofBaseUnits(BiscuitConstants.kJogAmountDown, Rotations)))
452-
.onFalse(new HoldBiscuitCommand(biscuitSubsystem));
453-
454-
// Move elevator
455-
new Trigger((() -> xboxController.getLeftY() < -RobotConstants.kTestingDeadband))
456-
.onTrue(
457-
new JogElevatorCommand(
458-
elevatorSubsystem, Angle.ofBaseUnits(ElevatorConstants.kJogAmountUp, Rotations)))
459-
.onFalse(new HoldElevatorCommand(elevatorSubsystem));
460-
new Trigger((() -> xboxController.getLeftY() > RobotConstants.kTestingDeadband))
461-
.onTrue(
462-
new JogElevatorCommand(
463-
elevatorSubsystem, Angle.ofBaseUnits(ElevatorConstants.kJogAmountDown, Rotations)))
464-
.onFalse(new HoldElevatorCommand(elevatorSubsystem));
446+
new Trigger(() -> xboxController.getPOV() != -1).onTrue(new EjectAlgaeCommand(algaeSubsystem));
447+
448+
// // Move biscuit
449+
// new Trigger((() -> xboxController.getRightY() < -RobotConstants.kTestingDeadband))
450+
// .onTrue(
451+
// new JogBiscuitCommand(
452+
// biscuitSubsystem, Angle.ofBaseUnits(BiscuitConstants.kJogAmountUp, Rotations)))
453+
// .onFalse(new HoldBiscuitCommand(biscuitSubsystem));
454+
// new Trigger((() -> xboxController.getRightY() > RobotConstants.kTestingDeadband))
455+
// .onTrue(
456+
// new JogBiscuitCommand(
457+
// biscuitSubsystem, Angle.ofBaseUnits(BiscuitConstants.kJogAmountDown, Rotations)))
458+
// .onFalse(new HoldBiscuitCommand(biscuitSubsystem));
459+
460+
// // Move elevator
461+
// new Trigger((() -> xboxController.getLeftY() < -RobotConstants.kTestingDeadband))
462+
// .onTrue(
463+
// new JogElevatorCommand(
464+
// elevatorSubsystem, Angle.ofBaseUnits(ElevatorConstants.kJogAmountUp, Rotations)))
465+
// .onFalse(new HoldElevatorCommand(elevatorSubsystem));
466+
// new Trigger((() -> xboxController.getLeftY() > RobotConstants.kTestingDeadband))
467+
// .onTrue(
468+
// new JogElevatorCommand(
469+
// elevatorSubsystem, Angle.ofBaseUnits(ElevatorConstants.kJogAmountDown,
470+
// Rotations)))
471+
// .onFalse(new HoldElevatorCommand(elevatorSubsystem));
465472
}
466473

467474
private void configureTestOperatorBindings() {
@@ -801,8 +808,9 @@ public Command getAutonomousCommand() {
801808
return Commands.print("No autonomous command configured");
802809
}
803810

804-
public void stopTagAlign() {
811+
public void stopTagAlignAndPathHandler() {
805812
tagAlignSubsystem.terminate();
813+
pathHandler.killPathHandler();
806814
}
807815

808816
public void setIsAuto(boolean isAuto) {
@@ -830,8 +838,8 @@ public void updateCanivoreStatus() {
830838
}
831839

832840
public void updateCANErrorCount() {
833-
rCanErrors = RobotController.getCANStatus().receiveErrorCount;
834-
tCanErrors = RobotController.getCANStatus().transmitErrorCount;
841+
rCanErrors += RobotController.getCANStatus().receiveErrorCount;
842+
tCanErrors += RobotController.getCANStatus().transmitErrorCount;
835843
}
836844

837845
public void disableNoMotionCal() {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package frc.robot.commands.algae;
2+
3+
import edu.wpi.first.wpilibj2.command.InstantCommand;
4+
import frc.robot.subsystems.algae.AlgaeSubsystem;
5+
6+
public class EjectAlgaeCommand extends InstantCommand {
7+
private AlgaeSubsystem algaeSubsystem;
8+
9+
public EjectAlgaeCommand(AlgaeSubsystem algaeSubsystem) {
10+
this.algaeSubsystem = algaeSubsystem;
11+
addRequirements(algaeSubsystem);
12+
}
13+
14+
@Override
15+
public void initialize() {
16+
algaeSubsystem.scoreProcessor();
17+
}
18+
}

src/main/java/frc/robot/commands/drive/DriveAutonCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public boolean isFinished() {
153153
return true;
154154
}
155155
return (timer.hasElapsed(trajectory.getTotalTime() + AutonConstants.kAutoTimeout)
156-
|| (FastMath.sqrtQuick(
156+
|| (Math.sqrt(
157157
FastMath.pow2(driveSubsystem.getPoseMeters().getX() - finalPose.getX())
158158
+ FastMath.pow2((driveSubsystem.getPoseMeters().getY() - finalPose.getY())))
159159
< AutonConstants.kMaxPathErrorMeters)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package frc.robot.commands.robotState;
2+
3+
import edu.wpi.first.wpilibj2.command.InstantCommand;
4+
import frc.robot.subsystems.algae.AlgaeSubsystem;
5+
import frc.robot.subsystems.robotState.RobotStateSubsystem;
6+
7+
public class EjectAlgaeCommand extends InstantCommand {
8+
private AlgaeSubsystem algaeSubsystem;
9+
private RobotStateSubsystem robotStateSubsystem;
10+
11+
public EjectAlgaeCommand(AlgaeSubsystem algaeSubsystem, RobotStateSubsystem robotStateSubsystem) {
12+
this.algaeSubsystem = algaeSubsystem;
13+
this.robotStateSubsystem = robotStateSubsystem;
14+
15+
addRequirements(algaeSubsystem);
16+
}
17+
18+
public void initialize() {
19+
robotStateSubsystem.releaseAlgae();
20+
}
21+
}

src/main/java/frc/robot/commands/robotState/ForceBargeCommand.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public ForceBargeCommand(
2828

2929
@Override
3030
public void initialize() {
31+
hasEjectedToBarge = false;
3132
startState = robotStateSubsystem.getState();
3233
startingElevatorFinished = elevatorSubsystem.isFinished();
3334
robotStateSubsystem.setAlgaeHeight(AlgaeHeight.HIGH);
@@ -38,16 +39,21 @@ public void initialize() {
3839

3940
@Override
4041
public boolean isFinished() {
41-
if (startState == RobotStates.PROCESSOR_ALGAE || hasEjectedToBarge) {
42+
if (startState == RobotStates.PROCESSOR_ALGAE
43+
|| startState == RobotStates.BARGE_ALGAE
44+
|| hasEjectedToBarge) {
4245
return robotStateSubsystem.getState() == RobotStates.FUNNEL_LOAD
4346
|| robotStateSubsystem.getState() == RobotStates.STOW
4447
|| !startingElevatorFinished;
45-
} else if (robotStateSubsystem.getState() == RobotStates.BARGE_ALGAE) {
48+
} else if (robotStateSubsystem.getState() == RobotStates.BARGE_ALGAE
49+
&& robotStateSubsystem.getIsAutoPlacing()) {
4650
hasEjectedToBarge = true;
51+
return false;
4752
} else {
4853
return robotStateSubsystem.getState() == RobotStates.PROCESSOR_ALGAE
54+
|| (robotStateSubsystem.getState() == RobotStates.BARGE_ALGAE
55+
&& !robotStateSubsystem.getIsAutoPlacing())
4956
|| !robotStateSubsystem.getIsBargeSafe();
5057
}
51-
return false;
5258
}
5359
}

src/main/java/frc/robot/commands/robotState/ForceProcessorCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public ForceProcessorCommand(
2828

2929
@Override
3030
public void initialize() {
31+
hasEjectedToBarge = false;
3132
startState = robotStateSubsystem.getState();
3233
startingElevatorFinished = elevatorSubsystem.isFinished();
3334
robotStateSubsystem.setAlgaeHeight(AlgaeHeight.LOW);

src/main/java/frc/robot/commands/robotState/ScoreAlgaeCommand.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ public ScoreAlgaeCommand(
2626

2727
@Override
2828
public void initialize() {
29+
hasEjectedToBarge = false;
2930
startState = robotStateSubsystem.getState();
3031
startingElevatorFinished = elevatorSubsystem.isFinished();
31-
if (startState == RobotStates.PROCESSOR_ALGAE) {
32+
if (startState == RobotStates.PROCESSOR_ALGAE || startState == RobotStates.BARGE_ALGAE) {
3233
robotStateSubsystem.releaseAlgae();
3334
} else {
3435
robotStateSubsystem.toScoreAlgae();
@@ -37,14 +38,19 @@ public void initialize() {
3738

3839
@Override
3940
public boolean isFinished() {
40-
if (startState == RobotStates.PROCESSOR_ALGAE || hasEjectedToBarge) {
41+
if (startState == RobotStates.PROCESSOR_ALGAE
42+
|| startState == RobotStates.BARGE_ALGAE
43+
|| hasEjectedToBarge) {
4144
return robotStateSubsystem.getState() == RobotStates.FUNNEL_LOAD
4245
|| robotStateSubsystem.getState() == RobotStates.STOW
4346
|| !startingElevatorFinished;
44-
} else if (robotStateSubsystem.getState() == RobotStates.BARGE_ALGAE) {
47+
} else if (robotStateSubsystem.getState() == RobotStates.BARGE_ALGAE
48+
&& robotStateSubsystem.getIsAutoPlacing()) {
4549
hasEjectedToBarge = true;
4650
} else {
4751
return robotStateSubsystem.getState() == RobotStates.PROCESSOR_ALGAE
52+
|| (robotStateSubsystem.getState() == RobotStates.BARGE_ALGAE
53+
&& !robotStateSubsystem.getIsAutoPlacing())
4854
|| !robotStateSubsystem.getIsBargeSafe();
4955
}
5056
return false;

src/main/java/frc/robot/constants/AlgaeConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class AlgaeConstants {
3232
public static final double kIntakingSpeed = -1;
3333

3434
public static final double kHasAlgaeVelThreshold = 10;
35-
public static final double kSuperCycleHasAlgaeVelThres = 50; // was 40
35+
public static final double kSuperCycleHasAlgaeVelThres = 40; // was 40
3636
public static final int kHasAlgaeCounts = 2;
3737

3838
public static final double kHasCoralVelThreshold = 70; // FIXME

src/main/java/frc/robot/constants/ClimbConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class ClimbConstants {
6363
public static final double kCloseEnoughX = 0.1;
6464
public static final double kCloseEnoughY = 0.03;
6565
public static final double kClimbAngleGood = RobotStateConstants.kClimbAngleSmall;
66-
public static final double kFastClimbAfter = 3.5;
66+
public static final double kFastClimbAt = 4.01;
6767

6868
public static TalonFXConfiguration getPivotArmFxConfig() {
6969
TalonFXConfiguration armFxConfig = new TalonFXConfiguration();

0 commit comments

Comments
 (0)