Skip to content

Commit 1c16d62

Browse files
committed
update docstrings with math in stochsys, statesp for proper formatting
1 parent a6e85c4 commit 1c16d62

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

control/statesp.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,19 @@ def _f2s(f):
164164

165165

166166
class StateSpace(LTI):
167-
"""StateSpace(A, B, C, D[, dt])
167+
r"""StateSpace(A, B, C, D[, dt])
168168
169169
A class for representing state-space models.
170170
171171
The StateSpace class is used to represent state-space realizations of
172172
linear time-invariant (LTI) systems:
173-
173+
174174
.. math::
175-
dx/dt = A x + B u
176-
177-
y = C x + D u
175+
176+
dx/dt &= A x + B u \\
177+
y &= C x + D u
178178
179-
where u is the input, y is the output, and x is the state.
179+
where `u` is the input, `y` is the output, and `x` is the state.
180180
181181
Parameters
182182
----------

control/stochsys.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -311,28 +311,32 @@ def create_estimator_iosystem(
311311
sys, QN, RN, P0=None, G=None, C=None,
312312
state_labels='xhat[{i}]', output_labels='xhat[{i}]',
313313
covariance_labels='P[{i},{j}]', sensor_labels=None):
314-
"""Create an I/O system implementing a linqear quadratic estimator
314+
r"""Create an I/O system implementing a linear quadratic estimator
315315
316316
This function creates an input/output system that implements a
317317
continuous time state estimator of the form
318318
319-
\dot xhat = A x + B u - L (C xhat - y)
320-
\dot P = A P + P A^T + F QN F^T - P C^T RN^{-1} C P
321-
L = P C^T RN^{-1}
319+
.. math::
320+
321+
d \hat{x}/dt &= A \hat{x} + B u - L (C \hat{x} - y) \\
322+
dP/dt &= A P + P A^T + F Q_N F^T - P C^T R_N^{-1} C P \\
323+
L &= P C^T R_N^{-1}
322324
323325
or a discrete time state estimator of the form
324326
325-
xhat[k + 1] = A x[k] + B u[k] - L (C xhat[k] - y[k])
326-
P[k + 1] = A P A^T + F QN F^T - A P C^T Reps^{-1} C P A
327-
L = A P C^T Reps^{-1}
327+
.. math::
328+
329+
\hat{x}[k+1] &= A \hat{x}[k] + B u[k] - L (C \hat{x}[k] - y[k]) \\
330+
P[k+1] &= A P A^T + F Q_N F^T - A P C^T R_e^{-1} C P A \\
331+
L &= A P C^T R_e^{-1}
328332
329-
where Reps = RN + C P C^T. It can be called in the form
333+
where :math:`R_e = R_N + C P C^T`. It can be called in the form::
330334
331335
estim = ct.create_estimator_iosystem(sys, QN, RN)
332336
333-
where ``sys`` is the process dynamics and QN and RN are the covariance
337+
where `sys` is the process dynamics and `QN` and `RN` are the covariance
334338
of the disturbance noise and sensor noise. The function returns the
335-
estimator ``estim`` as I/O system with a parameter ``correct`` that can
339+
estimator `estim` as I/O system with a parameter `correct` that can
336340
be used to turn off the correction term in the estimation (for forward
337341
predictions).
338342
@@ -356,8 +360,8 @@ def create_estimator_iosystem(
356360
{state, covariance, sensor, output}_labels : str or list of str, optional
357361
Set the name of the signals to use for the internal state, covariance,
358362
sensors, and outputs (state estimate). If a single string is
359-
specified, it should be a format string using the variable ``i`` as an
360-
index (or ``i`` and ``j`` for covariance). Otherwise, a list of
363+
specified, it should be a format string using the variable `i` as an
364+
index (or `i` and `j` for covariance). Otherwise, a list of
361365
strings matching the size of the respective signal should be used.
362366
Default is ``'xhat[{i}]'`` for state and output labels, ``'y[{i}]'``
363367
for output labels and ``'P[{i},{j}]'`` for covariance labels.
@@ -372,18 +376,18 @@ def create_estimator_iosystem(
372376
Notes
373377
-----
374378
This function can be used with the ``create_statefbk_iosystem()`` function
375-
to create a closed loop, output-feedback, state space controller:
379+
to create a closed loop, output-feedback, state space controller::
376380
377381
K, _, _ = ct.lqr(sys, Q, R)
378382
est = ct.create_estimator_iosystem(sys, QN, RN, P0)
379383
ctrl, clsys = ct.create_statefbk_iosystem(sys, K, estimator=est)
380384
381-
The estimator can also be run on its own to process a noisy signal:
385+
The estimator can also be run on its own to process a noisy signal::
382386
383387
resp = ct.input_output_response(est, T, [Y, U], [X0, P0])
384388
385389
If desired, the ``correct`` parameter can be set to ``False`` to allow
386-
prediction with no additional sensor information:
390+
prediction with no additional sensor information::
387391
388392
resp = ct.input_output_response(
389393
est, T, 0, [X0, P0], param={'correct': False)

0 commit comments

Comments
 (0)