BangBangController’la Bang-Bang Kontrol

Bang-bang kontrol algoritması yalnızca iki durum kullanan bir kontrol stratejisidir: açık (ölçüm ayar noktasının altında olduğunda) ve kapalı (aksi takdirde). Bu durumlar kabaca sonsuz kazançlı orantılı bir döngüye eşdeğerdir.

Kazançlar büyüdükçe PID döngülerinin dengesizleştiği bilindiğinden, bu başta kötü bir kontrol stratejisi olarak gözükmektedir ve doğrusu bang-bang kontrolörünü yüksek eylemsizlik düzeneklerinin hız kontrolü dışında bir şey için kullanmak kötü bir fikirdir.

However, when controlling the velocity of high-inertia mechanisms under varying loads (like a shooter flywheel), a bang-bang controller can yield faster recovery time and thus better/more consistent performance than a proportional controller. Unlike an ordinary P loop, a bang-bang controller is asymmetric - that is, the controller turns on when the process variable is below the setpoint, and does nothing otherwise. This allows the control effort in the forward direction to be made as large as possible without risking destructive oscillations as the control loop tries to correct a resulting overshoot.

Asymmetric bang-bang control is provided in WPILib by the BangBangController class (Java, C++, Python).

BangBangController’ın İnşaası

Bang-bang kontrolör herhangi bir kazanca sahip olmadığı için hiçbir constructor değişkenine ihtiyaç duymamaktadır (isteğe bağlı olarak kontrolör toleransını ``atSetpoint``le ayarlayabilmektedir, ancak bu ayarı yapmak şart değildir).

// Creates a BangBangController
BangBangController controller = new BangBangController();
// Creates a BangBangController
frc::BangBangController controller;
from wpimath.controller import BangBangController
  # Creates a BangBangController
controller = BangBangController()

BangBangController Kullanımı

Uyarı

Bang-bang kontrolü, sabit kalmak için cevap asimetrisine dayanan son derece şiddetli bir algoritmadır. Motor kontrolörlerlerinizi bang-bang kontrolörüyle yönetmeden önce kontrolörlerinizin “boşta” olduğundan kesinlikle emin olunuz, aksi takdirde frenleme işlemi kontrolörle tepki verecek ve tehlike teşkil edebilecek dalgalanmalara sebep olabilecektir.

Bang-bang kontrolörünün kullanımı kolaydır:

// Controls a motor with the output of the BangBang controller
motor.set(controller.calculate(encoder.getRate(), setpoint));
// Controls a motor with the output of the BangBang controller
motor.Set(controller.Calculate(encoder.GetRate(), setpoint));
# Controls a motor with the output of the BangBang controller
motor.set(controller.calculate(encoder.getRate(), setpoint))

Bang Bang Kontrolünün Feedforward ile Birleştirilmesi

Like a PID controller, best results are obtained in conjunction with a feedforward controller that provides the necessary voltage to sustain the system output at the desired speed, so that the bang-bang controller is only responsible for rejecting disturbances. Since the bang-bang controller can only correct in the forward direction, however, it may be preferable to use a slightly conservative feedforward estimate to ensure that the shooter does not over-speed.

// Controls a motor with the output of the BangBang controller and a feedforward
// Shrinks the feedforward slightly to avoid overspeeding the shooter
motor.setVoltage(controller.calculate(encoder.getRate(), setpoint) * 12.0 + 0.9 * feedforward.calculate(setpoint));
// Controls a motor with the output of the BangBang controller and a feedforward
// Shrinks the feedforward slightly to avoid overspeeding the shooter
motor.SetVoltage(controller.Calculate(encoder.GetRate(), setpoint) * 12.0 + 0.9 * feedforward.Calculate(setpoint));
# Controls a motor with the output of the BangBang controller and a feedforward
motor.setVoltage(controller.calculate(encoder.getRate(), setpoint) * 12.0 + 0.9 * feedforward.calculate(setpoint))