Skip to content

Commit

Permalink
add acceleration units
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewChoulas committed Jan 20, 2025
1 parent 46f6dff commit f53b8fb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/kotlin/org/team4099/lib/units/MechanismUnits.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.team4099.lib.units.base.inSeconds
import org.team4099.lib.units.base.meters
import org.team4099.lib.units.base.minutes
import org.team4099.lib.units.base.seconds
import org.team4099.lib.units.derived.AccelerationFeedforward
import org.team4099.lib.units.derived.DerivativeGain
import org.team4099.lib.units.derived.ElectricalPotential
import org.team4099.lib.units.derived.IntegralGain
Expand Down Expand Up @@ -75,6 +76,8 @@ interface MechanismSensor<U : UnitKey> {
): Double

fun velocityFeedforwardToRawUnits(velocityFeedforward: VelocityFeedforward<U, Volt>): Double

fun accelerationFeedforwardToRawUnits(accelerationFeedforward: AccelerationFeedforward<U, Volt>): Double
}

class LinearMechanismSensor(
Expand Down Expand Up @@ -173,6 +176,13 @@ class LinearMechanismSensor(
velocityToRawUnits(1.0.meters.perSecond) /
compensationVoltage.inVolts * fullPowerThrottle
}

override inline fun accelerationFeedforwardToRawUnits(
accelerationFeedforward: AccelerationFeedforward<Meter, Volt>): Double {
return accelerationFeedforward.value /
accelerationToRawUnits(1.0.meters.perSecond.perSecond) /
compensationVoltage.inVolts * fullPowerThrottle
}
}

class AngularMechanismSensor(
Expand Down Expand Up @@ -268,6 +278,13 @@ class AngularMechanismSensor(
velocityToRawUnits(1.0.radians.perSecond) /
compensationVoltage.inVolts * fullPowerThrottle
}

override inline fun accelerationFeedforwardToRawUnits(
accelerationFeedforward: AccelerationFeedforward<Radian, Volt>): Double {
return accelerationFeedforward.value /
accelerationToRawUnits(1.0.radians.perSecond.perSecond) /
compensationVoltage.inVolts * fullPowerThrottle
}
}

fun ctreAngularMechanismSensor(
Expand Down

0 comments on commit f53b8fb

Please sign in to comment.