Skip to content

feat(commands): collector commands#21

Open
Baconing wants to merge 3 commits intomasterfrom
collector-commands
Open

feat(commands): collector commands#21
Baconing wants to merge 3 commits intomasterfrom
collector-commands

Conversation

@Baconing
Copy link
Member

@Baconing Baconing commented Mar 17, 2026

blocked by #18

Summary by CodeRabbit

Release Notes

  • New Features

    • Added collector subsystem controls: raise, lower, intake, and variable speed drive commands.
    • Added robot constants for collector arm positioning.
  • Refactor

    • Simplified internal subsystem architecture by removing abstraction layer, reducing complexity in collector, shooter, turntable, vision, and drive subsystems.
    • Removed simulation-specific hardware initialization patterns.
  • Chores

    • Removed obsolete build task for replay functionality.
    • Removed unused logging and serialization infrastructure.

the robot doesnt work in simulation and the abstractions are causing trouble so
the robot doesnt work in simulation and the abstractions are causing trouble so
@Baconing Baconing self-assigned this Mar 17, 2026
@Baconing Baconing added the Status/Blocked Something is blocking this issue or pull request label Mar 17, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Walkthrough

This PR removes the IO abstraction pattern across multiple subsystems (Collector, Shooter, Swerve Drive, Turntable, Vision) and eliminates related logging infrastructure. Subsystems now receive direct motor and camera dependencies instead of IO interfaces. The replayWatch Gradle task is also removed, and teleop drive command wiring is updated.

Changes

