Skip to content

Conversation

ShmayaR
Copy link
Contributor

@ShmayaR ShmayaR commented Sep 10, 2025

Summary by CodeRabbit

  • New Features
    • Full reef scoring workflow with manual or autonomous paths selecting nearest target pose by level, clock position, and side.
    • Reef Chooser for live selection of scoring level (L1–L4), reef clock position (2–12 o’clock), and left/right side.
    • Controller bindings for quick level, clock-position, and side selection.
    • Autonomous coordination of drive, elevator, arm, and gripper for reef placements.
    • Elevator readiness/position checks to improve placement reliability.

@levyishai
Copy link
Member

@CodeRabbit full reveiw

Copy link

coderabbitai bot commented Sep 11, 2025

@levyishai I'll conduct a full review of the PR changes for you.

✅ Actions performed

Full review triggered.

Copy link

coderabbitai bot commented Sep 11, 2025

Walkthrough

Adds reef-scoring support: new CoralPlacingCommands with manual/autonomous branches and ScoringLevel; new ReefChooser for HID-driven reef selection; FieldConstants extended with reef enums, poses, and transforms; OperatorConstants exposes ReefChooser and triggers; Elevator adds atState() and atTargetState(); ElevatorConstants adds HEIGHT_TOLERANCE_METERS and import tidy.

Changes

Cohort / File(s) Summary
Reef scoring command factory
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
New command factory with SHOULD_SCORE_AUTONOMOUSLY, continuous conditional selection between manual and autonomous scoring paths, pose calculations and distance gating, readiness checks, reef-side flipping, and nested ScoringLevel enum (L1–L4) exposing elevator/arm state bindings and public pose calculation.
Field geometry and reef enums
src/main/java/frc/trigon/robot/constants/FieldConstants.java
Adds FlippablePose2d coral poses, reef clock angles/count, reef-center transforms, BLUE_REEF_CENTER_TRANSLATION, LEFT_FEEDER_ANGLE; renames tag-map helper; expands tag-ignore set; introduces nested enums ReefSide and ReefClockPosition.
Operator inputs and chooser wiring
src/main/java/frc/trigon/robot/constants/OperatorConstants.java
Adds REEF_CHOOSER instance (port 1) and multiple public Triggers for selecting scoring level (L1–L4), reef clock positions (2–12 o'clock), and reef side (left/right); consolidates controller port constants.
Reef chooser
src/main/java/frc/trigon/robot/misc/ReefChooser.java
New ReefChooser class managing clock position, reef side, and scoring level with delayed binding (3s) for HID and fallback triggers; exposes getters and calculateTargetScoringPose() delegating to ScoringLevel.
Elevator readiness & SysID surface
src/main/java/frc/trigon/robot/subsystems/elevator/Elevator.java
Adds public atState(ElevatorState) and atTargetState() predicates, updates setTargetState to sync rotations, introduces voltage/position request control objects, SysID config/getter, updateLog and sysIDDrive interfaces, and periodic updates.
Elevator constants tidy + tolerance
src/main/java/frc/trigon/robot/subsystems/elevator/ElevatorConstants.java
Replaces wildcard imports with explicit imports, adds HEIGHT_TOLERANCE_METERS = 0.01, minor coordinate/formatting fixes; no public signature changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Operator
  participant ReefChooser
  participant CmdFactory as CoralPlacingCommands
  participant Drive
  participant Elevator
  participant Arm
  participant Gripper

  Note over Operator,ReefChooser: Operator sets reef clock/side/level via triggers/HID
  Operator->>ReefChooser: set level / clock / side
  Operator->>CmdFactory: getScoreInReefFromGripperCommand(shouldScoreRight)
  CmdFactory->>ReefChooser: getScoringLevel() / calculateTargetScoringPose()
  alt SHOULD_SCORE_AUTONOMOUSLY == true
    CmdFactory->>Drive: drive to reef target pose (async)
    par Prepare robot
      CmdFactory->>Elevator: set elevator state
      CmdFactory->>Arm: set arm state
    and Autonomous release
      CmdFactory->>Gripper: auto-release when gated ready
    end
    CmdFactory->>Elevator: monitor atTargetState()
  else Manual path
    CmdFactory->>Gripper: run load sequence
    par Manual scoring
      CmdFactory->>Elevator: set elevator state
      CmdFactory->>Arm: set arm state
      CmdFactory->>Gripper: release on manual command
    end
  end
  CmdFactory-->>Operator: command completes
Loading
sequenceDiagram
  autonumber
  participant System
  participant ReefChooser
  participant Triggers

  Note over System: ReefChooser delayed binding initialization
  System->>ReefChooser: new ReefChooser(port)
  ReefChooser-->>ReefChooser: wait 3s then configure bindings
  ReefChooser->>Triggers: bind L1-L4, clock buttons, left/right
  Triggers-->>ReefChooser: update internal state on input
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.04% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Coral Placing Commands" is concise and directly reflects the primary change in the diff—the addition of a CoralPlacingCommands class and reef-scoring command infrastructure—so it clearly communicates the main intent for teammates scanning history. It is specific to the main change and avoids irrelevant noise.

Poem

I hop by reefs with compass bright,
Clock ticks six and turns to right—
L1 through L4 my whiskers learn,
Elevator hums, the arm will turn.
Flip the side — coral lands just right. 🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch coral-scoring-commands

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/frc/trigon/robot/subsystems/elevator/Elevator.java (1)

49-55: Unit mismatch in SysId logging (rotations reported as meters).

linearPosition and linearVelocity should be in meters/ m·s⁻¹. You’re logging rotations.

Apply:

-        log.motor("Elevator")
-                .linearPosition(Units.Meters.of(getPositionRotations()))
-                .linearVelocity(Units.MetersPerSecond.of(masterMotor.getSignal(TalonFXSignal.VELOCITY)))
+        log.motor("Elevator")
+                .linearPosition(Units.Meters.of(getPositionMeters()))
+                .linearVelocity(Units.MetersPerSecond.of(
+                        rotationsToMeters(masterMotor.getSignal(TalonFXSignal.VELOCITY))
+                ))
🧹 Nitpick comments (9)
src/main/java/frc/trigon/robot/subsystems/elevator/ElevatorConstants.java (1)

86-86: Consider exposing or centralizing elevator tolerance.

0.01 m may be tighter than field reality; if this drives gating logic elsewhere, consider making it configurable or at least record it to logs for tuning.

src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (3)

214-221: Guard L1 transforms.

L1 uses NaN transforms; ensure calculateTargetPlacingPosition is never called for L1 or throw with a clear message to avoid propagating NaNs.

         public FlippablePose2d calculateTargetPlacingPosition(FieldConstants.ReefClockPosition reefClockPosition, FieldConstants.ReefSide reefSide) {
+            if (this == L1) {
+                throw new IllegalStateException("L1 placing pose is not defined; this method should not be called for L1.");
+            }

40-47: Race/Repeat semantics: verify WaitUntilChangeCommand usage.

The repeated race between setting elevator state and waiting for chooser changes can thrash if chooser toggles quickly. Consider debouncing chooser updates or gating on equality with current target before repeating.


128-136: Distance calculation: OK but consider caching pose.

You call calculateClosestScoringPose twice in close succession in this class; consider caching per cycle in RobotContainer if used frequently.

src/main/java/frc/trigon/robot/misc/ReefChooser.java (3)

3-5: Replace magic 3s delay with HID-connected gate (avoid early scheduling from static init).

Scheduling from the constructor with a fixed WaitCommand(3) is brittle and may run before devices are available or the scheduler is fully ready. Gate on the HID actually being connected instead.

Apply:

-import edu.wpi.first.wpilibj2.command.WaitCommand;
+import edu.wpi.first.wpilibj2.command.WaitUntilCommand;
+import edu.wpi.first.wpilibj.DriverStation;
@@
-        new WaitCommand(3).andThen(this::configureBindings).ignoringDisable(true).schedule();
+        new WaitUntilCommand(() -> DriverStation.isJoystickConnected(port))
+                .andThen(this::configureBindings)
+                .ignoringDisable(true)
+                .schedule();

Verify on both sim and real hardware that bindings appear immediately when the device enumerates (no arbitrary delay).

Also applies to: 25-26


86-89: Harden face-index mapping against future misuse.

This relies on enum order and assumes 0–11. Add a guard so accidental out-of-range calls fail fast.

-    private void setFaceFromIndex(int index) {
+    private void setFaceFromIndex(int index) {
+        final int faces = FieldConstants.REEF_CLOCK_POSITIONS * FieldConstants.ReefSide.values().length;
+        if (index < 0 || index >= faces)
+            throw new IllegalArgumentException("Invalid reef face index: " + index);
         clockPosition = FieldConstants.ReefClockPosition.values()[index / 2];
         reefSide = FieldConstants.ReefSide.values()[index % 2];
     }

115-129: Remove or wire the unused level increment/decrement helpers.

Dead code adds maintenance overhead. Either bind them to buttons or drop them for now.

src/main/java/frc/trigon/robot/constants/FieldConstants.java (1)

20-22: Rename I_HATE_YOU and use a Set for clarity/perf.

Professional naming helps maintenance; a Set communicates intent and gives O(1) membership tests.

-    private static final List<Integer> I_HATE_YOU = List.of(
-            13, 12, 16, 15, 14, 4, 5, 3, 2, 1
-    );
+    private static final java.util.Set<Integer> IGNORED_TAG_IDS = java.util.Set.of(
+            13, 12, 16, 15, 14, 4, 5, 3, 2, 1
+    );
@@
-            if (!I_HATE_YOU.contains(aprilTag.ID))
+            if (!IGNORED_TAG_IDS.contains(aprilTag.ID))
                 tagIdToPose.put(aprilTag.ID, aprilTag.pose.transformBy(TAG_OFFSET));

Also applies to: 61-63

src/main/java/frc/trigon/robot/constants/OperatorConstants.java (1)

15-18: Be cautious with static initialization order for REEF_CHOOSER.

Since ReefChooser schedules work in its constructor, creating it here can run before the scheduler/devices are ready. If you adopt the WaitUntilCommand gate suggested in ReefChooser, this is fine; otherwise, consider lazy-init or invoking binding from robot/container init.

Also applies to: 25-26

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between faa4410 and 5315eb0.

📒 Files selected for processing (6)
  • src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (1 hunks)
  • src/main/java/frc/trigon/robot/constants/FieldConstants.java (3 hunks)
  • src/main/java/frc/trigon/robot/constants/OperatorConstants.java (3 hunks)
  • src/main/java/frc/trigon/robot/misc/ReefChooser.java (1 hunks)
  • src/main/java/frc/trigon/robot/subsystems/elevator/Elevator.java (3 hunks)
  • src/main/java/frc/trigon/robot/subsystems/elevator/ElevatorConstants.java (4 hunks)
🧰 Additional context used
🪛 GitHub Actions: Java CI with Gradle
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java

[error] 26-26: constructor ConditionalCommand in class ConditionalCommand cannot be applied to given types; required: Command,Command,BooleanSupplier; found: ProxyCommand,()->...


[error] 41-41: cannot find symbol: method getLoadCoralCommand() in CoralCollectionCommands


[error] 43-43: no suitable method found for getSetTargetStateCommand(REEF_CHOOSER::getElevatorState)


[error] 51-51: cannot find symbol: method getLoadCoralCommand() in CoralCollectionCommands


[error] 63-63: no suitable method found for ArmCommands.getSetTargetStateCommand()


[error] 64-64: cannot find symbol: method atState(ElevatorState) on ELEVATOR


[error] 65-65: invalid method reference: Elevator::isCloseEnoughToOpenGripper not found


[error] 72-72: package GripperConstants does not exist


[error] 73-73: cannot find symbol: GripperCommands


[error] 74-74: cannot find symbol: method atState(ElevatorState) on ELEVATOR


[error] 85-85: cannot find symbol: GripperCommands.getPrepareForStateCommand(REEF_CHOOSER::getGripperState)


[error] 91-91: cannot find symbol: GripperCommands.getSetTargetStateCommand(REEF_CHOOSER::getGripperState)


[error] 97-97: cannot find symbol: GripperCommands.getPrepareForStateCommand(REEF_CHOOSER::getGripperState).until(OperatorConstants.CONTINUE_TRIGGER)


[error] 98-98: cannot find symbol: GripperCommands.getSetTargetStateCommand(REEF_CHOOSER::getGripperState)


[error] 104-104: cannot find symbol: GripperCommands.getPrepareForScoringInL4Command(REEF_CHOOSER::calculateTargetScoringPose)


[error] 107-107: cannot find symbol: GripperCommands.getScoreInL4Command(REEF_CHOOSER::calculateTargetScoringPose)


[error] 113-113: no suitable method found for ElevatorCommands.getSetTargetStateCommand(REEF_CHOOSER::getElevatorState)


[error] 114-114: cannot find symbol: shouldScoreRight


[error] 122-122: package AutonomousConstants does not exist

🔇 Additional comments (11)
src/main/java/frc/trigon/robot/subsystems/elevator/ElevatorConstants.java (1)

113-120: Hardware gains are zero on real hardware — confirm intent or provide safe defaults

kP/kI/kD/kS/kV/kA/kG are set to 0 when RobotHardwareStats.isSimulation() is false; MotionMagic will not regulate with these values.

  • Add an inline comment if zeros are intentional.
  • Otherwise initialize safe starter gains or load Slot0 gains from WPILib Preferences.

File: src/main/java/frc/trigon/robot/subsystems/elevator/ElevatorConstants.java (lines 113–120)

        config.Slot0.kP = RobotHardwareStats.isSimulation() ? 3.5 : 0;
        config.Slot0.kI = RobotHardwareStats.isSimulation() ? 0 : 0;
        config.Slot0.kD = RobotHardwareStats.isSimulation() ? 0.4 : 0;
        config.Slot0.kS = RobotHardwareStats.isSimulation() ? 0.016165 : 0;
        config.Slot0.kV = RobotHardwareStats.isSimulation() ? 0.4766 : 0;
        config.Slot0.kA = RobotHardwareStats.isSimulation() ? 0.014239 : 0;
        config.Slot0.kG = RobotHardwareStats.isSimulation() ? 0.58202 : 0;

Need a template to load Slot0 gains from WPILib Preferences?

src/main/java/frc/trigon/robot/subsystems/elevator/Elevator.java (1)

79-82: atTargetState() looks good.

Simple, readable tolerance check using constants.

src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (4)

111-116: Reference to AutonomousConstants without import and potential capture issue.

Add the import (see earlier diff). Also ensure shouldScoreRight is effectively final (method param is fine).


95-101: .until(OperatorConstants.CONTINUE_TRIGGER) compatibility.

If CONTINUE_TRIGGER isn’t a BooleanSupplier, use .until(OperatorConstants.CONTINUE_TRIGGER::getAsBoolean).


139-156: Distance-minimization loop: looks good.

Nearest clock-angle scoring pose selection is clean and efficient.


118-126: Signature verified — confirm constraint constant type

SwerveCommands.getDriveToPoseCommand(Supplier, PathConstraints) exists so the Supplier you pass is correct; confirm AutonomousConstants.DRIVE_TO_REEF_CONSTRAINTS is a PathConstraints instance (and that calculateClosestScoringPose returns FlippablePose2d).

src/main/java/frc/trigon/robot/misc/ReefChooser.java (1)

44-54: API surface looks solid.

Pose, arm, and elevator state accessors are cohesive and side-effect free.

src/main/java/frc/trigon/robot/constants/FieldConstants.java (3)

84-90: All ReefClockPosition entries set isFacingDriverStation = true — likely incorrect.

The flip logic in ReefSide.shouldFlipYTransform() depends on this flag. With all true, flipping degenerates to side-only behavior and may produce wrong Y transforms on half the reef.

Proposed mapping (please verify against field geometry):

-        REEF_12_OCLOCK(true),
-        REEF_2_OCLOCK(true),
-        REEF_4_OCLOCK(true),
-        REEF_6_OCLOCK(true),
-        REEF_8_OCLOCK(true),
-        REEF_10_OCLOCK(true);
+        REEF_12_OCLOCK(true),
+        REEF_2_OCLOCK(true),
+        REEF_4_OCLOCK(true),
+        REEF_6_OCLOCK(false),
+        REEF_8_OCLOCK(false),
+        REEF_10_OCLOCK(false);

If orientation differs by alliance or mirroring, consider deriving this from pose/angle instead of hard-coding.

Also applies to: 92-99, 78-81


29-36: Confirm Rotation2d.unaryMinus() availability in your WPILib version.

If you target an older release, replace with Rotation2d.fromRadians(-AUTO_FIND_CORAL_POSE_LEFT_ROTATION.getRadians()).


39-47: Clock-angle math is clean and self-consistent.

Using REEF_CLOCK_POSITION_DIFFERENCE.times(-ordinal()) and exposing a precomputed REEF_CLOCK_ANGLES array is tidy.

Also applies to: 101-111

src/main/java/frc/trigon/robot/constants/OperatorConstants.java (1)

47-59: Trigger mapping looks good and covers the intended UX.

Direct binds for L1–L4, clock positions, and side selection are clear and discoverable.

Comment on lines 26 to 30
return new ConditionalCommand(
getScoreInReefFromGripperCommand(shouldScoreRight).asProxy(),
() -> REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1
);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

ConditionalCommand missing the “onFalse” command argument.

Constructor is (onTrue, onFalse, condition). Add an else branch (e.g., Commands.none()) and make the condition match intent.

-        return new ConditionalCommand(
-                getScoreInReefFromGripperCommand(shouldScoreRight).asProxy(),
-                () -> REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1
-        );
+        return new ConditionalCommand(
+                getScoreInReefFromGripperCommand(shouldScoreRight).asProxy(),
+                Commands.none(),
+                () -> REEF_CHOOSER.getScoringLevel() != ScoringLevel.L1
+        );

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 26-26: constructor ConditionalCommand in class ConditionalCommand cannot be applied to given types; required: Command,Command,BooleanSupplier; found: ProxyCommand,()->...

🤖 Prompt for AI Agents
In
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
around lines 26-30, the ConditionalCommand invocation is using the two-argument
constructor incorrectly (the lambda is being passed as the onFalse parameter);
add an explicit else branch such as Commands.none() as the second argument and
pass the condition lambda as the third argument (ensure the condition expression
matches the intended logic, e.g., REEF_CHOOSER.getScoringLevel() ==
ScoringLevel.L1 if that was intended).

Comment on lines 41 to 47
return CoralCollectionCommands.getLoadCoralCommand().asProxy().andThen(
new ParallelCommandGroup(
ElevatorCommands.getSetTargetStateCommand(REEF_CHOOSER::getElevatorState).raceWith(new WaitUntilChangeCommand<>(REEF_CHOOSER::getElevatorState)).repeatedly(),
getGripperScoringSequenceCommand()
).asProxy()
);
}
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Unknown method CoralCollectionCommands.getLoadCoralCommand().

Name/signature likely differs. Verify the actual API and fix the call.

Run to locate the available load/intake methods and signatures:


🏁 Script executed:

#!/bin/bash
rg -nP -C2 --type=java '\bclass\s+CoralCollectionCommands\b|getLoad.*Coral|get.*Intake.*Coral|getLoadCommand' 

Length of output: 2226


Fix unknown call to CoralCollectionCommands.getLoadCoralCommand()

CoralCollectionCommands does not define getLoadCoralCommand(); it defines public static Command getCoralCollectionCommand(). Update the call sites in src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (lines 41 and 51) to use getCoralCollectionCommand() or the correct factory and ensure the returned Command is compatible with .asProxy().andThen(...).

🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 41-41: cannot find symbol: method getLoadCoralCommand() in CoralCollectionCommands


[error] 43-43: no suitable method found for getSetTargetStateCommand(REEF_CHOOSER::getElevatorState)

🤖 Prompt for AI Agents
In
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
around lines 41 to 47 (and also update the other occurrence at line 51), replace
the invalid call to CoralCollectionCommands.getLoadCoralCommand() with the
correct CoralCollectionCommands.getCoralCollectionCommand(), and ensure the
returned Command is used in the same way (call .asProxy() before .andThen(...));
also update any imports or types if necessary so the Command returned is
compatible with .asProxy() and the surrounding chaining.

Comment on lines 71 to 75
return new SequentialCommandGroup(
GripperCommands.getSetTargetStateCommand(GripperConstants.GripperState.OPEN_FOR_NOT_HITTING_REEF)
.unless(() -> RobotContainer.ELEVATOR.atState(REEF_CHOOSER.getElevatorState()) || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2 || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
.until(RobotContainer.ELEVATOR::isCloseEnoughToOpenGripper),
new ConditionalCommand(
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Same issue for auto gripper sequence: non-existent Elevator APIs.

-                GripperCommands.getSetTargetStateCommand(GripperConstants.GripperState.OPEN_FOR_NOT_HITTING_REEF)
-                        .unless(() -> RobotContainer.ELEVATOR.atState(REEF_CHOOSER.getElevatorState()) || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2 || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
-                        .until(RobotContainer.ELEVATOR::isCloseEnoughToOpenGripper),
+                GripperCommands.getSetTargetStateCommand(GripperConstants.GripperState.OPEN_FOR_NOT_HITTING_REEF)
+                        .unless(() -> RobotContainer.ELEVATOR.atTargetState()
+                                || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2
+                                || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
+                        .until(RobotContainer.ELEVATOR::atTargetState),
📝 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
return new SequentialCommandGroup(
GripperCommands.getSetTargetStateCommand(GripperConstants.GripperState.OPEN_FOR_NOT_HITTING_REEF)
.unless(() -> RobotContainer.ELEVATOR.atState(REEF_CHOOSER.getElevatorState()) || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2 || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
.until(RobotContainer.ELEVATOR::isCloseEnoughToOpenGripper),
new ConditionalCommand(
return new SequentialCommandGroup(
GripperCommands.getSetTargetStateCommand(GripperConstants.GripperState.OPEN_FOR_NOT_HITTING_REEF)
.unless(() -> RobotContainer.ELEVATOR.atTargetState()
|| REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2
|| REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
.until(RobotContainer.ELEVATOR::atTargetState),
new ConditionalCommand(
🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 72-72: package GripperConstants does not exist


[error] 73-73: cannot find symbol: GripperCommands


[error] 74-74: cannot find symbol: method atState(ElevatorState) on ELEVATOR

🤖 Prompt for AI Agents
In
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
around lines 71-75, the lambda uses non-existent Elevator APIs (atState and
isCloseEnoughToOpenGripper). Replace those calls with the actual Elevator
contract: either call RobotContainer.ELEVATOR.getPosition() and compare it to
the target height from REEF_CHOOSER.getElevatorState() using an existing
tolerance constant (e.g., ElevatorConstants.OPEN_GRIPPER_POSITION_TOLERANCE), or
add a small helper on Elevator (e.g., isAtTargetHeight(targetHeight, tolerance)
or isCloseTo(targetHeight)) and use that; update the unless() predicate to check
the current position-vs-target and the until() to use the real proximity method
(or the new helper) so the code compiles against the real Elevator API.

Comment on lines +174 to +201
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();
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enum state mapping by ordinal is off-by-one and brittle.

L2→SCORE_L1, L3→SCORE_L2, etc. Use explicit mapping on enum constants.

-            this.elevatorState = determineElevatorState();
-            this.armState = determineArmState();
+            this.elevatorState = switch (this) {
+                case L1 -> ElevatorConstants.ElevatorState.SCORE_L1;
+                case L2 -> ElevatorConstants.ElevatorState.SCORE_L2;
+                case L3 -> ElevatorConstants.ElevatorState.SCORE_L3;
+                case L4 -> ElevatorConstants.ElevatorState.SCORE_L4;
+            };
+            this.armState = switch (this) {
+                case L1 -> ArmConstants.ArmState.SCORE_L1;
+                case L2 -> ArmConstants.ArmState.SCORE_L2;
+                case L3 -> ArmConstants.ArmState.SCORE_L3;
+                case L4 -> ArmConstants.ArmState.SCORE_L4;
+            };

Optionally delete determineElevatorState()/determineArmState().

📝 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 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();
}
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 = switch (this) {
case L1 -> ElevatorConstants.ElevatorState.SCORE_L1;
case L2 -> ElevatorConstants.ElevatorState.SCORE_L2;
case L3 -> ElevatorConstants.ElevatorState.SCORE_L3;
case L4 -> ElevatorConstants.ElevatorState.SCORE_L4;
};
this.armState = switch (this) {
case L1 -> ArmConstants.ArmState.SCORE_L1;
case L2 -> ArmConstants.ArmState.SCORE_L2;
case L3 -> ArmConstants.ArmState.SCORE_L3;
case L4 -> ArmConstants.ArmState.SCORE_L4;
};
}

Comment on lines +244 to +248
private int calculateLevel() {
if (ordinal() == 0)
return 1;
return ordinal();
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Level calculation is wrong (L2 becomes 1).

Use ordinal()+1.

-            if (ordinal() == 0)
-                return 1;
-            return ordinal();
+            return ordinal() + 1;
📝 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
private int calculateLevel() {
if (ordinal() == 0)
return 1;
return ordinal();
}
private int calculateLevel() {
return ordinal() + 1;
}
🤖 Prompt for AI Agents
In
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
around lines 244 to 248, the calculateLevel() implementation incorrectly maps
the first non-zero ordinal to 1 by special-casing ordinal()==0; instead return
ordinal()+1 for all cases so Level 1 maps to 1, Level 2 maps to 2, etc.; update
the method to compute and return ordinal()+1 (remove the conditional).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (9)
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (9)

3-19: Missing imports for referenced classes.

The file references several classes that are not imported, which will cause compilation failures.

Add the missing import statements:

 import edu.wpi.first.wpilibj2.command.*;
+import frc.trigon.robot.commands.commandclasses.GeneralCommands;
 import frc.trigon.robot.RobotContainer;
 import frc.trigon.robot.commands.commandclasses.WaitUntilChangeCommand;
 import frc.trigon.robot.constants.FieldConstants;
 import frc.trigon.robot.constants.OperatorConstants;
+import frc.trigon.robot.constants.AutonomousConstants;
 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 frc.trigon.robot.commands.commandfactories.CoralCollectionCommands;

24-30: Fix ConditionalCommand constructor parameter order.

The getContinuousConditionalCommand method is likely expecting the same parameter order as ConditionalCommand, but the condition logic appears to be incorrect for the intended behavior.

Based on the naming and logic, this should run autonomous when the condition is true. Apply this fix:

-        return GeneralCommands.getContinuousConditionalCommand(
-                getAutonomouslyScoreInReefFromGripperCommand(shouldScoreRight).asProxy(),
-                getManuallyScoreInReefFromGripperCommand().asProxy(),
-                () -> SHOULD_SCORE_AUTONOMOUSLY && REEF_CHOOSER.getScoringLevel() != ScoringLevel.L1
-        ).until(() -> REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1);
+        return GeneralCommands.getContinuousConditionalCommand(
+                getAutonomouslyScoreInReefFromGripperCommand(shouldScoreRight).asProxy(),
+                getManuallyScoreInReefFromGripperCommand().asProxy(),
+                () -> SHOULD_SCORE_AUTONOMOUSLY && REEF_CHOOSER.getScoringLevel() != ScoringLevel.L1
+        ).until(() -> REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1);

32-39: Fix method call and parameter type mismatch.

CoralCollectionCommands.getLoadCoralCommand() doesn't exist, and ElevatorCommands.getSetTargetStateCommand() expects a value, not a method reference.

Apply this fix:

-        return CoralCollectionCommands.getLoadCoralCommand().asProxy().andThen(
+        return CoralCollectionCommands.getCoralCollectionCommand().asProxy().andThen(
                 new ParallelCommandGroup(
-                        ElevatorCommands.getSetTargetStateCommand(REEF_CHOOSER::getElevatorState).raceWith(new WaitUntilChangeCommand<>(REEF_CHOOSER::getElevatorState)).repeatedly(),
+                        ElevatorCommands.getSetTargetStateCommand(REEF_CHOOSER.getElevatorState()).raceWith(new WaitUntilChangeCommand<>(REEF_CHOOSER::getElevatorState)).repeatedly(),
                         getArmScoringSequenceCommand()
                 ).asProxy()
         );

41-51: Fix method call and remove trailing andThen().

Same issues as the manual command, plus a stray .andThen() with no arguments.

Apply this fix:

-                CoralCollectionCommands.getLoadCoralCommand().asProxy().andThen(
+                CoralCollectionCommands.getCoralCollectionCommand().asProxy().andThen(
                         new ParallelCommandGroup(
                                 getOpenElevatorWhenCloseToReefCommand(shouldScoreRight),
                                 getAutoGripperScoringSequenceCommand(shouldScoreRight)
                         ).asProxy().raceWith(new WaitUntilChangeCommand<>(REEF_CHOOSER::getElevatorState)).repeatedly()
                 ),
                 getAutonomousDriveToReefThenManualDriveCommand(shouldScoreRight)
-        ).andThen();
+        );

74-100: Fix references to non-existent GripperCommands class.

These methods reference GripperCommands which doesn't exist in the codebase.

These methods need to be updated to use existing APIs or marked as TODOs until the GripperCommands class is implemented:

     private static Command scoreFromGripperReefChooserCommand(boolean shouldScoreRight) {
+        // TODO: Implement when GripperCommands class is available
+        return Commands.none();
+        /*
         return new SequentialCommandGroup(
-                GripperCommands.getPrepareForStateCommand(REEF_CHOOSER::getGripperState).raceWith(
+                // GripperCommands.getPrepareForStateCommand(REEF_CHOOSER::getGripperState).raceWith(
                         new SequentialCommandGroup(
                                 new WaitUntilCommand(() -> canAutonomouslyReleaseFromGripper(shouldScoreRight)),
                                 new WaitUntilChangeCommand<>(RobotContainer.ROBOT_POSE_ESTIMATOR::getEstimatedRobotPose)
-                        )
-                ).until(OperatorConstants.CONTINUE_TRIGGER),
-                GripperCommands.getSetTargetStateCommand(REEF_CHOOSER::getGripperState).finallyDo(OperatorConstants.REEF_CHOOSER::switchReefSide)
+                        // )
+                // ).until(OperatorConstants.CONTINUE_TRIGGER),
+                // GripperCommands.getSetTargetStateCommand(REEF_CHOOSER::getGripperState).finallyDo(OperatorConstants.REEF_CHOOSER::switchReefSide)
         );
+        */
     }

Apply similar fixes to the other methods that reference GripperCommands.


102-107: Fix parameter type mismatch and missing AutonomousConstants.

The method expects a value, not a method reference, and AutonomousConstants is missing.

Apply this fix:

         return GeneralCommands.runWhen(
-                ElevatorCommands.getSetTargetStateCommand(REEF_CHOOSER::getElevatorState),
+                ElevatorCommands.getSetTargetStateCommand(REEF_CHOOSER.getElevatorState()),
                 () -> calculateDistanceToTargetScoringPose(shouldScoreRight) < AutonomousConstants.MINIMUM_DISTANCE_FROM_REEF_TO_OPEN_ELEVATOR
         );

213-233: Use explicit enum mapping instead of ordinal-based logic.

The current implementation uses ordinal-based mapping which is brittle and error-prone. The mapping appears to be off by one.

Replace with explicit enum mapping:

         private ElevatorConstants.ElevatorState determineElevatorState() {
-            return switch (ordinal()) {
-                case 0 -> ElevatorConstants.ElevatorState.REST;
-                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());
-            };
+            return switch (this) {
+                case L1 -> ElevatorConstants.ElevatorState.SCORE_L1;
+                case L2 -> ElevatorConstants.ElevatorState.SCORE_L2;
+                case L3 -> ElevatorConstants.ElevatorState.SCORE_L3;
+                case L4 -> ElevatorConstants.ElevatorState.SCORE_L4;
+            };
         }

         private ArmConstants.ArmState determineArmState() {
-            return switch (ordinal()) {
-                case 0 -> null;
-                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());
-            };
+            return switch (this) {
+                case L1 -> ArmConstants.ArmState.SCORE_L1;
+                case L2 -> ArmConstants.ArmState.SCORE_L2;
+                case L3 -> ArmConstants.ArmState.SCORE_L3;
+                case L4 -> ArmConstants.ArmState.SCORE_L4;
+            };
         }

235-239: Fix incorrect level calculation logic.

The current logic incorrectly maps L1 (ordinal 0) to level 1, but other levels are off by one.

Apply this fix:

         private int calculateLevel() {
-            if (ordinal() == 0)
-                return 1;
-            return ordinal();
+            return ordinal() + 1;
         }

53-59: Fix compilation errors in arm scoring sequence.

Multiple syntax and API issues need to be addressed.

Based on the pipeline errors and other similar patterns, apply this fix:

         return new SequentialCommandGroup(
-                ArmCommands.getSetTargetStateCommand()
-                        .unless(() -> RobotContainer.ELEVATOR.atState(REEF_CHOOSER.getElevatorState()) || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2 || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
+                ArmCommands.getSetTargetStateCommand(REEF_CHOOSER.getArmState())
+                        .unless(() -> RobotContainer.ELEVATOR.atTargetState() 
+                                || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2 
+                                || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1),
                 scoreFromGripperReefChooserCommand()
         );
🧹 Nitpick comments (1)
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (1)

109-117: Consider uncommenting autonomous drive command.

The autonomous drive functionality is commented out, which may be intentional for testing but should be addressed.

If this functionality is needed, uncomment and fix the method:

-//    private static Command getAutonomousDriveToReefThenManualDriveCommand(boolean shouldScoreRight) {
-//        return new SequentialCommandGroup(
-//                SwerveCommands.getDriveToPoseCommand(
-//                        () -> CoralPlacingCommands.calculateClosestScoringPose(shouldScoreRight),
-//                        AutonomousConstants.DRIVE_TO_REEF_CONSTRAINTS
-//                ),
-//                GeneralCommands.getFieldRelativeDriveCommand()
-//        );
-//    }
+    private static Command getAutonomousDriveToReefThenManualDriveCommand(boolean shouldScoreRight) {
+        // TODO: Implement when SwerveCommands.getDriveToPoseCommand is available
+        return GeneralCommands.getFieldRelativeDriveCommand();
+        /*
+        return new SequentialCommandGroup(
+                SwerveCommands.getDriveToPoseCommand(
+                        () -> CoralPlacingCommands.calculateClosestScoringPose(shouldScoreRight),
+                        AutonomousConstants.DRIVE_TO_REEF_CONSTRAINTS
+                ),
+                GeneralCommands.getFieldRelativeDriveCommand()
+        );
+        */
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5315eb0 and f37501b.

📒 Files selected for processing (1)
  • src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-11T09:14:50.990Z
Learnt from: levyishai
PR: Programming-TRIGON/RobotCodeOffSeason2025#15
File: src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java:163-166
Timestamp: 2025-09-11T09:14:50.990Z
Learning: The Swerve subsystem's atPose method is designed to accept FlippablePose2d directly, not Pose2d. The method signature is `public boolean atPose(FlippablePose2d pose2d)` and it handles the internal conversion to Pose2d by calling pose2d.get().

Applied to files:

  • src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
📚 Learning: 2025-09-11T09:14:50.990Z
Learnt from: levyishai
PR: Programming-TRIGON/RobotCodeOffSeason2025#15
File: src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java:163-166
Timestamp: 2025-09-11T09:14:50.990Z
Learning: FlippablePose2d is a custom class in this codebase that can be used directly with the Swerve subsystem's atPose method, without needing to call .get() to convert it to a standard Pose2d.

Applied to files:

  • src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
🧬 Code graph analysis (1)
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (13)
src/main/java/frc/trigon/robot/RobotContainer.java (1)
  • RobotContainer (45-119)
src/main/java/frc/trigon/robot/commands/commandclasses/WaitUntilChangeCommand.java (1)
  • WaitUntilChangeCommand (7-31)
src/main/java/frc/trigon/robot/constants/FieldConstants.java (1)
  • FieldConstants (16-113)
src/main/java/frc/trigon/robot/constants/OperatorConstants.java (1)
  • OperatorConstants (10-60)
src/main/java/frc/trigon/robot/misc/ReefChooser.java (1)
  • ReefChooser (16-130)
src/main/java/frc/trigon/robot/subsystems/arm/ArmCommands.java (1)
  • ArmCommands (12-50)
src/main/java/frc/trigon/robot/subsystems/arm/ArmConstants.java (1)
  • ArmConstants (32-255)
src/main/java/frc/trigon/robot/subsystems/elevator/ElevatorCommands.java (1)
  • ElevatorCommands (10-35)
src/main/java/frc/trigon/robot/subsystems/elevator/ElevatorConstants.java (1)
  • ElevatorConstants (27-188)
src/main/java/lib/utilities/flippable/FlippablePose2d.java (1)
  • FlippablePose2d (11-58)
src/main/java/lib/utilities/flippable/FlippableTranslation2d.java (1)
  • FlippableTranslation2d (9-35)
src/main/java/frc/trigon/robot/commands/commandfactories/GeneralCommands.java (1)
  • GeneralCommands (15-65)
src/main/java/frc/trigon/robot/commands/commandfactories/CoralCollectionCommands.java (1)
  • CoralCollectionCommands (17-52)
🪛 GitHub Actions: Java CI with Gradle
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java

[error] 56-56: gradlew build: ')' expected at CoralPlacingCommands.java:56 (likely missing semicolon after chained '.unless(...)' call).


[error] 57-57: gradlew build: ';' expected at CoralPlacingCommands.java:57 (likely due to the previous line missing a semicolon).

🔇 Additional comments (1)
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (1)

153-157: LGTM - atPose method accepts FlippablePose2d directly.

Based on the retrieved learnings, the Swerve subsystem's atPose method accepts FlippablePose2d directly and handles the internal conversion.

Comment on lines 61 to 72
private static Command getAutoGripperScoringSequenceCommand(boolean shouldScoreRight) {
return new SequentialCommandGroup(
ArmCommands.getSetTargetStateCommand(ArmCommands.getSetTargetStateCommand().OPEN_FOR_NOT_HITTING_REEF)
.unless(() -> RobotContainer.ELEVATOR.atState(REEF_CHOOSER.getElevatorState()) || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2 || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
.until(RobotContainer.ELEVATOR::isCloseEnoughToOpenGripper),
new ConditionalCommand(
scoreFromGripperInL4Command(shouldScoreRight),
scoreFromGripperReefChooserCommand(shouldScoreRight),
() -> REEF_CHOOSER.getScoringLevel() == ScoringLevel.L4
)
);
}
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 multiple compilation errors in gripper scoring sequence.

The code references non-existent classes and methods, and has syntax errors.

This method references GripperCommands and other classes that don't exist in the codebase. The implementation needs to be updated to use existing APIs or the missing classes need to be added to the PR. Since this appears to be placeholder code, consider commenting it out or implementing with existing classes:

     private static Command getAutoGripperScoringSequenceCommand(boolean shouldScoreRight) {
+        // TODO: Implement when GripperCommands class is available
+        return Commands.none();
+        /*
         return new SequentialCommandGroup(
-                ArmCommands.getSetTargetStateCommand(ArmCommands.getSetTargetStateCommand().OPEN_FOR_NOT_HITTING_REEF)
-                        .unless(() -> RobotContainer.ELEVATOR.atState(REEF_CHOOSER.getElevatorState()) || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2 || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
-                        .until(RobotContainer.ELEVATOR::isCloseEnoughToOpenGripper),
+                // GripperCommands.getSetTargetStateCommand(GripperConstants.GripperState.OPEN_FOR_NOT_HITTING_REEF)
+                //         .unless(() -> RobotContainer.ELEVATOR.atTargetState() 
+                //                 || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2 
+                //                 || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
+                //         .until(RobotContainer.ELEVATOR::atTargetState),
                 new ConditionalCommand(
                         scoreFromGripperInL4Command(shouldScoreRight),
                         scoreFromGripperReefChooserCommand(shouldScoreRight),
                         () -> REEF_CHOOSER.getScoringLevel() == ScoringLevel.L4
                 )
         );
+        */
     }
📝 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
private static Command getAutoGripperScoringSequenceCommand(boolean shouldScoreRight) {
return new SequentialCommandGroup(
ArmCommands.getSetTargetStateCommand(ArmCommands.getSetTargetStateCommand().OPEN_FOR_NOT_HITTING_REEF)
.unless(() -> RobotContainer.ELEVATOR.atState(REEF_CHOOSER.getElevatorState()) || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2 || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
.until(RobotContainer.ELEVATOR::isCloseEnoughToOpenGripper),
new ConditionalCommand(
scoreFromGripperInL4Command(shouldScoreRight),
scoreFromGripperReefChooserCommand(shouldScoreRight),
() -> REEF_CHOOSER.getScoringLevel() == ScoringLevel.L4
)
);
}
private static Command getAutoGripperScoringSequenceCommand(boolean shouldScoreRight) {
// TODO: Implement when GripperCommands class is available
return Commands.none();
/*
return new SequentialCommandGroup(
// GripperCommands.getSetTargetStateCommand(GripperConstants.GripperState.OPEN_FOR_NOT_HITTING_REEF)
// .unless(() -> RobotContainer.ELEVATOR.atTargetState()
// || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L2
// || REEF_CHOOSER.getScoringLevel() == ScoringLevel.L1)
// .until(RobotContainer.ELEVATOR::atTargetState),
new ConditionalCommand(
scoreFromGripperInL4Command(shouldScoreRight),
scoreFromGripperReefChooserCommand(shouldScoreRight),
() -> REEF_CHOOSER.getScoringLevel() == ScoringLevel.L4
)
);
*/
}
🤖 Prompt for AI Agents
In
src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
around lines 61 to 72, the getAutoGripperScoringSequenceCommand method
references non-existent classes/methods and contains syntax errors (invalid
nested call to ArmCommands.getSetTargetStateCommand and references to missing
GripperCommands), which causes compilation failures; replace calls to undefined
classes/methods with the correct existing APIs (e.g., call the real ArmCommands
method once to get the target state command, use existing RobotContainer
gripper/elevator helpers, and swap any GripperCommands.* references to the
actual gripper command class in the codebase), or if the intended behavior is
not yet implemented, comment out or return a safe no-op/placeholder Command
until the proper APIs are available; ensure conditional logic uses valid method
references and lambdas and import any referenced classes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/frc/trigon/robot/subsystems/elevator/Elevator.java (1)

51-53: Fix SysId logging units (rotations ≠ meters).

You're reporting position/velocity in meters but feeding rotations/rotations-per-second. This corrupts SysId data and derived gains.

Apply:

-                .linearPosition(Units.Meters.of(getPositionRotations()))
-                .linearVelocity(Units.MetersPerSecond.of(masterMotor.getSignal(TalonFXSignal.VELOCITY)))
+                .linearPosition(Units.Meters.of(getPositionMeters()))
+                .linearVelocity(Units.MetersPerSecond.of(rotationsToMeters(masterMotor.getSignal(TalonFXSignal.VELOCITY))))
🧹 Nitpick comments (4)
src/main/java/frc/trigon/robot/subsystems/elevator/Elevator.java (4)

39-46: Also apply brake/stop to follower motor.

Keeps both motors’ neutral/drive states consistent; avoids asymmetric drag.

 public void setBrake(boolean brake) {
-    masterMotor.setBrake(brake);
+    masterMotor.setBrake(brake);
+    ElevatorConstants.FOLLOWER_MOTOR.setBrake(brake);
 }
 ...
 public void stop() {
-    masterMotor.stopMotor();
+    masterMotor.stopMotor();
+    ElevatorConstants.FOLLOWER_MOTOR.stopMotor();
 }

78-85: LGTM; minor API polish and tolerance edge-case.

Consider param rename to avoid shadowing and allow equality in tolerance.

-    public boolean atState(ElevatorConstants.ElevatorState targetState) {
-        return targetState == this.targetState && atTargetState();
+    public boolean atState(ElevatorConstants.ElevatorState expectedState) {
+        return expectedState == this.targetState && atTargetState();
     }
 ...
-        return currentToTargetStateDifferenceMeters < ElevatorConstants.HEIGHT_TOLERANCE_METERS;
+        return currentToTargetStateDifferenceMeters <= ElevatorConstants.HEIGHT_TOLERANCE_METERS;

111-113: Use >= for stage limit transition.

Prevents a 1-step “deadband” exactly at the limit.

-    private boolean isSecondStageComponentLimitReached() {
-        return getPositionMeters() > ElevatorConstants.SECOND_ELEVATOR_COMPONENT_EXTENDED_LENGTH_METERS;
-    }
+    private boolean isSecondStageComponentLimitReached() {
+        return getPositionMeters() >= ElevatorConstants.SECOND_ELEVATOR_COMPONENT_EXTENDED_LENGTH_METERS;
+    }

123-127: Clamp speed scalar and confirm dynamic-request mutation semantics.

Avoid accidental overspeed; Phoenix 6 allows mutating DynamicMotionMagicVoltage fields, but confirm your version. If uncertain, rebuild the request with withVelocity/withAcceleration.

-    private void scalePositionRequestSpeed(double speedScalar) {
-        positionRequest.Velocity = ElevatorConstants.DEFAULT_MAXIMUM_VELOCITY * speedScalar;
-        positionRequest.Acceleration = ElevatorConstants.DEFAULT_MAXIMUM_ACCELERATION * speedScalar;
+    private void scalePositionRequestSpeed(double speedScalar) {
+        final double clamped = Math.max(0.0, Math.min(1.0, speedScalar));
+        positionRequest.Velocity = ElevatorConstants.DEFAULT_MAXIMUM_VELOCITY * clamped;
+        positionRequest.Acceleration = ElevatorConstants.DEFAULT_MAXIMUM_ACCELERATION * clamped;
         positionRequest.Jerk = positionRequest.Acceleration * 10;
     }

Add (outside this hunk) if you prefer a helper: edu.wpi.first.math.MathUtil.clamp.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f37501b and 4559971.

📒 Files selected for processing (2)
  • src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java (1 hunks)
  • src/main/java/frc/trigon/robot/subsystems/elevator/Elevator.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/frc/trigon/robot/subsystems/elevator/Elevator.java (1)
src/main/java/frc/trigon/robot/subsystems/elevator/ElevatorConstants.java (1)
  • ElevatorConstants (27-188)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants