コード例 #1
0
ファイル: PIController.cs プロジェクト: haesemeyer/ZebraTrack
 /// <summary>
 /// Constructs a new PI controller object
 /// </summary>
 /// <param name="target">The initial target of the system</param>
 /// <param name="sensor">The sensor to read</param>
 /// <param name="effector">The effector to adjust the system</param>
 /// <param name="kP">The proportional term</param>
 /// <param name="kI">The integral term</param>
 /// <param name="updateStep">The step width with which we move towards a new setpoint</param>
 /// <param name="id">The id of this controller</param>
 public PIController(double target, Sensor sensor, Effector effector, double kP, double kI, double updateStep, string id)
 {
     _sensor = sensor;
     _sensor.ValueChanged += ControlLoop;
     _effector             = effector;
     KP               = kP;
     KI               = kI;
     UpdateStep       = updateStep;
     _id              = id;
     Target           = target;
     _setPoint        = target;
     _integralOfError = 0;
     //by default don't enforce any limits
     //on the controller
     MaxSystemValue   = double.MaxValue;
     MinSystemValue   = double.MinValue;
     MaxIntegralError = double.MaxValue;
 }
コード例 #2
0
 /// <summary>
 /// Constructs a new DeltaConstrainedPIController object
 /// </summary>
 /// <param name="target">The initial target of the system</param>
 /// <param name="sensor">The main sensor to read</param>
 /// <param name="delta">The sensor reporting on the delta of our constraint</param>
 /// <param name="effector">The system effector</param>
 /// <param name="kP">The proportional constant of our controller</param>
 /// <param name="kI">The integral constant of our controller</param>
 /// <param name="updateStep">The step width with which we move towards a new setpoint</param>
 /// <param name="kpConstraint">The proportional effect of the delta constraint</param>
 /// <param name="kIConstraint">The integral effect of the delta constraint</param>
 /// <param name="acceptableDelta">The maximum acceptable delta (without effect on controller)</param>
 /// <param name="id">The name of the controller</param>
 public DeltaConstrainedPIController(double target, Sensor sensor, Sensor delta, Effector effector, double kP,
                                     double kI, double updateStep, double kpConstraint, double kIConstraint, double acceptableDelta, string id)
 {
     _sensor = sensor;
     _sensor.ValueChanged += ControlLoop;
     _delta           = delta;
     _effector        = effector;
     KP               = kP;
     KI               = kI;
     UpdateStep       = updateStep;
     KPConstraint     = kpConstraint;
     KIConstraint     = kIConstraint;
     AcceptableDelta  = acceptableDelta;
     _id              = id;
     Target           = target;
     _setPoint        = target;
     _integralOfError = 0;
     //by default don't enforce any limits
     //on the controller
     MaxSystemValue   = double.MaxValue;
     MinSystemValue   = double.MinValue;
     MaxIntegralError = double.MaxValue;
 }