diff --git a/src/main/java/com/frcteam3636/frc2024/subsystems/indexer/Indexer.kt b/src/main/java/com/frcteam3636/frc2024/subsystems/indexer/Indexer.kt index e238922..f42fcd3 100644 --- a/src/main/java/com/frcteam3636/frc2024/subsystems/indexer/Indexer.kt +++ b/src/main/java/com/frcteam3636/frc2024/subsystems/indexer/Indexer.kt @@ -1,4 +1,31 @@ package com.frcteam3636.frc2024.subsystems.indexer +import edu.wpi.first.wpilibj2.command.Command +import edu.wpi.first.wpilibj2.command.Subsystem +import org.littletonrobotics.junction.Logger + object Indexer { + private var io: IndexerIO = IndexerIOReal() + + var inputs = IndexerIO.IndexerInputs() + + override fun periodic() { + io.updateInputs(inputs) + Logger.processInputs("Indexer", inputs) + } + + fun progressBalloon(): Command = + startEnd( + {io.setSpinSpeed(0.5)} + ) + + fun outtakeBalloon(): Command = + startEnd( + {io.setSpinSpeed(-0.5)} + ) + + fun stopIndexerSpin(): Command = + startEnd( + {io.setSpinSpeed(0.0)} + ) } \ No newline at end of file diff --git a/src/main/java/com/frcteam3636/frc2024/subsystems/indexer/IndexerIO.kt b/src/main/java/com/frcteam3636/frc2024/subsystems/indexer/IndexerIO.kt index 793cf19..d5d19ed 100644 --- a/src/main/java/com/frcteam3636/frc2024/subsystems/indexer/IndexerIO.kt +++ b/src/main/java/com/frcteam3636/frc2024/subsystems/indexer/IndexerIO.kt @@ -8,14 +8,14 @@ interface IndexerIO{ class IndexerInputs : LoggableInputs { var indexerVelocity = Rotation2d() var indexerCurrent: Double = 0.0 - var isSpinning: Boolean = false + var isSpinningBalloon: Boolean = false var hasBalloon: Boolean = false var balloonColor = null override fun toLog(table: LogTable?) { table?.put("Indexer Wheel Velocity", indexerVelocity) table?.put("Indexer Wheel Current", indexerCurrent) - table?.put("Is spinning", isSpinning) + table?.put("Is spinning", isSpinningBalloon) table?.put("Has balloon", hasBalloon) table?.put("Balloon Color", balloonColor) } @@ -23,7 +23,7 @@ interface IndexerIO{ override fun fromLog(table: LogTable) { indexerVelocity = table.get("Indexer Velocity", indexerVelocity)!![0] indexerCurrent = table.get("Indexer Wheel Current", indexerCurrent) - isSpinning = table.get("Is spinning", isSpinning) + isSpinningBalloon = table.get("Is spinning", isSpinningBalloon) hasBalloon = table.get("Has balloon", hasBalloon) balloonColor = table.get("Balloon Color", balloonColor) } @@ -46,7 +46,7 @@ class IndexerIOReal: IndexerIO{ override fun updateInputs(inputs: IndexerIO.IndexerInputs) { inputs.indexerVelocity = Rotation2d(indexerWheel.encoder.velocity) inputs.indexerCurrent = indexerWheel.outputCurrent - inputs.isSpinning = indexerWheel. + inputs.isSpinningBalloon = colorSensor.get() inputs.hasBalloon = colorSensor.get() inputs.balloonColor = colorSensor.get() }