Skip to content

Commit c92ac33

Browse files
Fix PID calculation in controls-base-sim.ts
1 parent d2ed4c1 commit c92ac33

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/simulation/controls-base-sim.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ export class ControlsBaseSim {
172172

173173
calculatePID(error: number): number {
174174
// Calculate PID output
175-
this.integral += this.kI * error * this.dt
175+
this.integral += error * this.dt
176176
const derivative = (error - this.prevError) / this.dt
177177
this.prevError = error
178178

179-
return this.kP * error + this.integral + this.kD * derivative
179+
return (this.kP * error) + (this.kI * this.integral) + (this.kD * derivative)
180180
}
181181

182182
update(dt?: number): void {

0 commit comments

Comments
 (0)