@@ -296,14 +296,14 @@ def acker(A, B, poles):
296
296
297
297
298
298
def lqr (* args , ** kwargs ):
299
- """lqr(A, B, Q, R[, N])
299
+ r """lqr(A, B, Q, R[, N])
300
300
301
301
Linear quadratic regulator design.
302
302
303
303
The lqr() function computes the optimal state feedback controller
304
304
u = -K x that minimizes the quadratic cost
305
305
306
- .. math:: J = \\ int_0^\ \ infty (x' Q x + u' R u + 2 x' N u) dt
306
+ .. math:: J = \int_0^\infty (x' Q x + u' R u + 2 x' N u) dt
307
307
308
308
The function can be called with either 3, 4, or 5 arguments:
309
309
@@ -442,14 +442,14 @@ def lqr(*args, **kwargs):
442
442
443
443
444
444
def dlqr (* args , ** kwargs ):
445
- """dlqr(A, B, Q, R[, N])
445
+ r """dlqr(A, B, Q, R[, N])
446
446
447
447
Discrete-time linear quadratic regulator design.
448
448
449
449
The dlqr() function computes the optimal state feedback controller
450
450
u[n] = - K x[n] that minimizes the quadratic cost
451
451
452
- .. math:: J = \\ sum_0^\ \ infty (x[n]' Q x[n] + u[n]' R u[n] + 2 x[n]' N u[n])
452
+ .. math:: J = \sum_0^\infty (x[n]' Q x[n] + u[n]' R u[n] + 2 x[n]' N u[n])
453
453
454
454
The function can be called with either 3, 4, or 5 arguments:
455
455
@@ -584,14 +584,14 @@ def create_statefbk_iosystem(
584
584
xd_labels = None , ud_labels = None , gainsched_indices = None ,
585
585
gainsched_method = 'linear' , control_indices = None , state_indices = None ,
586
586
name = None , inputs = None , outputs = None , states = None , ** kwargs ):
587
- """Create an I/O system using a (full) state feedback controller.
587
+ r """Create an I/O system using a (full) state feedback controller.
588
588
589
589
This function creates an input/output system that implements a
590
590
state feedback controller of the form
591
591
592
- u = ud - K_p (x - xd ) - K_i integral (C x - C x_d)
592
+ .. math:: u = u_d - K_p (x - x_d ) - K_i \int (C x - C x_d)
593
593
594
- It can be called in the form
594
+ It can be called in the form::
595
595
596
596
ctrl, clsys = ct.create_statefbk_iosystem(sys, K)
597
597
@@ -603,9 +603,9 @@ def create_statefbk_iosystem(
603
603
gains and a corresponding list of values of a set of scheduling
604
604
variables. In this case, the controller has the form
605
605
606
- u = ud - K_p(mu) (x - xd ) - K_i(mu) integral (C x - C x_d)
606
+ .. math:: u = u_d - K_p(\ mu) (x - x_d ) - K_i(\ mu) \int (C x - C x_d)
607
607
608
- where mu represents the scheduling variable.
608
+ where :math:`\mu` represents the scheduling variable.
609
609
610
610
Parameters
611
611
----------
@@ -614,7 +614,7 @@ def create_statefbk_iosystem(
614
614
is given, the output of this system should represent the full state.
615
615
616
616
gain : ndarray or tuple
617
- If an array is given, it represents the state feedback gain (K ).
617
+ If an array is given, it represents the state feedback gain (`K` ).
618
618
This matrix defines the gains to be applied to the system. If
619
619
`integral_action` is None, then the dimensions of this array
620
620
should be (sys.ninputs, sys.nstates). If `integral action` is
@@ -623,18 +623,18 @@ def create_statefbk_iosystem(
623
623
624
624
If a tuple is given, then it specifies a gain schedule. The tuple
625
625
should be of the form `(gains, points)` where gains is a list of
626
- gains :math: `K_j` and points is a list of values :math:` \\ mu_j` at
627
- which the gains are computed. The `gainsched_indices` parameter
628
- should be used to specify the scheduling variables.
626
+ gains `K_j` and points is a list of values ` mu_j` at which the
627
+ gains are computed. The `gainsched_indices` parameter should be
628
+ used to specify the scheduling variables.
629
629
630
630
xd_labels, ud_labels : str or list of str, optional
631
631
Set the name of the signals to use for the desired state and
632
- inputs. If a single string is specified, it should be a
633
- format string using the variable `i` as an index. Otherwise,
634
- a list of strings matching the size of xd and ud,
635
- respectively, should be used. Default is "xd[{i}]" for
636
- xd_labels and "ud[{i}]" for ud_labels. These settings can
637
- also be overriden using the `inputs` keyword.
632
+ inputs. If a single string is specified, it should be a format
633
+ string using the variable `i` as an index. Otherwise, a list of
634
+ strings matching the size of `x_d` and `u_d`, respectively, should
635
+ be used. Default is "xd[{i}]" for xd_labels and "ud [{i}]" for
636
+ ud_labels. These settings can also be overridden using the
637
+ `inputs` keyword.
638
638
639
639
integral_action : ndarray, optional
640
640
If this keyword is specified, the controller can include integral
@@ -650,13 +650,13 @@ def create_statefbk_iosystem(
650
650
gainsched_indices : int, slice, or list of int or str, optional
651
651
If a gain scheduled controller is specified, specify the indices of
652
652
the controller input to use for scheduling the gain. The input to
653
- the controller is the desired state xd , the desired input ud, and
654
- the system state x (or state estimate xhat, if an estimator is
655
- given). If value is an integer `q`, the first `q` values of the
656
- [xd, ud , x] vector are used. Otherwise, the value should be a
657
- slice or a list of indices. The list of indices can be specified
658
- as either integer offsets or as signal names. The default is to
659
- use the desired state xd .
653
+ the controller is the desired state `x_d` , the desired input `u_d`,
654
+ and the system state `x` (or state estimate ` xhat` , if an
655
+ estimator is given). If value is an integer `q`, the first `q`
656
+ values of the `[x_d, u_d , x]` vector are used. Otherwise, the
657
+ value should be a slice or a list of indices. The list of indices
658
+ can be specified as either integer offsets or as signal names. The
659
+ default is to use the desired state `x_d` .
660
660
661
661
gainsched_method : str, optional
662
662
The method to use for gain scheduling. Possible values are 'linear'
@@ -677,10 +677,10 @@ def create_statefbk_iosystem(
677
677
-------
678
678
ctrl : NonlinearIOSystem
679
679
Input/output system representing the controller. This system
680
- takes as inputs the desired state `xd `, the desired input
681
- `ud `, and either the system state `x` or the estimated state
680
+ takes as inputs the desired state `x_d `, the desired input
681
+ `u_d `, and either the system state `x` or the estimated state
682
682
`xhat`. It outputs the controller action `u` according to the
683
- formula :math: `u = u_d - K(x - x_d)`. If the keyword
683
+ formula `u = u_d - K(x - x_d)`. If the keyword
684
684
`integral_action` is specified, then an additional set of
685
685
integrators is included in the control system (with the gain
686
686
matrix `K` having the integral gains appended after the state
@@ -690,7 +690,7 @@ def create_statefbk_iosystem(
690
690
691
691
clsys : NonlinearIOSystem
692
692
Input/output system representing the closed loop system. This
693
- systems takes as inputs the desired trajectory `(xd, ud )` and
693
+ system takes as inputs the desired trajectory `(x_d, u_d )` and
694
694
outputs the system state `x` and the applied input `u`
695
695
(vertically stacked).
696
696
@@ -721,6 +721,23 @@ def create_statefbk_iosystem(
721
721
System name. If unspecified, a generic name <sys[id]> is generated
722
722
with a unique integer id.
723
723
724
+ Examples
725
+ --------
726
+ >>> import control as ct
727
+ >>> import numpy as np
728
+ >>>
729
+ >>> A = [[0, 1], [-0.5, -0.1]]
730
+ >>> B = [[0], [1]]
731
+ >>> C = np.eye(2)
732
+ >>> D = np.zeros((2, 1))
733
+ >>> sys = ct.ss(A, B, C, D)
734
+ >>>
735
+ >>> Q = np.eye(2)
736
+ >>> R = np.eye(1)
737
+ >>>
738
+ >>> K, _, _ = ct.lqr(sys,Q,R)
739
+ >>> ctrl, clsys = ct.create_statefbk_iosystem(sys, K)
740
+
724
741
"""
725
742
# Make sure that we were passed an I/O system as an input
726
743
if not isinstance (sys , NonlinearIOSystem ):
0 commit comments