Cohort / File(s) Summary
Build Configuration
build.gradle.kts
Removed replayWatch JavaExec task registration.
Collector Subsystem
src/main/kotlin/org/frc5183/robot/subsystems/collector/CollectorSubsystem.kt, src/main/kotlin/org/frc5183/robot/subsystems/collector/io/*
Replaced IO-based architecture with direct SparkMax motor injection; added arm/intake speed properties and atTop/atBottom state; introduced new command classes (DriveCollector, IntakeCommand, LowerCollector, RaiseCollector); removed CollectorIO interface and RealCollectorIO implementation.
Shooter Subsystem
src/main/kotlin/org/frc5183/robot/subsystems/shooter/ShooterSubsystem.kt, src/main/kotlin/org/frc5183/robot/subsystems/shooter/io/*
Replaced IO-based wiring with direct SparkMax motors (shooter, intake, feeder) as public properties; updated logging from inputs to direct Logger calls; removed ShooterIO interface, RealShooterIO, and ShooterIOInputs.
Swerve Drive Subsystem
src/main/kotlin/org/frc5183/robot/subsystems/drive/SwerveDriveSubsystem.kt, src/main/kotlin/org/frc5183/robot/subsystems/drive/io/*, src/main/kotlin/org/frc5183/robot/Robot.kt
Replaced IO interface with direct SwerveDrive instance; removed real/sim branching in initialization; wired vision measurements directly; removed RealSwerveDriveIO, SimulatedSwerveDriveIO, SwerveDriveIO, and SwerveDriveIOInputs.
Turntable Subsystem
src/main/kotlin/org/frc5183/robot/subsystems/turntable/TurntableSubsystem.kt, src/main/kotlin/org/frc5183/robot/subsystems/turntable/io/*
Replaced IO abstraction with direct SparkMax motor and PhotonCamera injection; updated speed and target access to use motor/camera directly; removed TurntableIO, RealTurntableIO, and TurntableIOInputs.
Vision Subsystem
src/main/kotlin/org/frc5183/robot/subsystems/vision/VisionSubsystem.kt, src/main/kotlin/org/frc5183/robot/subsystems/vision/io/*
Replaced IO-based camera wiring with direct FixedCamera instances (front/back); exposed frontTargets, backTargets, frontRobotPose, backRobotPose as public properties; removed VisionIO, RealVisionIO, and VisionIOInputs.
Logging Infrastructure
src/main/kotlin/org/frc5183/robot/logging/AutoLogInputs.kt, src/main/kotlin/org/frc5183/robot/logging/struct/EstimatedRobotPoseStruct.kt, src/main/kotlin/org/frc5183/robot/logging/struct/PhotonTrackedTargetStruct.kt
Removed AutoLogInputs base class and struct implementations for EstimatedRobotPose and PhotonTrackedTarget.
Constants & Controls
src/main/kotlin/org/frc5183/robot/constants/Constants.kt, src/main/kotlin/org/frc5183/robot/constants/Controls.kt
Added Constants object with three Angle properties (COLLECTOR_ARM_TOP, COLLECTOR_ARM_BOTTOM, COLLECTOR_ARM_DELTA); replaced TELEOP_DRIVE_COMMAND with lateinit DRIVE_COMMAND.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PR #13: Overlapping drive subsystem refactoring (SwerveDriveSubsystem, RealSwerveDriveIO, teleop drive wiring).
  • PR #10: Directly related collector subsystem IO removal and direct motor injection pattern.
  • PR #9: Related vision IO abstraction removal and EstimatedRobotPose/PhotonTrackedTarget struct deletions.

Suggested labels

Kind/Feature

Suggested reviewers

  • Trip-kun

Poem

🐰 No more layers of abstraction deep,
Motors dance where circuits leap,
Direct wiring, clean and bright,
The code hops forward, light and light!
thump thump goes the refactor's beat. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(commands): collector commands' accurately describes the main feature additions: new DriveCollector, IntakeCommand, LowerCollector, and RaiseCollector command classes for the collector subsystem.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch collector-commands
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai bot added the Kind/Feature New functionality label Mar 17, 2026
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: 5

🧹 Nitpick comments (5)
src/main/kotlin/org/frc5183/robot/subsystems/shooter/ShooterSubsystem.kt (1)

7-11: Consider making motor properties private for encapsulation.

Exposing shooter, intake, and feeder as public val properties allows external code to bypass the subsystem's control methods and directly manipulate the motors. In FRC's command-based architecture, this could lead to command conflicts.

♻️ Suggested change to improve encapsulation
 class ShooterSubsystem(
-    val shooter: SparkMax,
-    val intake: SparkMax,
-    val feeder: SparkMax,
+    private val shooter: SparkMax,
+    private val intake: SparkMax,
+    private val feeder: SparkMax,
 ) : SubsystemBase() {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/subsystems/shooter/ShooterSubsystem.kt`
around lines 7 - 11, The ShooterSubsystem currently exposes SparkMax instances
as public vals (shooter, intake, feeder); make these properties private (e.g.,
change to private val shooter/intake/feeder) to enforce encapsulation and
prevent external commands from directly manipulating motor controllers, and if
external access is required expose only controlled methods or read-only status
getters on ShooterSubsystem (e.g., getShooterVelocity/getIntakeState) so all
motor actions go through the subsystem's control methods.
src/main/kotlin/org/frc5183/robot/commands/collector/RaiseCollector.kt (1)

5-5: Unused import: ShooterSubsystem.

This import is not used in the file.

♻️ Proposed fix
-import org.frc5183.robot.subsystems.shooter.ShooterSubsystem
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/commands/collector/RaiseCollector.kt` at
line 5, Remove the unused import of
org.frc5183.robot.subsystems.shooter.ShooterSubsystem from RaiseCollector.kt;
open the RaiseCollector class/file and delete the import line referencing
ShooterSubsystem so only necessary imports remain and the file compiles without
unused imports.
src/main/kotlin/org/frc5183/robot/constants/Controls.kt (1)

6-8: Unused imports: TeleopDriveCommand and SwerveInputStream.

These imports appear to be leftover from the refactor and are no longer used.

♻️ Proposed cleanup
-import org.frc5183.robot.commands.drive.TeleopDriveCommand
-import swervelib.SwerveInputStream
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/constants/Controls.kt` around lines 6 - 8,
The file imports TeleopDriveCommand and SwerveInputStream but neither symbol is
referenced; remove the unused imports (the lines importing TeleopDriveCommand
and SwerveInputStream) from Controls.kt to clean up the code and eliminate the
unused-import warnings, leaving only necessary imports such as
SwerveDriveSubsystem.
src/main/kotlin/org/frc5183/robot/subsystems/collector/CollectorSubsystem.kt (1)

60-62: Consider making helper functions private.

speedIsUp and speedIsDown appear to be internal implementation details. Making them private would reduce the public API surface.

♻️ Proposed refactor
-    fun speedIsUp(speed: Double): Boolean = speed.sign == 1.0
+    private fun speedIsUp(speed: Double): Boolean = speed.sign == 1.0

-    fun speedIsDown(speed: Double): Boolean = speed.sign == -1.0
+    private fun speedIsDown(speed: Double): Boolean = speed.sign == -1.0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/subsystems/collector/CollectorSubsystem.kt`
around lines 60 - 62, The functions speedIsUp and speedIsDown are internal
helpers exposed publicly; make them private to reduce the public API surface by
changing their visibility to private (i.e., mark functions speedIsUp(speed:
Double) and speedIsDown(speed: Double) as private) so they remain available
inside CollectorSubsystem but are not part of the class's public interface.
src/main/kotlin/org/frc5183/robot/commands/collector/IntakeCommand.kt (1)

5-5: Unused import: ShooterSubsystem.

This import is not used in the file.

♻️ Proposed fix
-import org.frc5183.robot.subsystems.shooter.ShooterSubsystem
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/commands/collector/IntakeCommand.kt` at
line 5, Remove the unused import of ShooterSubsystem from IntakeCommand.kt;
locate the import line importing
org.frc5183.robot.subsystems.shooter.ShooterSubsystem at the top of the file (in
the IntakeCommand class/file) and delete it so only actually used imports
remain.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/kotlin/org/frc5183/robot/commands/collector/LowerCollector.kt`:
- Line 5: The import of ShooterSubsystem at the top of LowerCollector is unused;
open the LowerCollector class and remove the line importing
org.frc5183.robot.subsystems.shooter.ShooterSubsystem so the file no longer
contains an unused import (leave all other imports and the LowerCollector class
unchanged).

In `@src/main/kotlin/org/frc5183/robot/constants/Constants.kt`:
- Around line 5-9: The three vals in the Constants object (COLLECTOR_ARM_TOP,
COLLECTOR_ARM_BOTTOM, COLLECTOR_ARM_DELTA) are declared without initializers and
will not compile; fix by assigning each an appropriate Angle value (e.g., using
Units to convert degrees/radians as required) and add the import
edu.wpi.first.units.Units at the top so you can construct the Angle constants
(update the Constants object to initialize COLLECTOR_ARM_TOP,
COLLECTOR_ARM_BOTTOM, and COLLECTOR_ARM_DELTA with concrete Angle expressions).

In `@src/main/kotlin/org/frc5183/robot/constants/Controls.kt`:
- Around line 15-20: The registerControls function is setting
drive.defaultCommand to an undefined symbol TELEOP_DRIVE_COMMAND; replace that
reference with the declared property DRIVE_COMMAND so the code compiles (update
the assignment in registerControls where drive.defaultCommand is set to use
DRIVE_COMMAND instead of TELEOP_DRIVE_COMMAND).

In
`@src/main/kotlin/org/frc5183/robot/subsystems/collector/CollectorSubsystem.kt`:
- Around line 38-39: The periodic safety check in CollectorSubsystem incorrectly
uses speedIsUp(armSpeed) for the bottom limit; change the condition that
currently reads if (atBottom && speedIsUp(armSpeed)) stopArm() to use
speedIsDown(armSpeed) instead so the arm stops when it's trying to move down
into the bottom limit; locate this logic in the CollectorSubsystem class where
atTop, atBottom, armSpeed, speedIsUp/speedIsDown and stopArm are referenced and
update the predicate accordingly.

In
`@src/main/kotlin/org/frc5183/robot/subsystems/turntable/TurntableSubsystem.kt`:
- Around line 13-22: The targets getter currently calls camera.allUnreadResults
which is destructive and periodic() logs via targets, draining the camera queue
before AlignTurntable.execute() can read them; to fix, add a backing field
(e.g., cachedTargets: Array<PhotonTrackedTarget>) and update it once at the
start of each periodic() by calling camera.allUnreadResults (or use
FixedCamera.updateUnreadResults() pattern), then have the targets property
return cachedTargets so subsequent calls (including AlignTurntable.execute()) in
the same cycle see the same non-destructive snapshot.

---

Nitpick comments:
In `@src/main/kotlin/org/frc5183/robot/commands/collector/IntakeCommand.kt`:
- Line 5: Remove the unused import of ShooterSubsystem from IntakeCommand.kt;
locate the import line importing
org.frc5183.robot.subsystems.shooter.ShooterSubsystem at the top of the file (in
the IntakeCommand class/file) and delete it so only actually used imports
remain.

In `@src/main/kotlin/org/frc5183/robot/commands/collector/RaiseCollector.kt`:
- Line 5: Remove the unused import of
org.frc5183.robot.subsystems.shooter.ShooterSubsystem from RaiseCollector.kt;
open the RaiseCollector class/file and delete the import line referencing
ShooterSubsystem so only necessary imports remain and the file compiles without
unused imports.

In `@src/main/kotlin/org/frc5183/robot/constants/Controls.kt`:
- Around line 6-8: The file imports TeleopDriveCommand and SwerveInputStream but
neither symbol is referenced; remove the unused imports (the lines importing
TeleopDriveCommand and SwerveInputStream) from Controls.kt to clean up the code
and eliminate the unused-import warnings, leaving only necessary imports such as
SwerveDriveSubsystem.

In
`@src/main/kotlin/org/frc5183/robot/subsystems/collector/CollectorSubsystem.kt`:
- Around line 60-62: The functions speedIsUp and speedIsDown are internal
helpers exposed publicly; make them private to reduce the public API surface by
changing their visibility to private (i.e., mark functions speedIsUp(speed:
Double) and speedIsDown(speed: Double) as private) so they remain available
inside CollectorSubsystem but are not part of the class's public interface.

In `@src/main/kotlin/org/frc5183/robot/subsystems/shooter/ShooterSubsystem.kt`:
- Around line 7-11: The ShooterSubsystem currently exposes SparkMax instances as
public vals (shooter, intake, feeder); make these properties private (e.g.,
change to private val shooter/intake/feeder) to enforce encapsulation and
prevent external commands from directly manipulating motor controllers, and if
external access is required expose only controlled methods or read-only status
getters on ShooterSubsystem (e.g., getShooterVelocity/getIntakeState) so all
motor actions go through the subsystem's control methods.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 43a90ba5-d0d3-463e-bac0-e9d3adf46cd1

📥 Commits

Reviewing files that changed from the base of the PR and between a44fda8 and 4ede88a.

📒 Files selected for processing (32)
  • build.gradle.kts
  • src/main/kotlin/org/frc5183/robot/Robot.kt
  • src/main/kotlin/org/frc5183/robot/commands/collector/DriveCollector.kt
  • src/main/kotlin/org/frc5183/robot/commands/collector/IntakeCommand.kt
  • src/main/kotlin/org/frc5183/robot/commands/collector/LowerCollector.kt
  • src/main/kotlin/org/frc5183/robot/commands/collector/RaiseCollector.kt
  • src/main/kotlin/org/frc5183/robot/constants/Constants.kt
  • src/main/kotlin/org/frc5183/robot/constants/Controls.kt
  • src/main/kotlin/org/frc5183/robot/logging/AutoLogInputs.kt
  • src/main/kotlin/org/frc5183/robot/logging/struct/EstimatedRobotPoseStruct.kt
  • src/main/kotlin/org/frc5183/robot/logging/struct/PhotonTrackedTargetStruct.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/collector/CollectorSubsystem.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/collector/io/CollectorIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/collector/io/CollectorIOInputs.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/collector/io/RealCollectorIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/drive/SwerveDriveSubsystem.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/drive/io/RealSwerveDriveIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/drive/io/SimulatedSwerveDriveIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/drive/io/SwerveDriveIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/drive/io/SwerveDriveIOInputs.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/shooter/ShooterSubsystem.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/shooter/io/RealShooterIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/shooter/io/ShooterIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/shooter/io/ShooterIOInputs.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/turntable/TurntableSubsystem.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/turntable/io/RealTurntableIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/turntable/io/TurntableIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/turntable/io/TurntableIOInputs.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/vision/VisionSubsystem.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/vision/io/RealVisionIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/vision/io/VisionIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/vision/io/VisionIOInputs.kt
💤 Files with no reviewable changes (20)
  • build.gradle.kts
  • src/main/kotlin/org/frc5183/robot/subsystems/vision/io/RealVisionIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/collector/io/CollectorIOInputs.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/collector/io/CollectorIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/shooter/io/ShooterIOInputs.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/vision/io/VisionIO.kt
  • src/main/kotlin/org/frc5183/robot/logging/struct/EstimatedRobotPoseStruct.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/drive/io/SwerveDriveIOInputs.kt
  • src/main/kotlin/org/frc5183/robot/logging/AutoLogInputs.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/turntable/io/RealTurntableIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/drive/io/RealSwerveDriveIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/shooter/io/RealShooterIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/turntable/io/TurntableIOInputs.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/drive/io/SwerveDriveIO.kt
  • src/main/kotlin/org/frc5183/robot/logging/struct/PhotonTrackedTargetStruct.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/shooter/io/ShooterIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/turntable/io/TurntableIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/collector/io/RealCollectorIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/drive/io/SimulatedSwerveDriveIO.kt
  • src/main/kotlin/org/frc5183/robot/subsystems/vision/io/VisionIOInputs.kt


import edu.wpi.first.wpilibj2.command.Command
import org.frc5183.robot.subsystems.collector.CollectorSubsystem
import org.frc5183.robot.subsystems.shooter.ShooterSubsystem
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused import.

ShooterSubsystem is imported but never used in this class.

🧹 Proposed fix
 import edu.wpi.first.wpilibj2.command.Command
 import org.frc5183.robot.subsystems.collector.CollectorSubsystem
-import org.frc5183.robot.subsystems.shooter.ShooterSubsystem
📝 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
import org.frc5183.robot.subsystems.shooter.ShooterSubsystem
import edu.wpi.first.wpilibj2.command.Command
import org.frc5183.robot.subsystems.collector.CollectorSubsystem
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/commands/collector/LowerCollector.kt` at
line 5, The import of ShooterSubsystem at the top of LowerCollector is unused;
open the LowerCollector class and remove the line importing
org.frc5183.robot.subsystems.shooter.ShooterSubsystem so the file no longer
contains an unused import (leave all other imports and the LowerCollector class
unchanged).

Comment on lines +5 to +9
object Constants {
val COLLECTOR_ARM_TOP: Angle
val COLLECTOR_ARM_BOTTOM: Angle
val COLLECTOR_ARM_DELTA: Angle
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Uninitialized val properties will cause compilation error.

In Kotlin, val properties within an object declaration must be initialized. These three properties lack initializers, which will fail compilation.

🐛 Proposed fix: Initialize the constants with appropriate values
 object Constants {
-    val COLLECTOR_ARM_TOP: Angle
-    val COLLECTOR_ARM_BOTTOM: Angle
-    val COLLECTOR_ARM_DELTA: Angle
+    val COLLECTOR_ARM_TOP: Angle = Units.Rotations.of(0.0) // TODO: Set actual top position
+    val COLLECTOR_ARM_BOTTOM: Angle = Units.Rotations.of(0.0) // TODO: Set actual bottom position
+    val COLLECTOR_ARM_DELTA: Angle = Units.Rotations.of(0.01) // TODO: Set actual tolerance
 }

You'll need to add the import:

import edu.wpi.first.units.Units
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/constants/Constants.kt` around lines 5 - 9,
The three vals in the Constants object (COLLECTOR_ARM_TOP, COLLECTOR_ARM_BOTTOM,
COLLECTOR_ARM_DELTA) are declared without initializers and will not compile; fix
by assigning each an appropriate Angle value (e.g., using Units to convert
degrees/radians as required) and add the import edu.wpi.first.units.Units at the
top so you can construct the Angle constants (update the Constants object to
initialize COLLECTOR_ARM_TOP, COLLECTOR_ARM_BOTTOM, and COLLECTOR_ARM_DELTA with
concrete Angle expressions).

Comment on lines +15 to 20
lateinit var DRIVE_COMMAND: Command

fun registerControls(drive: SwerveDriveSubsystem) {
CommandScheduler.getInstance().activeButtonLoop.clear()

TELEOP_DRIVE_COMMAND =
TeleopDriveCommand(
drive,
xInput = { if (DRIVER_CONTROLLER.leftX.absoluteValue < .2) 0.0 else DRIVER_CONTROLLER.leftX },
yInput = { if (DRIVER_CONTROLLER.leftY.absoluteValue < .2) 0.0 else DRIVER_CONTROLLER.leftY },
rotationInput = { 0.0 },
fieldRelative = false,
)

drive.defaultCommand = TELEOP_DRIVE_COMMAND
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

TELEOP_DRIVE_COMMAND is undefined; should use DRIVE_COMMAND.

Line 20 references TELEOP_DRIVE_COMMAND which doesn't exist. The declared property is DRIVE_COMMAND. This will fail compilation.

🐛 Proposed fix
-        drive.defaultCommand = TELEOP_DRIVE_COMMAND
+        drive.defaultCommand = DRIVE_COMMAND
📝 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
lateinit var DRIVE_COMMAND: Command
fun registerControls(drive: SwerveDriveSubsystem) {
CommandScheduler.getInstance().activeButtonLoop.clear()
TELEOP_DRIVE_COMMAND =
TeleopDriveCommand(
drive,
xInput = { if (DRIVER_CONTROLLER.leftX.absoluteValue < .2) 0.0 else DRIVER_CONTROLLER.leftX },
yInput = { if (DRIVER_CONTROLLER.leftY.absoluteValue < .2) 0.0 else DRIVER_CONTROLLER.leftY },
rotationInput = { 0.0 },
fieldRelative = false,
)
drive.defaultCommand = TELEOP_DRIVE_COMMAND
lateinit var DRIVE_COMMAND: Command
fun registerControls(drive: SwerveDriveSubsystem) {
CommandScheduler.getInstance().activeButtonLoop.clear()
drive.defaultCommand = DRIVE_COMMAND
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/constants/Controls.kt` around lines 15 -
20, The registerControls function is setting drive.defaultCommand to an
undefined symbol TELEOP_DRIVE_COMMAND; replace that reference with the declared
property DRIVE_COMMAND so the code compiles (update the assignment in
registerControls where drive.defaultCommand is set to use DRIVE_COMMAND instead
of TELEOP_DRIVE_COMMAND).

Comment on lines +38 to +39
if (atTop && speedIsUp(armSpeed)) stopArm()
if (atBottom && speedIsUp(armSpeed)) stopArm()
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Logic error: Line 39 should check speedIsDown, not speedIsUp.

The periodic safety check at line 39 uses speedIsUp(armSpeed) but should use speedIsDown(armSpeed). When at the bottom, the arm should stop if it's still trying to move down, not up.

🐛 Proposed fix
         if (atTop && speedIsUp(armSpeed)) stopArm()
-        if (atBottom && speedIsUp(armSpeed)) stopArm()
+        if (atBottom && speedIsDown(armSpeed)) stopArm()
📝 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
if (atTop && speedIsUp(armSpeed)) stopArm()
if (atBottom && speedIsUp(armSpeed)) stopArm()
if (atTop && speedIsUp(armSpeed)) stopArm()
if (atBottom && speedIsDown(armSpeed)) stopArm()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/subsystems/collector/CollectorSubsystem.kt`
around lines 38 - 39, The periodic safety check in CollectorSubsystem
incorrectly uses speedIsUp(armSpeed) for the bottom limit; change the condition
that currently reads if (atBottom && speedIsUp(armSpeed)) stopArm() to use
speedIsDown(armSpeed) instead so the arm stops when it's trying to move down
into the bottom limit; locate this logic in the CollectorSubsystem class where
atTop, atBottom, armSpeed, speedIsUp/speedIsDown and stopArm are referenced and
update the predicate accordingly.

Comment on lines 13 to +22
val targets: Array<PhotonTrackedTarget>
get() = ioInputs.targets
get() =
camera.allUnreadResults
.map { it.targets }
.flatten()
.toTypedArray()

override fun periodic() {
io.updateInputs(ioInputs)
Logger.recordOutput("Turntable/Speed", motor.get())
Logger.recordOutput("Turntable/Targets", targets.map { it.fiducialId }.toIntArray())
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

allUnreadResults is destructive; periodic() drains the queue before commands can read targets.

PhotonCamera.allUnreadResults returns and removes results from the internal queue. Since targets is a computed property that calls allUnreadResults on every access:

  1. periodic() calls targets on line 22 for logging
  2. This drains the camera results queue
  3. When AlignTurntable.execute() later calls turntable.targets, it receives an empty array

Cache the results once per cycle, similar to FixedCamera.updateUnreadResults():

🐛 Proposed fix: cache results in periodic()
 class TurntableSubsystem(
     val motor: SparkMax,
     val camera: PhotonCamera,
 ) : SubsystemBase() {
-    val targets: Array<PhotonTrackedTarget>
-        get() =
-            camera.allUnreadResults
-                .map { it.targets }
-                .flatten()
-                .toTypedArray()
+    var targets: Array<PhotonTrackedTarget> = emptyArray()
+        private set

     override fun periodic() {
+        targets = camera.allUnreadResults
+            .flatMap { it.targets }
+            .toTypedArray()
+
         Logger.recordOutput("Turntable/Speed", motor.get())
         Logger.recordOutput("Turntable/Targets", targets.map { it.fiducialId }.toIntArray())
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/kotlin/org/frc5183/robot/subsystems/turntable/TurntableSubsystem.kt`
around lines 13 - 22, The targets getter currently calls camera.allUnreadResults
which is destructive and periodic() logs via targets, draining the camera queue
before AlignTurntable.execute() can read them; to fix, add a backing field
(e.g., cachedTargets: Array<PhotonTrackedTarget>) and update it once at the
start of each periodic() by calling camera.allUnreadResults (or use
FixedCamera.updateUnreadResults() pattern), then have the targets property
return cachedTargets so subsequent calls (including AlignTurntable.execute()) in
the same cycle see the same non-destructive snapshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Kind/Feature New functionality Status/Blocked Something is blocking this issue or pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant