Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
12 changes: 4 additions & 8 deletions src/main/java/frc/trigon/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@
import frc.trigon.robot.misc.simulatedfield.SimulatedGamePieceConstants;
import frc.trigon.robot.poseestimation.poseestimator.PoseEstimator;
import frc.trigon.robot.subsystems.MotorSubsystem;

import frc.trigon.robot.subsystems.elevator.Elevator;
import frc.trigon.robot.subsystems.elevator.ElevatorCommands;
import frc.trigon.robot.subsystems.elevator.ElevatorConstants;
import frc.trigon.robot.subsystems.arm.Arm;
import frc.trigon.robot.subsystems.arm.ArmCommands;
import frc.trigon.robot.subsystems.arm.ArmConstants;

import frc.trigon.robot.subsystems.climber.Climber;
import frc.trigon.robot.subsystems.climber.ClimberCommands;
import frc.trigon.robot.subsystems.climber.ClimberConstants;
import frc.trigon.robot.subsystems.elevator.Elevator;
import frc.trigon.robot.subsystems.elevator.ElevatorCommands;
import frc.trigon.robot.subsystems.elevator.ElevatorConstants;
import frc.trigon.robot.subsystems.intake.Intake;
import frc.trigon.robot.subsystems.intake.IntakeCommands;
import frc.trigon.robot.subsystems.intake.IntakeConstants;

