Skip to content

Commit

Permalink
completed saraansh's peer review
Browse files Browse the repository at this point in the history
  • Loading branch information
00magikarp committed Jan 23, 2024
1 parent d603b93 commit ffd7923
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
22 changes: 5 additions & 17 deletions src/main/kotlin/com/team4099/robot2023/subsystems/feeder/Feeder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,19 @@ class Feeder(val io: FeederIO) : SubsystemBase() {
var nextState = currentState
when (currentState) {
FeederStates.UNINITIALIZED -> {
nextState = FeederStates.IDLE
}
FeederStates.IDLE -> {
setFeederVoltage(FeederConstants.FEEDER_IDLE_VOLTAGE)
nextState = fromRequestToState(currentRequest)
nextState = FeederStates.OPEN_LOOP_INTAKE
}
FeederStates.OPEN_LOOP_INTAKE -> {

if (!hasNote) {
setFeederVoltage(feederTargetVoltage)
nextState = fromRequestToState(currentRequest)
} else {
nextState = FeederStates.IDLE
}
}
nextState = fromRequestToState(currentRequest)
}
FeederStates.OPEN_LOOP_SHOOT -> {
if (hasNote) {
setFeederVoltage(feederTargetVoltage)
nextState = fromRequestToState(currentRequest)
} else {
nextState = FeederStates.IDLE
}
nextState = fromRequestToState(currentRequest)
}
}
currentState = nextState
Expand All @@ -112,22 +103,19 @@ class Feeder(val io: FeederIO) : SubsystemBase() {
companion object {
enum class FeederStates {
UNINITIALIZED,
IDLE,
OPEN_LOOP_INTAKE,
OPEN_LOOP_SHOOT;

fun equivalentToRequest(request: Request.FeederRequest): Boolean {
return (
(request is Request.FeederRequest.OpenLoopIntake && this == OPEN_LOOP_SHOOT) ||
(request is Request.FeederRequest.OpenLoopIntake && this == OPEN_LOOP_INTAKE) ||
(request is Request.FeederRequest.Idle && this == IDLE)
(request is Request.FeederRequest.OpenLoopIntake && this == OPEN_LOOP_INTAKE)
)
}
}

fun fromRequestToState(request: Request.FeederRequest): FeederStates {
return when (request) {
is Request.FeederRequest.Idle -> FeederStates.IDLE
is Request.FeederRequest.OpenLoopIntake -> FeederStates.OPEN_LOOP_INTAKE
is Request.FeederRequest.OpenLoopShoot -> FeederStates.OPEN_LOOP_SHOOT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface FeederIO {
table?.put("feederStatorCurrent", feederStatorCurrent.inAmperes)
table?.put("feederSupplyCurrent", feederSupplyCurrent.inAmperes)
table?.put("feederTempCelcius", feederTemp.inCelsius)
table?.put("feederBeamBroken", beamBroken)
}

override fun fromLog(table: LogTable?) {
Expand All @@ -53,6 +54,7 @@ interface FeederIO {
}

table?.get("feederTempCelcius", feederTemp.inCelsius)?.let { feederTemp = it.celsius }
table?.get("feederBeamBroken", beamBroken)?.let { beamBroken = it }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ object FeederIONeo : FeederIO {

feederSparkMax.idleMode = CANSparkMax.IdleMode.kCoast

feederSparkMax.openLoopRampRate = 0.0
feederSparkMax.burnFlash()

MotorChecker.add(
Expand All @@ -47,7 +46,7 @@ object FeederIONeo : FeederIO {
mutableListOf(Neo(feederSparkMax, "Roller Motor")),
FeederConstants.FEEDER_CURRENT_LIMIT,
70.celsius,
FeederConstants.FEEDER_CURRENT_LIMIT - 0.amps,
30.amps,
90.celsius
),
)
Expand All @@ -66,11 +65,6 @@ object FeederIONeo : FeederIO {
inputs.feederStatorCurrent * feederSparkMax.appliedOutput.absoluteValue
inputs.feederTemp = feederSparkMax.motorTemperature.celsius

Logger.recordOutput(
"Intake/rollerMotorOvercurrentFault",
feederSparkMax.getFault(CANSparkMax.FaultID.kOvercurrent)
)
Logger.recordOutput("Intake/busVoltage", feederSparkMax.busVoltage)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ sealed interface Request {
}

sealed interface FeederRequest : Request {
class Idle() : FeederRequest
class OpenLoopIntake(val feederVoltage: ElectricalPotential) : FeederRequest
class OpenLoopShoot(val feederVoltage: ElectricalPotential) : FeederRequest
}
Expand Down

0 comments on commit ffd7923

Please sign in to comment.