Skip to content

Commit

Permalink
fix theta not adjusting error
Browse files Browse the repository at this point in the history
  • Loading branch information
Shom770 committed Mar 26, 2024
1 parent a7a6868 commit 7e61ff8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
9 changes: 5 additions & 4 deletions src/main/kotlin/org/team4099/lib/units/derived/Controller.kt
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ inline val DerivativeGain<Velocity<Radian>, Ampere>.inAmpsPerDegreesPerSecondPer
inline val DerivativeGain<Velocity<Radian>, Ampere>.inAmpsPerRotationsPerMinutePerSecond: Double
get() = inAmpsPerRadiansPerSecondPerSecond / SECONDS_PER_MINUTE * RADIANS_PER_ROTATION

inline val Double.radiansPerSecondPerRadiansPerSecond
inline val Double.RadiansPerSecondPerRadiansPerSecond
get() = Value<Fraction<Velocity<Radian>, Velocity<Radian>>>(this)

inline val ProportionalGain<Meter, Velocity<Radian>>.inRadiansPerSecondPerMeter: Double
Expand Down Expand Up @@ -348,7 +348,7 @@ inline val DerivativeGain<
Velocity<Radian>, Velocity<Radian>>.inRadiansPerSecondPerRotationsPerMinutePerSecond: Double
get() = inRadiansPerSecondPerRadiansPerSecondPerSecond / SECONDS_PER_MINUTE * RADIANS_PER_ROTATION

inline val Double.metersPerSecondPerMetersPerSecond
inline val Double.MetersPerSecondPerMetersPerSecond
get() = Value<Fraction<Velocity<Meter>, Velocity<Meter>>>(this)

inline val ProportionalGain<Meter, Velocity<Meter>>.inMetersPerSecondPerMeter: Double
Expand Down Expand Up @@ -548,11 +548,12 @@ inline val ProportionalGain<Meter, Velocity<Radian>>.inDegreesPerSecondPerFoot:
get() = inDegreesPerSecondPerMeter * METERS_PER_FOOT

inline val ProportionalGain<Radian, Velocity<Radian>>.inDegreesPerSecondPerRadian: Double
get() = value
get() = inRadiansPerSecondPerRadian * RADIANS_PER_DEGREES

inline val ProportionalGain<Radian, Velocity<Radian>>.inDegreesPerSecondPerDegree: Double
get() = inDegreesPerSecondPerRadian * RADIANS_PER_DEGREES
get() = inDegreesPerSecondPerRadian / RADIANS_PER_DEGREES

//
inline val ProportionalGain<Radian, Velocity<Radian>>.inDegreesPerSecondPerRotation: Double
get() = inDegreesPerSecondPerRadian * RADIANS_PER_ROTATION

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def render_template(template_filename, context):
return TEMPLATE_ENVIRONMENT.get_template(template_filename).render(context)

def create_controller_file():
fname = "src/main/kotlin/org/team4099/lib/units/derived/Controller.kt"
fname = "../Controller.kt"
outputs = ['Volt', 'Ampere', 'Velocity<Radian>', 'Velocity<Meter>', "Meter", "Velocity<Radian>"]
output_aliases = ['Volts', 'Amps', 'RadiansPerSecond', "MetersPerSecond", "Meters", "DegreesPerSecond"]
context = {
Expand Down
10 changes: 0 additions & 10 deletions src/test/kotlin/team4099/controller/PIDControllerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,13 @@ import org.team4099.lib.units.derived.inVoltsPerInch
import org.team4099.lib.units.derived.inVoltsPerRotation
import org.team4099.lib.units.derived.inVoltsPerRotationPerMinute
import org.team4099.lib.units.derived.inVoltsPerRotationsPerMinutePerSecond
import org.team4099.lib.units.derived.metersPerSecondPerMetersPerSecond
import org.team4099.lib.units.derived.perInch
import org.team4099.lib.units.derived.rotations
import org.team4099.lib.units.derived.volts
import org.team4099.lib.units.perMinute
import org.team4099.lib.units.perSecond

class PIDControllerTest {

@Test
fun testConstruction() {
val kP: ProportionalGain<Meter, Fraction<Meter, Second>> = 10.meters.perSecond / 1.meters
val kD = (0.5.meters.perSecond / (1.meters / 1.seconds)).metersPerSecondPerMetersPerSecond
val kI = 0.1.meters.perSecond / (10.meters * 1.seconds)
val positionToVelocityPIDController = PIDController<Meter, Fraction<Meter, Second>>(kP, kI, kD)
}

@Test
fun ampFeedForward() {
val aff =
Expand Down

0 comments on commit 7e61ff8

Please sign in to comment.