control.create_statefbk_iosystem

control.create_statefbk_iosystem(sys, gain, integral_action=None, estimator=None, type=None, xd_labels='xd[{i}]', ud_labels='ud[{i}]', gainsched_indices=None, gainsched_method='linear', name=None, inputs=None, outputs=None, states=None)[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

u = ud - K_p (x - xd) - K_i integral(C x - C x_d)

It can be called in the form

ctrl, clsys = ct.create_statefbk_iosystem(sys, K)

where sys is the process dynamics and K is the state (+ integral) feedback gain (eg, from LQR). The function returns the controller ctrl and the closed loop systems clsys, 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

u = ud - K_p(mu) (x - xd) - K_i(mu) integral(C x - C x_d)

where mu represents the scheduling variable.

Parameters
  • sys (InputOutputSystem) – The I/O system that represents the process dynamics. If no estimator is given, the output of this system should represent the full state.

  • gain (ndarray or tuple) –

    If a array is give, it represents the state feedback gain (K). This matrix defines the gains to be applied to the system. If integral_action is None, then the dimensions of this array should be (sys.ninputs, sys.nstates). If integral action is 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 gains K_j and points is a list of values \mu_j at which the gains are computed. The gainsched_indices parameter should be used to specify the scheduling variables.

  • xd_labels (str or list of str, optional) – Set the name of the signals to use for the desired state and inputs. If a single string is specified, it should be a format string using the variable i as an index. Otherwise, a list of strings matching the size of xd and ud, respectively, should be used. Default is 'xd[{i}]' for xd_labels and 'ud[{i}]' for ud_labels. These settings can also be overriden using the inputs keyword.

  • ud_labels (str or list of str, optional) – Set the name of the signals to use for the desired state and inputs. If a single string is specified, it should be a format string using the variable i as an index. Otherwise, a list of strings matching the size of xd and ud, respectively, should be used. Default is 'xd[{i}]' for xd_labels and 'ud[{i}]' for ud_labels. These settings can also be overriden using the inputs keyword.

  • integral_action (None, ndarray, or func, optional) – If this keyword is specified, the controller can include integral action in addition to state feedback. If integral_action is a matrix, it will be multiplied by the current and desired state to generate the error for the internal integrator states of the control law. If integral_action is a function h, that function will be called with the signature h(t, x, u, params) to obtain the outputs that should be integrated. The number of outputs that are to be integrated must match the number of additional columns in the K matrix.

  • estimator (InputOutputSystem, optional) – If an estimator is provided, use the states of the estimator as the system inputs for the controller.

  • gainsched_indices (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 xd, the desired input ud, and the system state x (or state estimate xhat, if an estimator is given). The indices can either be specified as integer offsets into the input vector or as strings matching the signal names of the input vector. The default is to use the desire state xd.

  • gainsched_method (str, 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.

  • 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 :class:NonlinearIOSystem is created instead, with the gain K as a parameter (allowing modifications of the gain at runtime). If the gain parameter is a tuple, then a nonlinear, gain-scheduled controller is created.

  • inputs (str, or list of str, optional) – List of strings that name the individual signals of the transformed system. If not given, the inputs and outputs are the same as the original system.

  • outputs (str, or list of str, optional) – List of strings that name the individual signals of the transformed system. If not given, the inputs and outputs are the same as the original system.

  • name (string, optional) – System name. If unspecified, a generic name <sys[id]> is generated with a unique integer id.

Returns

  • ctrl (InputOutputSystem) – Input/output system representing the controller. This system takes as inputs the desired state xd, the desired input ud, and either the system state x or the estimated state xhat. It outputs the controller action u according to the formula u =
u_d - K(x - x_d). If the keyword integral_action is specified, then an additional set of integrators is included in the control system (with the gain matrix K having 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 by gainsched_indices.

  • clsys (InputOutputSystem) – Input/output system representing the closed loop system. This systems takes as inputs the desired trajectory (xd, ud) and outputs the system state x and the applied input u (vertically stacked).