control.create_statefbk_iosystem
- control.create_statefbk_iosystem(sys, gain, feedfwd_gain=None, integral_action=None, estimator=None, controller_type=None, xd_labels=None, ud_labels=None, ref_labels=None, feedfwd_pattern='trajgen', gainsched_indices=None, gainsched_method='linear', control_indices=None, state_indices=None, name=None, inputs=None, outputs=None, states=None, params=None, **kwargs)[source]
Create an I/O system using a (full) state feedback controller.
This function creates an input/output system that implements a state feedback controller of the form

by calling
ctrl, clsys = ct.create_statefbk_iosystem(sys, K)
where
sysis the process dynamics andKis the state (+ integral) feedback gain (e.g., from LQR). The function returns the controllerctrland the closed loop systemsclsys, both as I/O systems.A gain scheduled controller can also be created, by passing a list of gains and a corresponding list of values of a set of scheduling variables. In this case, the controller has the form

where
represents the scheduling variable.Alternatively, a controller of the form

can be created by calling
- ctrl, clsys = ct.create_statefbk_iosystem(
sys, K, kf, feedfwd_pattern=’refgain’)
In either form, an estimator can also be used to compute the estimated state from the input and output measurements.
- Parameters:
- sys
NonlinearIOSystem The I/O system that represents the process dynamics. If no estimator is given, the output of this system should represent the full state.
- gainndarray, tuple, or I/O system
If an array is given, it represents the state feedback gain (
K). This matrix defines the gains to be applied to the system. Ifintegral_actionis None, then the dimensions of this array should be (sys.ninputs, sys.nstates). Ifintegral actionis set to a matrix or a function, then additional columns represent the gains of the integral states of the controller.If a tuple is given, then it specifies a gain schedule. The tuple should be of the form
(gains, points)where gains is a list of gainsK_jand points is a list of valuesmu_jat which the gains are computed. Thegainsched_indicesparameter should be used to specify the scheduling variables.If an I/O system is given, the error e = x - xd is passed to the system and the output is used as the feedback compensation term.
- feedfwd_gainarray_like, optional
Specify the feedforward gain,
k_f. Used only for the reference gain design pattern. If not given and ifsysis aStateSpace(linear) system, will be computed as -1/(C (A-BK)^{-1}) B.- feedfwd_patternstr, optional
If set to ‘refgain’, the reference gain design pattern is used to create the controller instead of the trajectory generation (‘trajgen’) pattern.
- integral_actionndarray, optional
If this keyword is specified, the controller can include integral action in addition to state feedback. The value of the
integral_actionkeyword should be an ndarray that will be multiplied by the current and desired state to generate the error for the internal integrator states of the control law.- estimator
NonlinearIOSystem, optional If an estimator is provided, use the states of the estimator as the system inputs for the controller.
- gainsched_indicesint, slice, or list of int or str, optional
If a gain scheduled controller is specified, specify the indices of the controller input to use for scheduling the gain. The input to the controller is the desired state
x_d, the desired inputu_d, and the system statex(or state estimatexhat, if an estimator is given). If value is an integerq, the firstqvalues of the[x_d, u_d, x]vector are used. Otherwise, the value should be a slice or a list of indices. The list of indices can be specified as either integer offsets or as signal names. The default is to use the desired statex_d.- gainsched_methodstr, optional
The method to use for gain scheduling. Possible values are ‘linear’ (default), ‘nearest’, and ‘cubic’. More information is available in
scipy.interpolate.griddata. For points outside of the convex hull of the scheduling points, the gain at the nearest point is used.- controller_type‘linear’ or ‘nonlinear’, optional
Set the type of controller to create. The default for a linear gain is a linear controller implementing the LQR regulator. If the type is ‘nonlinear’, a
NonlinearIOSystemis created instead, with the gainKas a parameter (allowing modifications of the gain at runtime). If the gain parameter is a tuple, then a nonlinear, gain-scheduled controller is created.
- sys
- Returns:
- ctrl
NonlinearIOSystem Input/output system representing the controller. For the ‘trajgen’ design pattern (default), this system takes as inputs the desired state
x_d, the desired inputu_d, and either the system statexor the estimated statexhat. It outputs the controller actionuaccording to the formula u = u_d - K(x - x_d). For the ‘refgain’ design pattern, the system takes as inputs the reference inputrand the system or estimated state. If the keywordintegral_actionis specified, then an additional set of integrators is included in the control system (with the gain matrixKhaving the integral gains appended after the state gains). If a gain scheduled controller is specified, the gain (proportional and integral) are evaluated using the scheduling variables specified bygainsched_indices.- clsys
NonlinearIOSystem Input/output system representing the closed loop system. This system takes as inputs the desired trajectory (x_d, u_d) and outputs the system state
xand the applied inputu(vertically stacked).
- ctrl
- Other Parameters:
- control_indicesint, slice, or list of int or str, optional
Specify the indices of the system inputs that should be determined by the state feedback controller. If value is an integer
m, the firstmsystem inputs are used. Otherwise, the value should be a slice or a list of indices. The list of indices can be specified as either integer offsets or as system input signal names. If not specified, defaults to the system inputs.- state_indicesint, slice, or list of int or str, optional
Specify the indices of the system (or estimator) outputs that should be used by the state feedback controller. If value is an integer
n, the firstnsystem states are used. Otherwise, the value should be a slice or a list of indices. The list of indices can be specified as either integer offsets or as estimator/system output signal names. If not specified, defaults to the system states.- xd_labels, ud_labels, ref_labelsstr or list of str, optional
Set the name of the signals to use for the desired state and inputs or the reference inputs (for the ‘refgain’ design pattern). If a single string is specified, it should be a format string using the variable
ias an index. Otherwise, a list of strings matching the size of x_d and u_d, respectively, should be used. Default is “xd[{i}]” for xd_labels and “ud[{i}]” for ud_labels. These settings can also be overridden using theinputskeyword.- inputs, outputs, statesstr, or list of str, optional
List of strings that name the individual signals of the transformed system. If not given, the inputs, outputs, and states are the same as the original system.
- namestring, optional
System name. If unspecified, a generic name ‘sys[id]’ is generated with a unique integer id.
- paramsdict, optional
System parameter values. By default, these will be copied from
sysandctrl, but can be overridden with this keyword.
Examples
>>> import control as ct >>> import numpy as np >>> >>> A = [[0, 1], [-0.5, -0.1]] >>> B = [[0], [1]] >>> C = np.eye(2) >>> D = np.zeros((2, 1)) >>> sys = ct.ss(A, B, C, D) >>> >>> Q = np.eye(2) >>> R = np.eye(1) >>> >>> K, _, _ = ct.lqr(sys,Q,R) >>> ctrl, clsys = ct.create_statefbk_iosystem(sys, K)