-
Notifications
You must be signed in to change notification settings - Fork 0
Algae Commands #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Algae Commands #17
Changes from 13 commits
6458b12
24d64e7
bf36334
9be26f9
2175ebf
6842f2c
ec764d9
d88d93b
0f9d7db
d906247
63e618f
360cda7
47684bf
5720832
7592057
9537d3e
60688dd
a4c41fa
0f94518
ee10305
9a35efc
c653954
d58b841
02f4c91
28ab418
f6042fb
95e944b
20ce80e
f59a54d
2799d9c
8c79424
3b97a1b
0f756d2
e452d1b
e942e88
dd399f0
b9fc291
3ac3afb
eba36bb
6e36c6f
ee1ae18
bc006a4
4eff751
7ff39e8
202c4bd
5861571
a49c49f
6662ca8
2e4beb9
62dd446
cf9ddea
4122b01
c6ddc98
8c05c04
d8947fd
7323b27
64db523
3e7189a
7cdf12c
0a34c02
8491f00
fbedb8f
0fc0c01
a65a34b
01e7b00
07840d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,218 @@ | ||||||||||||||
| package frc.trigon.robot.commands.commandfactories; | ||||||||||||||
|
|
||||||||||||||
| import edu.wpi.first.math.controller.PIDController; | ||||||||||||||
| import edu.wpi.first.math.geometry.Pose2d; | ||||||||||||||
| import edu.wpi.first.math.geometry.Rotation2d; | ||||||||||||||
| import edu.wpi.first.math.geometry.Transform2d; | ||||||||||||||
| import edu.wpi.first.math.geometry.Translation2d; | ||||||||||||||
| import edu.wpi.first.wpilibj2.command.*; | ||||||||||||||
| import frc.trigon.robot.RobotContainer; | ||||||||||||||
| import frc.trigon.robot.commands.CommandConstants; | ||||||||||||||
| import frc.trigon.robot.commands.commandclasses.WaitUntilChangeCommand; | ||||||||||||||
| import frc.trigon.robot.constants.AutonomousConstants; | ||||||||||||||
| import frc.trigon.robot.constants.FieldConstants; | ||||||||||||||
| import frc.trigon.robot.constants.LEDConstants; | ||||||||||||||
| import frc.trigon.robot.constants.OperatorConstants; | ||||||||||||||
| import frc.trigon.robot.subsystems.arm.ArmCommands; | ||||||||||||||
| import frc.trigon.robot.subsystems.arm.ArmConstants; | ||||||||||||||
| import frc.trigon.robot.subsystems.elevator.ElevatorCommands; | ||||||||||||||
| import frc.trigon.robot.subsystems.elevator.ElevatorConstants; | ||||||||||||||
| import frc.trigon.robot.subsystems.swerve.SwerveCommands; | ||||||||||||||
| import lib.hardware.RobotHardwareStats; | ||||||||||||||
| import lib.hardware.misc.leds.LEDCommands; | ||||||||||||||
| import lib.utilities.flippable.FlippablePose2d; | ||||||||||||||
| import lib.utilities.flippable.FlippableRotation2d; | ||||||||||||||
| import lib.utilities.flippable.FlippableTranslation2d; | ||||||||||||||
|
|
||||||||||||||
| import java.util.List; | ||||||||||||||
| import java.util.Map; | ||||||||||||||
|
|
||||||||||||||
| public class AlgaeManipulationCommands { | ||||||||||||||
| private static boolean | ||||||||||||||
| IS_HOLDING_ALGAE = false, | ||||||||||||||
| SHOULD_COLLECT_FROM_LOLLIPOP = false; | ||||||||||||||
| private static final PIDController ALIGN_TO_REEF_Y_CONTROLLER = | ||||||||||||||
| RobotHardwareStats.isSimulation() ? | ||||||||||||||
| new PIDController(3, 0, 0) : | ||||||||||||||
| new PIDController(3, 0, 0); | ||||||||||||||
|
|
||||||||||||||
| public static boolean isHoldingAlgae() { | ||||||||||||||
| return IS_HOLDING_ALGAE; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| public static void toggleLollipopCollection() { | ||||||||||||||
| SHOULD_COLLECT_FROM_LOLLIPOP = !SHOULD_COLLECT_FROM_LOLLIPOP; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| public static Command getFloorAlgaeCollectionCommand() { | ||||||||||||||
| return new SequentialCommandGroup( | ||||||||||||||
| GeneralCommands.getResetFlipArmOverrideCommand(), | ||||||||||||||
| new InstantCommand(() -> IS_HOLDING_ALGAE = true), | ||||||||||||||
| CoralCollectionCommands.getUnloadCoralCommand().onlyIf(RobotContainer.ARM::hasGamePiece), | ||||||||||||||
| getInitiateReefAlgaeCollectionCommand().until(RobotContainer.ARM::hasGamePiece), | ||||||||||||||
| new InstantCommand(() -> getScoreAlgaeCommand().schedule()).alongWith(getAlgaeCollectionConfirmationCommand()) | ||||||||||||||
| ).finallyDo(() -> IS_HOLDING_ALGAE = false); | ||||||||||||||
| } | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| public static Command getReefAlgaeCollectionCommand() { | ||||||||||||||
| return new SequentialCommandGroup( | ||||||||||||||
| GeneralCommands.getResetFlipArmOverrideCommand(), | ||||||||||||||
| new InstantCommand(() -> IS_HOLDING_ALGAE = true), | ||||||||||||||
| CoralCollectionCommands.getUnloadCoralCommand().onlyIf(RobotContainer.ARM::hasGamePiece), | ||||||||||||||
| getInitiateReefAlgaeCollectionCommand().until(RobotContainer.ARM::hasGamePiece), | ||||||||||||||
| getScoreAlgaeCommand().alongWith(getAlgaeCollectionConfirmationCommand()) | ||||||||||||||
Strflightmight09 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
| ).alongWith(getAlignToReefCommand()).finallyDo(() -> IS_HOLDING_ALGAE = false); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static Command getAlignToReefCommand() { | ||||||||||||||
| return new SequentialCommandGroup( | ||||||||||||||
| SwerveCommands.getDriveToPoseCommand( | ||||||||||||||
| AlgaeManipulationCommands::calculateClosestAlgaeCollectionPose, | ||||||||||||||
| AutonomousConstants.DRIVE_TO_REEF_CONSTRAINTS | ||||||||||||||
| ), | ||||||||||||||
| SwerveCommands.getClosedLoopSelfRelativeDriveCommand( | ||||||||||||||
| () -> fieldRelativePowersToSelfRelativeXPower(OperatorConstants.DRIVER_CONTROLLER.getLeftY(), OperatorConstants.DRIVER_CONTROLLER.getLeftX()), | ||||||||||||||
| () -> ALIGN_TO_REEF_Y_CONTROLLER.calculate(calculateReefRelativeYOffset()), | ||||||||||||||
| () -> calculateClosestAlgaeCollectionPose().getRotation() | ||||||||||||||
| ) | ||||||||||||||
| ).raceWith( | ||||||||||||||
| new WaitCommand(1).andThen(new WaitUntilCommand(RobotContainer.ARM::hasGamePiece)), | ||||||||||||||
| new WaitUntilCommand(OperatorConstants.STOP_REEF_ALGAE_ALIGN_TRIGGER) | ||||||||||||||
| ).onlyIf(() -> CoralPlacingCommands.SHOULD_SCORE_AUTONOMOUSLY).asProxy(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static Command getScoreAlgaeCommand() { | ||||||||||||||
| return new SelectCommand<>( | ||||||||||||||
| Map.of( | ||||||||||||||
| 0, getHoldAlgaeCommand(), | ||||||||||||||
| 1, getScoreInNetCommand(), | ||||||||||||||
| 2, getScoreInProcessorCommand() | ||||||||||||||
| ), | ||||||||||||||
| AlgaeManipulationCommands::getAlgaeScoreMethodSelector | ||||||||||||||
| ).raceWith(new WaitUntilChangeCommand<>(AlgaeManipulationCommands::isScoreAlgaeButtonPressed)).repeatedly().until(() -> !RobotContainer.ARM.hasGamePiece() && !isScoreAlgaeButtonPressed()); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static Command getHoldAlgaeCommand() { | ||||||||||||||
| return new ParallelCommandGroup( | ||||||||||||||
| ArmCommands.getSetTargetStateCommand(ArmConstants.ArmState.HOLD_ALGAE), | ||||||||||||||
| ElevatorCommands.getSetTargetStateCommand(ElevatorConstants.ElevatorState.REST_WITH_ALGAE) | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static Command getScoreInNetCommand() { | ||||||||||||||
| return new ParallelRaceGroup( | ||||||||||||||
| ElevatorCommands.getSetTargetStateCommand(ElevatorConstants.ElevatorState.SCORE_NET), | ||||||||||||||
| getArmScoringSequenceCommand(ArmConstants.ArmState.SCORE_NET, shouldReverseNetScore()), | ||||||||||||||
| SwerveCommands.getClosedLoopFieldRelativeDriveCommand( | ||||||||||||||
| () -> CommandConstants.calculateDriveStickAxisValue(OperatorConstants.DRIVER_CONTROLLER.getLeftY()), | ||||||||||||||
| () -> CommandConstants.calculateDriveStickAxisValue(OperatorConstants.DRIVER_CONTROLLER.getLeftX()), | ||||||||||||||
| () -> new FlippableRotation2d(shouldReverseNetScore() ? Rotation2d.kZero : Rotation2d.k180deg, true) | ||||||||||||||
| ).asProxy().onlyWhile(() -> CoralPlacingCommands.SHOULD_SCORE_AUTONOMOUSLY) | ||||||||||||||
| ); | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static Command getScoreInProcessorCommand() { | ||||||||||||||
| return new ParallelRaceGroup( | ||||||||||||||
| ElevatorCommands.getSetTargetStateCommand(ElevatorConstants.ElevatorState.SCORE_PROCESSOR), | ||||||||||||||
| getArmScoringSequenceCommand(ArmConstants.ArmState.SCORE_PROCESSOR, false), | ||||||||||||||
| SwerveCommands.getDriveToPoseCommand( | ||||||||||||||
| () -> FieldConstants.FLIPPABLE_PROCESSOR_SCORE_POSE, | ||||||||||||||
| AutonomousConstants.DRIVE_TO_REEF_CONSTRAINTS | ||||||||||||||
| ).until(() -> RobotContainer.SWERVE.atPose(FieldConstants.FLIPPABLE_PROCESSOR_SCORE_POSE)) | ||||||||||||||
| .asProxy().onlyWhile(() -> CoralPlacingCommands.SHOULD_SCORE_AUTONOMOUSLY) | ||||||||||||||
| ); | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static Command getArmScoringSequenceCommand(ArmConstants.ArmState scoreState, boolean shouldReverseScore) { | ||||||||||||||
| return new SequentialCommandGroup( | ||||||||||||||
| ArmCommands.getPrepareForStateCommand(scoreState, shouldReverseScore).until(OperatorConstants.CONTINUE_TRIGGER), | ||||||||||||||
| ArmCommands.getSetTargetStateCommand(scoreState, shouldReverseScore) | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private static int getAlgaeScoreMethodSelector() { | ||||||||||||||
| if (OperatorConstants.SCORE_ALGAE_IN_NET_TRIGGER.getAsBoolean()) | ||||||||||||||
| return 1; | ||||||||||||||
| if (OperatorConstants.SCORE_ALGAE_IN_PROCESSOR_TRIGGER.getAsBoolean()) | ||||||||||||||
| return 2; | ||||||||||||||
| return 0; | ||||||||||||||
| } | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| private static boolean shouldReverseNetScore() {//TODO: Implement | ||||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
|
||||||||||||||
| private static boolean shouldReverseNetScore() {//TODO: Implement | |
| return false; | |
| } | |
| private static boolean shouldReverseNetScore() {//TODO: Implement | |
| return CoralPlacingCommands.shouldReverseScore(); | |
| } |
🤖 Prompt for AI Agents
In
src/main/java/frc/trigon/robot/commands/commandfactories/AlgaeManipulationCommands.java
around lines 150 to 152, the placeholder shouldReverseNetScore() currently
returns false; replace its body to delegate to
CoralPlacingCommands.shouldReverseScore() so it returns that method's result.
Ensure you call the method statically (or qualify it appropriately) and add an
import if needed so the call compiles.
Uh oh!
There was an error while loading. Please reload this page.