Skip to content

Commit

Permalink
Add a functional wrapper over the PID controller
Browse files Browse the repository at this point in the history
  • Loading branch information
aib committed May 13, 2020
1 parent 763635d commit 6f790e4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions util/FunPIDController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;

public
class FunPIDController: PIDController
{
private readonly Func<double> getter;
private readonly Action<double> setter;

public FunPIDController(double Kp, double Ki, double Kd, Func<double> getter, Action<double> setter)
:base(Kp, Ki, Kd)
{
this.getter = getter;
this.setter = setter;
}

public void run(double deltaT)
{
setter(run(deltaT, getter()));
}
}

0 comments on commit 6f790e4

Please sign in to comment.