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

Commit

Permalink
Added basic indexer commands and fixed some issues with indexer io.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taimorioka authored Nov 7, 2024
1 parent b74a5ea commit 35c3bf4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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)}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ 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)
}

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)
}
Expand All @@ -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()
}
Expand Down

0 comments on commit 35c3bf4

Please sign in to comment.