From 9f55d221a9866645bd9a7b5ac0e0f428c1b68e4f Mon Sep 17 00:00:00 2001 From: CodingMaster121 Date: Tue, 9 Jan 2024 19:00:46 -0500 Subject: [PATCH] Added Feeder IO File --- build.gradle | 4 +- .../robot2023/subsystems/feeder/FeederIO.kt | 66 +++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/com/team4099/robot2023/subsystems/feeder/FeederIO.kt diff --git a/build.gradle b/build.gradle index a21179a3..1f2fe330 100644 --- a/build.gradle +++ b/build.gradle @@ -84,9 +84,9 @@ dependencies { implementation 'org.jetbrains.kotlin:kotlin-test-junit5' implementation 'com.github.team4099:FalconUtils:1.1.26' - implementation 'org.apache.commons:commons-collections4:4.0' + implementation 'org.apache.commons:commons-collections4:4.4' implementation 'com.google.code.gson:gson:2.10.1' - implementation "io.javalin:javalin:5.3.2" + implementation 'io.javalin:javalin:5.4.2' // We need to add the Kotlin stdlib in order to use most Kotlin language features. // compile "org.jetbrains.kotlin:kotlin-stdlib" diff --git a/src/main/kotlin/com/team4099/robot2023/subsystems/feeder/FeederIO.kt b/src/main/kotlin/com/team4099/robot2023/subsystems/feeder/FeederIO.kt new file mode 100644 index 00000000..15eec3c3 --- /dev/null +++ b/src/main/kotlin/com/team4099/robot2023/subsystems/feeder/FeederIO.kt @@ -0,0 +1,66 @@ +package com.team4099.robot2023.subsystems.feeder + +import org.littletonrobotics.junction.LogTable +import org.littletonrobotics.junction.inputs.LoggableInputs +import org.team4099.lib.units.base.amps +import org.team4099.lib.units.base.celsius +import org.team4099.lib.units.base.inAmperes +import org.team4099.lib.units.base.inCelsius +import org.team4099.lib.units.derived.ElectricalPotential +import org.team4099.lib.units.derived.inVolts +import org.team4099.lib.units.derived.volts + +interface FeederIO { + class FeederIOInputs: LoggableInputs { + var floorAppliedVoltage = 0.0.volts + var floorStatorCurrent = 0.0.amps + var floorSupplyCurrent = 0.0.amps + var floorTemp = 0.0.celsius + var verticalAppliedVoltage = 0.0.volts + var verticalStatorCurrent = 0.0.amps + var verticalSupplyCurrent = 0.0.amps + var verticalTemp = 0.0.celsius + + var isSimulated = false + + override fun toLog(table: LogTable?) { + table?.put("floorAppliedVoltage", floorAppliedVoltage.inVolts) + table?.put("floorStatorCurrent", floorStatorCurrent.inAmperes) + table?.put("floorSupplyCurrent", floorSupplyCurrent.inAmperes) + table?.put("floorTempCelcius", floorTemp.inCelsius) + table?.put("verticalAppliedVoltage", verticalAppliedVoltage.inVolts) + table?.put("verticalStatorCurrent", verticalStatorCurrent.inAmperes) + table?.put("verticalSupplyCurrent", verticalSupplyCurrent.inAmperes) + table?.put("verticalTempCelcius", verticalTemp.inCelsius) + } + + override fun fromLog(table: LogTable?) { + table?.getDouble("floorAppliedVoltage", floorAppliedVoltage.inVolts)?.let { + floorAppliedVoltage = it.volts + } + table?.getDouble("floorStatorCurrent", floorStatorCurrent.inAmperes)?.let { + floorStatorCurrent = it.amps + } + table?.getDouble("floorSupplyCurrent", floorSupplyCurrent.inAmperes)?.let { + floorSupplyCurrent = it.amps + } + table?.getDouble("floorTempCelcius", floorTemp.inCelsius)?.let { floorTemp = it.celsius } + table?.getDouble("verticalAppliedVoltage", verticalAppliedVoltage.inVolts)?.let { + verticalAppliedVoltage = it.volts + } + table?.getDouble("verticalStatorCurrent", verticalStatorCurrent.inAmperes)?.let { + verticalStatorCurrent = it.amps + } + table?.getDouble("verticalSupplyCurrent", verticalSupplyCurrent.inAmperes)?.let { + verticalSupplyCurrent = it.amps + } + table?.getDouble("verticalTempCelcius", verticalTemp.inCelsius)?.let { verticalTemp = it.celsius } + } + + fun updateInputs(inputs: FeederIOInputs) {} + + fun setFloorVoltage(voltage: ElectricalPotential) {} + + fun setVerticalVoltage(voltage: ElectricalPotential) {} + } +} \ No newline at end of file