This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c36ed95
commit 60b3c19
Showing
2 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
24 changes: 17 additions & 7 deletions
24
src/main/java/com/frcteam3636/frc2024/subsystems/indexer/Indexer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
package com.frcteam3636.frc2024.subsystems.indexer | ||
|
||
import com.revrobotics.ColorMatch | ||
import edu.wpi.first.wpilibj.util.Color | ||
import edu.wpi.first.wpilibj2.command.Command | ||
import edu.wpi.first.wpilibj2.command.Commands.startEnd | ||
import edu.wpi.first.wpilibj2.command.Subsystem | ||
import org.littletonrobotics.junction.Logger | ||
|
||
object Indexer { | ||
object Indexer: Subsystem { | ||
private var io: IndexerIO = IndexerIOReal() | ||
private var colorMatcher = ColorMatch().apply { | ||
addColorMatch(RED_BALLOON_COLOR) | ||
addColorMatch(BLUE_BALLOON_COLOR) | ||
} | ||
|
||
var inputs = IndexerIO.IndexerInputs() | ||
var currentColor: Color? = null | ||
|
||
override fun periodic() { | ||
io.updateInputs(inputs) | ||
Logger.processInputs("Indexer", inputs) | ||
currentColor = colorMatcher.matchClosestColor(inputs.balloonColor).color | ||
} | ||
|
||
fun progressBalloon(): Command = | ||
startEnd( | ||
{io.setSpinSpeed(0.5)} | ||
{io.setSpinSpeed(0.5)}, | ||
{io.setSpinSpeed(0.0)} | ||
) | ||
|
||
fun outtakeBalloon(): Command = | ||
startEnd( | ||
{io.setSpinSpeed(-0.5)} | ||
) | ||
|
||
fun stopIndexerSpin(): Command = | ||
startEnd( | ||
{io.setSpinSpeed(-0.5)}, | ||
{io.setSpinSpeed(0.0)} | ||
) | ||
|
||
val RED_BALLOON_COLOR = Color(255, 0, 0) | ||
val BLUE_BALLOON_COLOR = Color(0, 0, 255) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters