API Reference¶
pyadrc.pyadrc¶
Active Disturbance Rejection Control for Python
It is highly recommended to check the documentation first before attempting to use the package. Although it is simple in nature, ADRC requires some basic knowledge about PID control, observers and state-feedback.
- class pyadrc.pyadrc.FeedbackTF(order, delta, b0, w_cl, k_eso, x_init=False, r_lim=(None, None), m_lim=(None, None))[source]¶
Minimal footprint ADRC implemented with transfer functions in feedback path
- Parameters
- orderint
first- or second-order ADRC
- deltafloat
sampling time in seconds
- b0float
gain parameter b0
- w_clfloat
desired closed-loop bandwidth [rad/s], 4 / w_cl and 6 / w_cl is the corresponding settling time in seconds for first- and second-order ADRC respectively
- k_esofloat
relational observer bandwidth
- x_inittuple, optional
initial state for the storage variables, by default False
- r_limtuple, optional
rate limits of the controller, by default (None, None)
- m_limtuple, optional
magnitude limits of the controller, by default (None, None)
References
- 3
G. Herbst, “A Minimum-Footprint Implementation of Discrete-Time ADRC”, https://arxiv.org/abs/2104.01943
- __call__(y, r, zoh=False)[source]¶
Returns value of the control signal depending on current measurements and reference signal.
- Parameters
- yfloat
Current measurement y[k] of the process
- rfloat
Current reference signal r[k]
- zohbool, optional
Only update every delta seconds, by default False
- Returns
- float
Current control signal u[k]
- property limiter¶
Returns the value of both limiters of the controller
- Returns
- tuple of tuples
Returns (magnitude_limits, rate_limits)
- property x_states¶
Returns the storage variables
- Returns
- tuple
Storage variables
- class pyadrc.pyadrc.StateSpace(order, delta, b0, w_cl, k_eso, inc_form=False, eso_init=False, r_lim=(None, None), m_lim=(None, None), half_gain=(False, False))[source]¶
Discrete linear time-invariant state space implementation of ADRC
- Parameters
- orderint
first- or second-order ADRC
- deltafloat
sampling time in seconds
- b0float
gain parameter b0
- w_clfloat
desired closed-loop bandwidth [rad/s], 4 / w_cl and 6 / w_cl is the corresponding settling time in seconds for first- and second-order ADRC respectively
- k_esofloat
relational observer bandwidth
- inc_formfloat
toggle incremental form of ADRC, by default False. If the incremental form is toggled, the controller will return the incrementation to the current control signal. This value needs to be accumulated by the user. Functionally identical to the non-incremental (normal) form.
- eso_inittuple, optional
initial state for the extended state observer, by default False
- r_limtuple, optional
rate limits for the control signal, by default (None, None)
- m_limtuple, optional
magnitude limits for the control signal, by default (None, None)
- half_gaintuple, optional
half gain tuning for controller/observer gains, by default (False, False)
References
- 1
G. Herbst, “Practical active disturbance rejection control: Bumpless transfer, rate limitation, and incremental algorithm”, https://arxiv.org/abs/1908.04610
- 2
G. Herbst, “Half-Gain Tuning for Active Disturbance Rejection Control”, https://arxiv.org/abs/2003.03986
- __call__(y, u, r, zoh=False)[source]¶
Returns value of the control signal depending on current measurements, previous control action, reference signal.
- Parameters
- yfloat
Current measurement y[k] of the process
- ufloat
Previous control signal u[k-1]
- rfloat
Current reference signal r[k]
- zohbool, optional
Only update every delta seconds, by default False
- Returns
- float
Current control signal u[k]
- property eso_states¶
Returns the states of the linear extended state observer
- Returns
- tuple
States of the linear extended state observer
- property limiter¶
Returns the value of both limiters of the controller
- Returns
- tuple of tuples
Returns (magnitude_limits, rate_limits)
- class pyadrc.pyadrc.TransferFunction(order, delta, b0, w_cl, k_eso, eso_init=None, r_lim=(None, None), m_lim=(None, None), half_gain=(False, False), method='general_terms')[source]¶
Discrete time linear active disturbance rejection control in transfer function representation
- Parameters
- orderint
first- or second-order ADRC TF
- deltafloat
sampling time in seconds
- b0float
modelling parameter b0
- w_clfloat
desired closed-loop bandwidth [rad/s], 4 / w_cl and 6 / w_cl is the corresponding settling time in seconds for first- and second-order ADRC respectively
- k_esofloat
observer bandwidth is parametrized as k_eso-multiple faster than w_cl
- eso_initnp.array, optional
initial state for the extended state observer, by default None
- r_limtuple, optional
rate limits for the control output, by default (None, None)
- m_limtuple, optional
magnitude limits for the control output, by default (None, None)
- half_gaintuple, optional
half gain tuning for controller/observer gains, by default (False, False)
- methodstr, optional, ‘general_terms’ or ‘bandwidth’
method with which the transfer function parameters are calculated, functionally identical, but general_terms is used to implement half gain tuning
References
- 4
G. Herbst, Transfer Function Analysis and Implementation of Active Disturbance Rejection Control https://arxiv.org/abs/2011.01044
- __call__(y, r)[source]¶
Control loop call
- Parameters
- yfloat
current output signal
- rfloat
current reference signal
- Returns
- float
control signal to the plant (accumulator output)
- property accumulator¶
Get accumulator
- Returns
- float
accumulator output
- property parameters¶
Get parameters
- Returns
- dict
calculated paramaters
pyadrc.models¶
- class pyadrc.models.QuadAltitude(dt=0.001, m=0.028, g=9.807)[source]¶
Discrete-time model of altitude of a quadcopter
- Parameters
- dtfloat, optional
Discretization time (zero-order hold), by default 0.001
- mfloat, optional
Mass of the quadcopter, by default 0.028
- gfloat, optional
Gravitational acceleration, by default 9.807
- __call__(u)[source]¶
Input port to the quadcopter
- Parameters
- ufloat
Thrust of the rotors
- Returns
- float:
Current altitude of quadcopter
- property states¶
Return the state of the quadcopter
- class pyadrc.models.System(K=1.0, T=1.0, D=None, delta=0.001)[source]¶
Python class to generate a first-or second-order process for simulation and verification purposes
- Parameters
- Kfloat, optional
system gain, by default 1.0
- Tfloat, optional
time constant, by default 1.0
- Dfloat, optional
damping factor, by default None
- deltafloat, optional
discretization time in seconds, by default 0.001