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.StateSpace(order, delta, b0, t_settle, k_eso, 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
- t_settlefloat
settling time in seconds, determines closed-loop bandwidth
- k_esofloat
observer bandwidth
- 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)
-
__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
magnitude_limiter¶ Returns the magnitude limits of the controller
- Returns
- tuple
magnitude limits of the controller
-
property
rate_limiter¶ Returns the rate limits of the controller
- Returns
- tuple
Rate limits of the controller
-
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
- 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
-
__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