feat: error wrap callback
This commit is contained in:
@@ -2,6 +2,7 @@ export interface PIDParameters {
|
||||
kP: number;
|
||||
kI: number;
|
||||
kD: number;
|
||||
errorWrap?: (error: number) => number;
|
||||
}
|
||||
|
||||
export type PIDReport = {
|
||||
@@ -44,7 +45,11 @@ export class PID {
|
||||
|
||||
public update(measuredValue: number): number {
|
||||
const currentTime = os.epoch("utc");
|
||||
const error = this.setpoint - measuredValue;
|
||||
|
||||
const rawError = this.setpoint - measuredValue;
|
||||
const error = this.params.errorWrap
|
||||
? this.params.errorWrap(rawError)
|
||||
: rawError;
|
||||
|
||||
let deltaTime = 0;
|
||||
if (this.lastTime !== null) {
|
||||
|
||||
Reference in New Issue
Block a user