API Reference

state_space_design.lqrTool.cli

Command line interface for the LQR tool.

state_space_design.lqrTool.cli.build_parser()[source]

Build the command line parser.

Return type:

ArgumentParser

state_space_design.lqrTool.cli.main(argv=None)[source]
Parameters:

argv (list[str] | None)

Return type:

int

state_space_design.lqrTool.apis

class state_space_design.lqrTool.apis.LQRRunRequest(A: 'Optional[str]' = None, B: 'Optional[str]' = None, C: 'Optional[str]' = None, D: 'Optional[str]' = '0', num: 'Optional[str]' = None, den: 'Optional[str]' = None, Q: 'str' = 'eye', R: 'str' = '1', x0: 'Optional[str]' = None, step: 'bool' = False, step_amp: 'float' = 1.0, prefilter: 'PrefilterMode' = 'dcgain', tfinal: 'float' = 8.0, dt: 'float' = 0.01, plots: 'PlotsMode' = 'mpl')[source]

Bases: object

Parameters:
  • A (str | None)

  • B (str | None)

  • C (str | None)

  • D (str | None)

  • num (str | None)

  • den (str | None)

  • Q (str)

  • R (str)

  • x0 (str | None)

  • step (bool)

  • step_amp (float)

  • prefilter (Literal['ogata', 'dcgain', 'none'])

  • tfinal (float)

  • dt (float)

  • plots (Literal['mpl', 'plotly', 'both', 'none'])

A: str | None = None
B: str | None = None
C: str | None = None
D: str | None = '0'
Q: str = 'eye'
R: str = '1'
den: str | None = None
dt: float = 0.01
num: str | None = None
plots: Literal['mpl', 'plotly', 'both', 'none'] = 'mpl'
prefilter: Literal['ogata', 'dcgain', 'none'] = 'dcgain'
step: bool = False
step_amp: float = 1.0
tfinal: float = 8.0
to_jsonable()[source]
Return type:

Dict[str, Any]

x0: str | None = None
class state_space_design.lqrTool.apis.LQRRunResult(K: 'list', P: 'list', eig_cl: 'list', prefilter_gain: 'float | None', rank_ctrb: 'int', note: 'str' = '')[source]

Bases: object

Parameters:
  • K (list)

  • P (list)

  • eig_cl (list)

  • prefilter_gain (float | None)

  • rank_ctrb (int)

  • note (str)

K: list
P: list
eig_cl: list
note: str = ''
prefilter_gain: float | None
rank_ctrb: int
to_jsonable()[source]
Return type:

Dict[str, Any]

state_space_design.lqrTool.app

class state_space_design.lqrTool.app.LQRApp(req: 'LQRRunRequest')[source]

Bases: object

Parameters:

req (LQRRunRequest)

build_model()[source]
Return type:

StateSpaceModel

req: LQRRunRequest
run()[source]
Return type:

LQRRunResult

state_space_design.lqrTool.core

class state_space_design.lqrTool.core.LQRDesignResult(K: 'np.ndarray', P: 'np.ndarray', eig_cl: 'np.ndarray')[source]

Bases: object

Parameters:
  • K (ndarray)

  • P (ndarray)

  • eig_cl (ndarray)

K: ndarray
P: ndarray
eig_cl: ndarray
class state_space_design.lqrTool.core.Simulator[source]

Bases: object

Simulation utilities for initial and forced responses with robust result unpacking.

static forced_step(model, K, N, T, amp=1.0)[source]
Parameters:
Return type:

Trajectory

static initial(model, K, x0, T)[source]
Parameters:
Return type:

Trajectory

class state_space_design.lqrTool.core.StateSpaceModel(A: 'np.ndarray', B: 'np.ndarray', C: 'np.ndarray', D: 'np.ndarray')[source]

Bases: object

Parameters:
  • A (ndarray)

  • B (ndarray)

  • C (ndarray)

  • D (ndarray)

A: ndarray
B: ndarray
C: ndarray
D: ndarray
as_control()[source]
Return type:

StateSpace

property m: int
property n: int
property p: int
class state_space_design.lqrTool.core.Trajectory(T: 'np.ndarray', X: 'np.ndarray', Y: 'np.ndarray', U: 'np.ndarray')[source]

Bases: object

Parameters:
  • T (ndarray)

  • X (ndarray)

  • Y (ndarray)

  • U (ndarray)

T: ndarray
U: ndarray
X: ndarray
Y: ndarray

state_space_design.lqrTool.io

state_space_design.lqrTool.io.build_model_from_ABCD(A, B, C, D)[source]
Parameters:
  • A (str)

  • B (str)

  • C (str | None)

  • D (str | None)

Return type:

StateSpaceModel

state_space_design.lqrTool.io.build_model_from_tf(num, den, C=None, D=None)[source]
Parameters:
  • num (str)

  • den (str)

  • C (str | None)

  • D (str | None)

Return type:

StateSpaceModel

state_space_design.lqrTool.io.parse_Q(s, n)[source]
Parameters:
  • s (str)

  • n (int)

Return type:

ndarray

state_space_design.lqrTool.io.parse_R(s)[source]
Parameters:

s (str)

state_space_design.lqrTool.io.parse_matrix(s)[source]
Parameters:

s (str)

Return type:

ndarray

state_space_design.lqrTool.io.parse_vector(s)[source]
Parameters:

s (str)

Return type:

ndarray

state_space_design.lqrTool.plotting

state_space_design.lqrTool.plotting.plot_mpl_initial(T, x, y, u, title='LQR initial-condition response')[source]
Parameters:

title (str)

state_space_design.lqrTool.plotting.plot_mpl_step(T, x, y, u, title='LQR unit-step response (servo)')[source]
Parameters:

title (str)

state_space_design.lqrTool.plotting.plot_plotly_initial(T, x, y, u, title='LQR initial-condition response')[source]
Parameters:

title (str)

state_space_design.lqrTool.plotting.plot_plotly_step(T, x, y, u, title='LQR unit-step response (servo)')[source]
Parameters:

title (str)