Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
refactor: use limelight classifier class index
Browse files Browse the repository at this point in the history
this might work
  • Loading branch information
Gavin-Niederman committed Dec 4, 2024
1 parent ee6076a commit f5aa3a2
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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) {
Expand Down

0 comments on commit f5aa3a2

Please sign in to comment.