Merge remote-tracking branch 'spc/dev' into dev
# Conflicts: # demo/constructor/src/jvmMain/kotlin/main.kt
This commit is contained in:
commit
0c128bce36
@ -49,7 +49,7 @@ public class VirtualDrive(
|
|||||||
public val positionState: MutableDeviceState<Double>,
|
public val positionState: MutableDeviceState<Double>,
|
||||||
) : Drive, DeviceBySpec<Drive>(Drive, context) {
|
) : Drive, DeviceBySpec<Drive>(Drive, context) {
|
||||||
|
|
||||||
private val dt = meta["time.step"].double?.milliseconds ?: 5.milliseconds
|
private val dt = meta["time.step"].double?.milliseconds ?: 1.milliseconds
|
||||||
private val clock = context.clock
|
private val clock = context.clock
|
||||||
|
|
||||||
override var force: Double = 0.0
|
override var force: Double = 0.0
|
||||||
@ -74,7 +74,6 @@ public class VirtualDrive(
|
|||||||
|
|
||||||
// compute new value based on velocity and acceleration from the previous step
|
// compute new value based on velocity and acceleration from the previous step
|
||||||
positionState.value += velocity * dtSeconds + force / mass * dtSeconds.pow(2) / 2
|
positionState.value += velocity * dtSeconds + force / mass * dtSeconds.pow(2) / 2
|
||||||
propertyChanged(Drive.position, positionState.value)
|
|
||||||
|
|
||||||
// compute new velocity based on acceleration on the previous step
|
// compute new velocity based on acceleration on the previous step
|
||||||
velocity += force / mass * dtSeconds
|
velocity += force / mass * dtSeconds
|
||||||
|
@ -62,7 +62,6 @@ public class PidRegulator(
|
|||||||
lastPosition = drive.position
|
lastPosition = drive.position
|
||||||
|
|
||||||
drive.force = pidParameters.kp * delta + pidParameters.ki * integral + pidParameters.kd * derivative
|
drive.force = pidParameters.kp * delta + pidParameters.ki * integral + pidParameters.kd * derivative
|
||||||
propertyChanged(Regulator.position, drive.position)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user