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 sys
is the process dynamics and K
is the state (+ integral) feedback gain (e.g., 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
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.
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.
If an array is given, 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.
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.
Specify the feedforward gain, k_f
. Used only for the reference gain design pattern. If not given and if sys
is a StateSpace
(linear) system, will be computed as -1/(C (A-BK)^{-1}) B.
If set to ‘refgain’, the reference gain design pattern is used to create the controller instead of the trajectory generation (‘trajgen’) pattern.
If this keyword is specified, the controller can include integral action in addition to state feedback. The value of the integral_action
keyword 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.
NonlinearIOSystem
, optional
If an estimator is provided, use the states of the estimator as the system inputs for the controller.
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 input u_d
, and the system state x
(or state estimate xhat
, if an estimator is given). If value is an integer q
, the first q
values 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 state x_d
.
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.
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 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.
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 input u_d
, 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). For the ‘refgain’ design pattern, the system takes as inputs the reference input r
and the system or estimated state. 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
.
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 x
and the applied input u
(vertically stacked).
Specify the indices of the system inputs that should be determined by the state feedback controller. If value is an integer m
, the first m
system 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.
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 first n
system 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.
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 i
as 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 the inputs
keyword.
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.
System name. If unspecified, a generic name ‘sys[id]’ is generated with a unique integer id.
System parameter values. By default, these will be copied from sys
and ctrl
, 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)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4