import frc.trigon.robot.subsystems.swerve.Swerve;
import frc.trigon.robot.subsystems.transporter.Transporter;
import frc.trigon.robot.subsystems.transporter.TransporterCommands;
Expand Down Expand Up @@ -79,7 +75,7 @@ private void configureBindings() {

private void bindDefaultCommands() {
SWERVE.setDefaultCommand(GeneralCommands.getFieldRelativeDriveCommand());
ARM.setDefaultCommand(ArmCommands.getSetTargetStateCommand(ArmConstants.ArmState.REST));
ARM.setDefaultCommand(ArmCommands.getRestCommand());
CLIMBER.setDefaultCommand(ClimberCommands.getSetTargetStateCommand(ClimberConstants.ClimberState.REST));
ELEVATOR.setDefaultCommand(ElevatorCommands.getSetTargetStateCommand(ElevatorConstants.ElevatorState.REST));
INTAKE.setDefaultCommand(IntakeCommands.getSetTargetStateCommand(IntakeConstants.IntakeState.REST));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@
import frc.trigon.robot.commands.commandclasses.IntakeAssistCommand;
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.intake.IntakeCommands;
import frc.trigon.robot.subsystems.intake.IntakeConstants;
import frc.trigon.robot.subsystems.transporter.TransporterCommands;
import frc.trigon.robot.subsystems.transporter.TransporterConstants;
import lib.hardware.misc.leds.LEDCommands;

public class CoralCollectionCommands {
public static Command getLoadCoralCommand() {
return new ParallelCommandGroup(
ArmCommands.getSetTargetStateCommand(ArmConstants.ArmState.LOAD_CORAL),
ElevatorCommands.getSetTargetStateCommand(ElevatorConstants.ElevatorState.LOAD_CORAL)
).until(RobotContainer.ARM::hasGamePiece);
}
Comment on lines +22 to +27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Cancellation stops rollers; likely to drop coral on detection

ArmCommands.getSetTargetStateCommand(...) calls Arm.stop() on end; Arm.stop() halts both the arm and end-effector motors (see Arm.java Lines 49–52). When .until(ARM::hasGamePiece) triggers, the rollers stop immediately, risking loss of the newly acquired coral. Also, there’s no timeout if the sensor never trips.

Apply a minimal safety guard now (timeout):

-        ).until(RobotContainer.ARM::hasGamePiece);
+        )
+        .until(RobotContainer.ARM::hasGamePiece)
+        .withTimeout(2.5);

Recommended follow-ups (requires small helpers in ArmCommands):

  • Keep rollers at a gentle hold after detection instead of stopping.
  • Split “arm positioning” from “roller control” so end behavior doesn’t cut power to rollers.

Example helper additions (in ArmCommands.java):

// New: keep only the arm positioning running; do not stop rollers on end.
public static Command getSetArmStateCommand(ArmConstants.ArmState targetState, boolean reversed) {
    return new FunctionalCommand(
        () -> {}, // init handled elsewhere
        () -> RobotContainer.ARM.setArmState(targetState, reversed),
        interrupted -> RobotContainer.ARM.setArmState(ArmConstants.ArmState.REST), // or no-op
        () -> false,
        RobotContainer.ARM
    );
}

// New: hold rollers at specified voltage (no auto-stop on end).
public static Command getSetEndEffectorHoldCommand(double holdVoltage) {
    return new StartEndCommand(
        () -> RobotContainer.ARM.setEndEffectorState(new ArmConstants.ArmState(ArmConstants.ArmState.REST.targetAngle, holdVoltage)),
        () -> {}, // keep holding after this command unless another command takes control
        RobotContainer.ARM
    );
}

Then refactor getLoadCoralCommand:

-        return new ParallelCommandGroup(
-                ArmCommands.getSetTargetStateCommand(ArmConstants.ArmState.LOAD_CORAL),
-                ElevatorCommands.getSetTargetStateCommand(ElevatorConstants.ElevatorState.LOAD_CORAL)
-        ).until(RobotContainer.ARM::hasGamePiece);
+        final double HOLD_VOLTAGE = -1.5; // tune as needed
+        return new ParallelCommandGroup(
+                ArmCommands.getSetArmStateCommand(ArmConstants.ArmState.LOAD_CORAL, false),
+                ArmCommands.getSetEndEffectorHoldCommand(ArmConstants.ArmState.LOAD_CORAL.targetEndEffectorVoltage),
+                ElevatorCommands.getSetTargetStateCommand(ElevatorConstants.ElevatorState.LOAD_CORAL)
+        )
+        .until(RobotContainer.ARM::hasGamePiece)
+        .andThen(ArmCommands.getSetEndEffectorHoldCommand(HOLD_VOLTAGE))
+        .withTimeout(2.5);

If adding helpers isn’t desirable now, at least keep the current rollers running briefly post-detection via an InstantCommand that bumps the end-effector voltage (requires a public API to set it without stopping).

To confirm the stop-on-cancel behavior:


🏁 Script executed:

#!/bin/bash
# Verify ArmCommands end behavior and Arm.stop() effect
rg -nP 'FunctionalCommand\(|ExecuteEndCommand\(' src/main/java/frc/trigon/robot/subsystems/arm/ArmCommands.java -C3
rg -n 'void stop\(\)' src/main/java/frc/trigon/robot/subsystems/arm/Arm.java -n -C3

Length of output: 886


Critical: cancellation currently stops rollers — add timeout and decouple roller control

Verified: getSetTargetStateCommand(...) ends by calling RobotContainer.ARM.stop(), and Arm.stop() calls armMasterMotor.stopMotor() and endEffectorMotor.stopMotor() (ArmCommands.java ~lines 40–44; Arm.java ~lines 48–52). .until(...) will therefore cut power to the rollers on detection, and there is no timeout if the sensor never trips.

  • Immediate fix (apply now, in CoralCollectionCommands.getLoadCoralCommand): add a short timeout so rollers aren’t cut off instantly.
-        ).until(RobotContainer.ARM::hasGamePiece);
+        )
+        .until(RobotContainer.ARM::hasGamePiece)
+        .withTimeout(2.5);
  • Required follow-up (must address before release): decouple arm positioning from end-effector control so cancelling/ending an arm-position command does not stop the rollers.
    • Change ArmCommands.getSetTargetStateCommand(...) to avoid calling RobotContainer.ARM.stop() for end-effect behavior (or call a function that only stops the arm motor).
    • Add a separate command to control/hold the end-effector (rollers) so you can explicitly stop or hold rollers after detection.

