feat: error wrap callback
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "computercraft-mutil",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "",
|
||||
"license": "ISC",
|
||||
"author": "",
|
||||
|
||||
@@ -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