From f5aa3a24a145aa8ca18b388e2c4aef170c7f74bb Mon Sep 17 00:00:00 2001 From: Gavin <94215019+Gavin-Niederman@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:38:47 +0000 Subject: [PATCH] refactor: use limelight classifier class index this might work --- .../frc2024/subsystems/indexer/IndexerIO.kt | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/frcteam3636/frc2024/subsystems/indexer/IndexerIO.kt b/src/main/kotlin/com/frcteam3636/frc2024/subsystems/indexer/IndexerIO.kt index 21ef8a4..d622554 100644 --- a/src/main/kotlin/com/frcteam3636/frc2024/subsystems/indexer/IndexerIO.kt +++ b/src/main/kotlin/com/frcteam3636/frc2024/subsystems/indexer/IndexerIO.kt @@ -36,9 +36,9 @@ interface IndexerIO { class IndexerIOReal : IndexerIO{ companion object Constants { - const val RED_CLASS = "red" - const val BLUE_CLASS = "blue" - const val NONE_CLASS = "none" + const val RED_CLASS = 0 + const val BLUE_CLASS = 1 + const val NONE_CLASS = 2 } private var indexerMotor = @@ -52,14 +52,11 @@ class IndexerIOReal : IndexerIO{ inputs.indexerCurrent = Amps.of(indexerMotor.outputCurrent) inputs.position = Rotations.of(indexerMotor.encoder.position) - val colorClass = LimelightHelpers.getClassifierClass("limelight") - inputs.balloonState = if (colorClass.contains(RED_CLASS)) { // "0 red" - BalloonState.Red - } else if (colorClass.contains(BLUE_CLASS)) { // "1 blue" - BalloonState.Blue - } else { // "" - BalloonState.None - } + when (val colorClass = LimelightHelpers.getClassifierClassIndex("limelight")) { + RED_CLASS -> inputs.balloonState = BalloonState.Red + BLUE_CLASS -> inputs.balloonState = BalloonState.Blue + else -> inputs.balloonState = BalloonState.None + } } override fun setSpinSpeed(speed: Double) {