Files/locations to update:

  • Immediate: src/main/java/frc/trigon/robot/commands/commandfactories/CoralCollectionCommands.java (getLoadCoralCommand).
  • Follow-up: src/main/java/frc/trigon/robot/subsystems/arm/ArmCommands.java (FunctionalCommand end handler) and src/main/java/frc/trigon/robot/subsystems/arm/Arm.java (stop implementation lines shown above).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static Command getLoadCoralCommand() {
return new ParallelCommandGroup(
ArmCommands.getSetTargetStateCommand(ArmConstants.ArmState.LOAD_CORAL),
ElevatorCommands.getSetTargetStateCommand(ElevatorConstants.ElevatorState.LOAD_CORAL)
).until(RobotContainer.ARM::hasGamePiece);
}
public static Command getLoadCoralCommand() {
return new ParallelCommandGroup(
ArmCommands.getSetTargetStateCommand(ArmConstants.ArmState.LOAD_CORAL),
ElevatorCommands.getSetTargetStateCommand(ElevatorConstants.ElevatorState.LOAD_CORAL)
)
.until(RobotContainer.ARM::hasGamePiece)
.withTimeout(2.5);
}
🤖 Prompt for AI Agents
In
src/main/java/frc/trigon/robot/commands/commandfactories/CoralCollectionCommands.java
around lines 22–27, the ParallelCommandGroup used for getLoadCoralCommand is
being cancelled by .until(...) which triggers Arm.stop() and cuts power to the
rollers immediately; add a short timeout to the command (e.g., withTimeout(0.5)
on the ParallelCommandGroup) so the rollers are allowed to run briefly before
the until predicate can cancel them, and keep the existing
.until(RobotContainer.ARM::hasGamePiece) behavior; as a required follow-up
before release, refactor ArmCommands.getSetTargetStateCommand(...) to avoid
calling RobotContainer.ARM.stop() for end-effector behavior and add a separate
command/subsystem to control/hold the rollers so ending/cancelling arm position
commands does not stop the rollers.


