Skip to content

Commit

Permalink
pid variable adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
SirBeans committed Jan 29, 2024
1 parent 604a3c9 commit af060f2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/main/kotlin/com/team4099/robot2023/BuildConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ package com.team4099.robot2023
* Automatically generated file containing build version information.
*/
const val MAVEN_GROUP = ""
const val MAVEN_NAME = "cresendo"
const val MAVEN_NAME = "Crescendo-2024v2"
const val VERSION = "unspecified"
const val GIT_REVISION = 101
const val GIT_SHA = "a599b3e0917de8004033315a58f3dad671b072e5"
const val GIT_DATE = "2024-01-28T18:05:00Z"
const val GIT_REVISION = 102
const val GIT_SHA = "604a3c944cf21d691d7f2d854357417009e237cd"
const val GIT_DATE = "2024-01-28T19:00:59Z"
const val GIT_BRANCH = "shooter"
const val BUILD_DATE = "2024-01-28T18:58:53Z"
const val BUILD_UNIX_TIME = 1706486333778L
const val BUILD_DATE = "2024-01-28T19:34:57Z"
const val BUILD_UNIX_TIME = 1706488497518L
const val DIRTY = 1
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ object FlywheelConstants {
val FLYWHEEL_TOLERANCE = 50.0.rotations.perMinute
object PID {
val RIGHT_REAL_KP: ProportionalGain<Velocity<Radian>, Volt> =
0.001.volts / 1.0.rotations.perMinute
0.0.volts / 1.0.rotations.perMinute
val RIGHT_REAL_KI: IntegralGain<Velocity<Radian>, Volt> =
0.0.volts / (1.0.rotations.perMinute * 1.0.seconds)
val RIGHT_REAL_KD: DerivativeGain<Velocity<Radian>, Volt> =
0.0.volts / (1.0.rotations.perMinute.perSecond)

val RIGHT_SIM_KP: ProportionalGain<Velocity<Radian>, Volt> =
0.1.volts / 1.0.rotations.perMinute
0.0.volts / 1.0.rotations.perMinute
val RIGHT_SIM_KI: IntegralGain<Velocity<Radian>, Volt> =
0.0.volts / (1.0.radians.perSecond * 1.0.seconds)
val RIGHT_SIM_KD: DerivativeGain<Velocity<Radian>, Volt> =
0.0.volts / (1.0.rotations.perMinute.perSecond)

val LEFT_REAL_KP: ProportionalGain<Velocity<Radian>, Volt> =
0.001.volts / 1.0.rotations.perMinute
0.1.volts / 1.0.rotations.perMinute
val LEFT_REAL_KI: IntegralGain<Velocity<Radian>, Volt> =
0.0.volts / (1.0.rotations.perMinute * 1.0.seconds)
val LEFT_REAL_KD: DerivativeGain<Velocity<Radian>, Volt> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class Flywheel(val io: FlywheelIO) : SubsystemBase() {
}

fun flywheelOpenLoopCommand(): Command {
return runOnce({ currentRequest = Request.FlywheelRequest.OpenLoop(10.volts) })
return runOnce({ currentRequest = Request.FlywheelRequest.OpenLoop(12.volts) })
}

fun flywheelResetCommand(): Command {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.team4099.lib.units.derived.radians
import org.team4099.lib.units.derived.rotations
import org.team4099.lib.units.derived.volts
import org.team4099.lib.units.inRadiansPerSecond
import org.team4099.lib.units.inRotationsPerMinute
import org.team4099.lib.units.perMinute
import org.team4099.lib.units.perSecond

Expand All @@ -45,15 +46,15 @@ interface FlywheelIO {
var isSimulated = false

override fun toLog(table: LogTable) {
table.put("flywheelRightVelocityRPM", rightFlywheelVelocity.inRadiansPerSecond)
table.put("flywheelRightVelocityRPM", rightFlywheelVelocity.inRotationsPerMinute)
table.put("flywheelRightAppliedVoltage", rightFlywheelAppliedVoltage.inVolts)
table.put("flywheelRightStatorCurrent", rightFlywheelStatorCurrent.inAmperes)
table.put("flywheelRightSupplyCurrent", rightFlywheelSupplyCurrent.inAmperes)
table.put("flywheelRightTemperature", rightFlywheelTemperature.inCelsius)
table.put("rightFlywheelDutyCycle", rightFlywheelDutyCycle.inVolts)
table.put("rightFlywheelTorque", rightFlywheelTorque.inNewtons)

table.put("flywheelLeftVelocityRPM", leftFlywheelVelocity.inRadiansPerSecond)
table.put("flywheelLeftVelocityRPM", leftFlywheelVelocity.inRotationsPerMinute)
table.put("flywheelLeftAppliedVoltage", leftFlywheelAppliedVoltage.inVolts)
table.put("flywheelLeftStatorCurrent", leftFlywheelStatorCurrent.inAmperes)
table.put("flywheelLeftSupplyCurrent", leftFlywheelSupplyCurrent.inAmperes)
Expand All @@ -64,8 +65,8 @@ interface FlywheelIO {

override fun fromLog(table: LogTable) {
// Flywheel logs
table.get("rightFlywheelVelocityRPM", rightFlywheelVelocity.inRadiansPerSecond).let {
rightFlywheelVelocity = it.radians.perSecond
table.get("rightFlywheelVelocityRPM", rightFlywheelVelocity.inRotationsPerMinute).let {
rightFlywheelVelocity = it.rotations.perMinute
}
table.get("rightFlywheelAppliedVoltage", rightFlywheelAppliedVoltage.inVolts).let {
rightFlywheelAppliedVoltage = it.volts
Expand All @@ -87,8 +88,8 @@ interface FlywheelIO {
}

// Left motor
table.get("leftFlywheelVelocityRPM", leftFlywheelVelocity.inRadiansPerSecond).let {
leftFlywheelVelocity = it.radians.perSecond
table.get("leftFlywheelVelocityRPM", leftFlywheelVelocity.inRotationsPerMinute).let {
leftFlywheelVelocity = it.rotations.perMinute
}
table.get("leftFlywheelAppliedVoltage", leftFlywheelAppliedVoltage.inVolts).let {
leftFlywheelAppliedVoltage = it.volts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import org.team4099.lib.units.perMinute
object FlywheelIOSim : FlywheelIO {
private val flywheelRightSim: FlywheelSim =
FlywheelSim(
DCMotor.getKrakenX60Foc(1),
DCMotor.getFalcon500(2),
FlywheelConstants.LEFT_GEAR_RATIO,
FlywheelConstants.INERTIA.inKilogramsMeterSquared
)

private val flywheelLeftSim: FlywheelSim =
FlywheelSim(
DCMotor.getKrakenX60Foc(1),
DCMotor.getFalcon500(2),
FlywheelConstants.RIGHT_GEAR_RATIO,
FlywheelConstants.INERTIA.inKilogramsMeterSquared
)
Expand All @@ -53,14 +53,12 @@ object FlywheelIOSim : FlywheelIO {
flywheelLeftSim.update(Constants.Universal.LOOP_PERIOD_TIME.inSeconds)
flywheelRightSim.update(Constants.Universal.LOOP_PERIOD_TIME.inSeconds)

inputs.leftFlywheelVelocity = flywheelLeftSim.getAngularVelocityRPM().rotations.perMinute
inputs.leftFlywheelVelocity = flywheelLeftSim.getAngularVelocityRPM().rotations.perMinute
inputs.leftFlywheelAppliedVoltage = appliedLeftVoltage
inputs.leftFlywheelSupplyCurrent = 0.amps
inputs.leftFlywheelStatorCurrent = flywheelLeftSim.currentDrawAmps.amps
inputs.leftFlywheelTemperature = 0.0.celsius

inputs.rightFlywheelVelocity = flywheelRightSim.getAngularVelocityRPM().rotations.perMinute
inputs.rightFlywheelVelocity = flywheelRightSim.getAngularVelocityRPM().rotations.perMinute
inputs.rightFlywheelAppliedVoltage = appliedRightVoltage
inputs.rightFlywheelSupplyCurrent = 0.amps
Expand Down

0 comments on commit af060f2

Please sign in to comment.