public static Command getCoralCollectionCommand() {
return new ParallelCommandGroup(
getIntakeSequenceCommand(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static Command getEjectCoralFromIntakeCommand() {

private static Command getEjectCoralFromArmCommand() {
return new SequentialCommandGroup(
ArmCommands.getPrepareForStateCommand(ArmConstants.ArmState.EJECT).until(RobotContainer.ARM::atTargetAngle),
ArmCommands.getPrepareForStateCommand(ArmConstants.ArmState.EJECT).until(RobotContainer.ARM::atPrepareAngle),
ArmCommands.getSetTargetStateCommand(ArmConstants.ArmState.EJECT)
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
package frc.trigon.robot.commands.commandfactories;

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.Command;
import edu.wpi.first.wpilibj2.command.ConditionalCommand;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import frc.trigon.robot.RobotContainer;
import frc.trigon.robot.constants.AutonomousConstants;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix build: replace missing AutonomousConstants with local PathConstraints.

AutonomousConstants isn’t on classpath (pipeline error). Inline a local PathConstraints and drop the import/usage.

-import frc.trigon.robot.constants.AutonomousConstants;
+import com.pathplanner.lib.path.PathConstraints;
@@
 public class CoralPlacingCommands {
-    public static boolean SHOULD_SCORE_AUTONOMOUSLY = true;
+    public static boolean SHOULD_SCORE_AUTONOMOUSLY = true;
     private static final ReefChooser REEF_CHOOSER = OperatorConstants.REEF_CHOOSER;
+    // TODO: tune values or move to a restored AutonomousConstants
+    private static final PathConstraints DRIVE_TO_REEF_CONSTRAINTS = new PathConstraints(3.0, 2.0, 8.0, 10.0);
@@
                 SwerveCommands.getDriveToPoseCommand(
                         () -> CoralPlacingCommands.calculateClosestScoringPose(shouldScoreRight),
-                        AutonomousConstants.DRIVE_TO_REEF_CONSTRAINTS
+                        DRIVE_TO_REEF_CONSTRAINTS
                 ),

Also applies to: 47-52

🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 11-11: cannot find symbol: AutonomousConstants; import frc.trigon.robot.constants.AutonomousConstants cannot be resolved. Ensure the class exists and is on the classpath.

🤖 Prompt for AI Agents
In
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
around line 11 (and usages around lines 47-52), remove the nonexistent import of
frc.trigon.robot.constants.AutonomousConstants and replace references to
AutonomousConstants with a local PathConstraints definition inside this file;
add a small local static PathConstraints (or equivalent) instance/values that
mirror the fields used (max velocity, max acceleration, etc.), then update the
code that referenced AutonomousConstants to use this local PathConstraints
instance and drop the import line.

import frc.trigon.robot.constants.FieldConstants;
Comment on lines +12 to +13
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Build break: AutonomousConstants not found.

Either add the constants class or stop depending on it here. Quick unblock: inline a local PathConstraints and drop the import.

-import frc.trigon.robot.constants.AutonomousConstants;
+import com.pathplanner.lib.path.PathConstraints;
@@
-                        AutonomousConstants.DRIVE_TO_REEF_CONSTRAINTS
+                        DRIVE_TO_REEF_CONSTRAINTS
                 ),

Add near Line 26:

+    // TODO: tune these; placeholder to unblock compilation if AutonomousConstants is absent
+    private static final PathConstraints DRIVE_TO_REEF_CONSTRAINTS = new PathConstraints(3.0, 2.0, 8.0, 10.0);

Alternatively, add frc.trigon.robot.constants.AutonomousConstants with DRIVE_TO_REEF_CONSTRAINTS.

Also applies to: 47-52

🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 11-11: cannot find symbol: import frc.trigon.robot.constants.AutonomousConstants; symbol: class AutonomousConstants

🤖 Prompt for AI Agents
In
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
around lines 11-12 and 26 (and also affecting lines 47-52): the import of
frc.trigon.robot.constants.AutonomousConstants causes a build break because the
class is missing; either remove the import and inline a local PathConstraints
instance (named e.g. DRIVE_TO_REEF_CONSTRAINTS) near line 26 and use that in
place of AutonomousConstants references, or create the missing
frc.trigon.robot.constants.AutonomousConstants class exposing
DRIVE_TO_REEF_CONSTRAINTS; update all uses at lines ~47-52 to reference the new
local constant or the newly-added class accordingly.

import frc.trigon.robot.constants.OperatorConstants;
import frc.trigon.robot.misc.ReefChooser;
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.utilities.flippable.FlippablePose2d;
import lib.utilities.flippable.FlippableTranslation2d;

public class CoralPlacingCommands {
public static boolean SHOULD_SCORE_AUTONOMOUSLY = true;
private static final ReefChooser REEF_CHOOSER = OperatorConstants.REEF_CHOOSER;

public static Command getScoreInReefCommand(boolean shouldScoreRight) {
return new ConditionalCommand(
getAutonomouslyScoreCommand(shouldScoreRight),
getScoreCommand(shouldScoreRight),
() -> SHOULD_SCORE_AUTONOMOUSLY
);
}

private static Command getAutonomouslyScoreCommand(boolean shouldScoreRight) {
return new SequentialCommandGroup(
getAutonomouslyPrepareScoreCommand(shouldScoreRight).until(() -> isArmAndElevatorAtPrepareState(shouldScoreRight)),
new ParallelCommandGroup(
ElevatorCommands.getSetTargetStateCommand(REEF_CHOOSER::getElevatorState),
ArmCommands.getSetTargetStateCommand(REEF_CHOOSER::getArmState, CoralPlacingCommands::shouldReverseScore)
)
);
}

private static Command getScoreCommand(boolean shouldScoreRight) {
return new SequentialCommandGroup(
getAutonomouslyPrepareScoreCommand(shouldScoreRight).until(OperatorConstants.CONTINUE_TRIGGER),
new ParallelCommandGroup(
ElevatorCommands.getSetTargetStateCommand(REEF_CHOOSER::getElevatorState),
ArmCommands.getSetTargetStateCommand(REEF_CHOOSER::getArmState, CoralPlacingCommands::shouldReverseScore)
)
);
}

private static Command getAutonomouslyPrepareScoreCommand(boolean shouldScoreRight) {
return new ParallelCommandGroup(
ElevatorCommands.getPrepareStateCommand(REEF_CHOOSER::getElevatorState),
ArmCommands.getPrepareForStateCommand(REEF_CHOOSER::getArmState, CoralPlacingCommands::shouldReverseScore),
getAutonomousDriveToReefThenManualDriveCommand(shouldScoreRight).asProxy()
);
}

private static Command getAutonomousDriveToReefThenManualDriveCommand(boolean shouldScoreRight) {
return new SequentialCommandGroup(
SwerveCommands.getDriveToPoseCommand(
() -> CoralPlacingCommands.calculateClosestScoringPose(shouldScoreRight),
AutonomousConstants.DRIVE_TO_REEF_CONSTRAINTS
),
GeneralCommands.getFieldRelativeDriveCommand()
);
}

private static double calculateDistanceToTargetScoringPose(boolean shouldScoreRight) {
final Translation2d currentTranslation = RobotContainer.ROBOT_POSE_ESTIMATOR.getEstimatedRobotPose().getTranslation();
final Translation2d targetTranslation = calculateClosestScoringPose(shouldScoreRight).get().getTranslation();
return currentTranslation.getDistance(targetTranslation);
}

public static FlippablePose2d calculateClosestScoringPose(boolean shouldScoreRight) {
final Translation2d robotPositionOnField = RobotContainer.ROBOT_POSE_ESTIMATOR.getEstimatedRobotPose().getTranslation();
final Translation2d reefCenterPosition = new FlippableTranslation2d(FieldConstants.BLUE_REEF_CENTER_TRANSLATION, true).get();
final Rotation2d[] reefClockAngles = FieldConstants.REEF_CLOCK_ANGLES;
final Transform2d reefCenterToScoringPose = new Transform2d(FieldConstants.REEF_CENTER_TO_TARGET_SCORING_POSITION_X_TRANSFORM_METERS, 0, new Rotation2d());

double distanceFromClosestScoringPoseMeters = Double.POSITIVE_INFINITY;
Pose2d closestScoringPose = new Pose2d();
for (final Rotation2d targetRotation : reefClockAngles) {
final Pose2d reefCenterAtTargetRotation = new Pose2d(reefCenterPosition, targetRotation);


final Pose2d currentScoringPose = reefCenterAtTargetRotation.transformBy(reefCenterToScoringPose);
final double distanceFromCurrentScoringPoseMeters = currentScoringPose.getTranslation().getDistance(robotPositionOnField);
if (distanceFromCurrentScoringPoseMeters < distanceFromClosestScoringPoseMeters) {
distanceFromClosestScoringPoseMeters = distanceFromCurrentScoringPoseMeters;
closestScoringPose = currentScoringPose;
}
}

final Transform2d scoringPoseToBranch = new Transform2d(
0,
shouldScoreRight ? FieldConstants.REEF_CENTER_TO_TARGET_SCORING_POSITION_Y_TRANSFORM_METERS : -FieldConstants.REEF_CENTER_TO_TARGET_SCORING_POSITION_Y_TRANSFORM_METERS,
shouldReverseScore() ? Rotation2d.k180deg : new Rotation2d()
);

return new FlippablePose2d(closestScoringPose.transformBy(scoringPoseToBranch), false);
}

private static boolean isArmAndElevatorAtPrepareState(boolean shouldScoreRight) {
return RobotContainer.ELEVATOR.atPreparedTargetState()
&& RobotContainer.ARM.atPrepareAngle()
&& RobotContainer.SWERVE.atPose(calculateClosestScoringPose(shouldScoreRight));
}

private static boolean shouldReverseScore() {
final Rotation2d robotRotation = RobotContainer.ROBOT_POSE_ESTIMATOR.getEstimatedRobotPose().getRotation();
final Translation2d robotTranslation = RobotContainer.ROBOT_POSE_ESTIMATOR.getEstimatedRobotPose().getTranslation();
final Translation2d reefCenterTranslation = FieldConstants.FLIPPABLE_REEF_CENTER_TRANSLATION.get();
final Translation2d difference = reefCenterTranslation.minus(robotTranslation);
final Rotation2d robotRotationRelativeToReef = difference.getAngle();
final Rotation2d robotRotationFacingReef = robotRotation.minus(robotRotationRelativeToReef);
return robotRotationFacingReef.getDegrees() > Rotation2d.kCW_90deg.getDegrees() && robotRotationFacingReef.getDegrees() < Rotation2d.kCCW_90deg.getDegrees();
}

/**
* An enum that represents the different levels of scoring in the reef.
* Each level has a different x and y transform from the reef center,
* as well as a different elevator and gripper state.
* The x and y transform are used to calculate the target placing position from the middle of the reef.
*/
public enum ScoringLevel {
L1(Double.NaN, Double.NaN, null),
L2(FieldConstants.REEF_CENTER_TO_TARGET_SCORING_POSITION_X_TRANSFORM_METERS, FieldConstants.REEF_CENTER_TO_TARGET_SCORING_POSITION_Y_TRANSFORM_METERS, Rotation2d.fromDegrees(0)),
L3(L2.xTransformMeters, L2.positiveYTransformMeters, Rotation2d.fromDegrees(0)),
L4(L2.xTransformMeters, L2.positiveYTransformMeters, Rotation2d.fromDegrees(0));

public final ElevatorConstants.ElevatorState elevatorState;
public final ArmConstants.ArmState armState;
public final int level = calculateLevel();
final double xTransformMeters, positiveYTransformMeters;
final Rotation2d rotationTransform;

/**
* Constructs a scoring level with the given x and y transform.
* The elevator and gripper state are determined automatically based on the scoring level.
*
* @param xTransformMeters the x transform from the middle of the reef to the target placing position
* @param positiveYTransformMeters the y transform from the middle of the reef to the target placing position.
* This must be positive (to account for flipping later on), and might be flipped depending on operator input (left or right reef side)
* @param rotationTransform the angle to be facing the reef with the robot. Might change when scoring from the coral intake
*/
ScoringLevel(double xTransformMeters, double positiveYTransformMeters, Rotation2d rotationTransform) {
this.xTransformMeters = xTransformMeters;
this.positiveYTransformMeters = positiveYTransformMeters;
this.rotationTransform = rotationTransform;
this.elevatorState = determineElevatorState();
this.armState = determineArmState();
}

/**
* Calculates the target placing position using the clock position and the target reef side.
* The reef side transform will be flipped depending on operator input.
* To make it more intuitive for the operator to input the reef side,
* left will always correspond to the physical left side in the driver station,
* as opposed to "reef relative" left.
*
* @param reefClockPosition the desired clock position of the reef
* @param reefSide the desired side of the reef, left or right (as seen from the driver station)
* @return the target placing position
*/
public FlippablePose2d calculateTargetPlacingPosition(FieldConstants.ReefClockPosition reefClockPosition, FieldConstants.ReefSide reefSide) {
final Pose2d reefCenterPose = new Pose2d(FieldConstants.BLUE_REEF_CENTER_TRANSLATION, reefClockPosition.clockAngle);
final double yTransform = reefSide.shouldFlipYTransform(reefClockPosition) ? -positiveYTransformMeters : positiveYTransformMeters;
final Transform2d transform = new Transform2d(xTransformMeters, yTransform, rotationTransform);

return new FlippablePose2d(reefCenterPose.plus(transform), true);
}

private ElevatorConstants.ElevatorState determineElevatorState() {
return switch (level) {
case 1 -> ElevatorConstants.ElevatorState.SCORE_L1;
case 2 -> ElevatorConstants.ElevatorState.SCORE_L2;
case 3 -> ElevatorConstants.ElevatorState.SCORE_L3;
case 4 -> ElevatorConstants.ElevatorState.SCORE_L4;
default -> throw new IllegalStateException("Unexpected value: " + ordinal());
};
}

private ArmConstants.ArmState determineArmState() {
return switch (level) {
case 1 -> ArmConstants.ArmState.SCORE_L1;
case 2 -> ArmConstants.ArmState.SCORE_L2;
case 3 -> ArmConstants.ArmState.SCORE_L3;
case 4 -> ArmConstants.ArmState.SCORE_L4;
default -> throw new IllegalStateException("Unexpected value: " + ordinal());
};
}

private int calculateLevel() {
return ordinal() + 1;
}
}
}
Loading
Loading