Shortcuts

pypose.module.LTI

class pypose.module.LTI(A, B, C, D, c1=None, c2=None)[source]

Discrete-time Linear Time-Invariant (LTI) system.

Parameters:
  • A (Tensor) – The state matrix of LTI system.

  • B (Tensor) – The input matrix of LTI system.

  • C (Tensor) – The output matrix of LTI system.

  • D (Tensor) – The observation matrix of LTI system,

  • c1 (Tensor, optional) – The constant input of LTI system. Default: None

  • c2 (Tensor, optional) – The constant output of LTI system. Default: None

A linear time-invariant lumped system can be described by state-space equation of the form:

\[\begin{align*} \mathbf{x}_{k+1} = \mathbf{A}\mathbf{x}_k + \mathbf{B}\mathbf{u}_k + \mathbf{c}_1 \\ \mathbf{y}_k = \mathbf{C}\mathbf{x}_k + \mathbf{D}\mathbf{u}_k + \mathbf{c}_2 \\ \end{align*} \]

where \(\mathbf{x}\) and \(\mathbf{u}\) are state and input of the current timestamp of LTI system.

Note

The variables including state and input are row vectors, which is the last dimension of a Tensor. A, B, C, D, x, u could be a single matrix or batched matrices. In the batch case, their dimensions must be consistent so that they can be multiplied for each channel.

Example

>>> # Batch, State, Input, Observe Dimension
>>> Bd, Sd, Id, Od = 2, 3, 2, 2
>>> # Linear System Matrices
>>> device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
>>> A = torch.randn(Bd, Sd, Sd)
>>> B = torch.randn(Bd, Sd, Id)
>>> C = torch.randn(Bd, Od, Sd)
>>> D = torch.randn(Bd, Od, Id)
>>> c1 = torch.randn(Bd, Sd)
>>> c2 = torch.randn(Bd, Od)
...
>>> lti = pp.module.LTI(A, B, C, D, c1, c2).to(device)
...
>>> state = torch.randn(Bd, Sd, device=device)
>>> input = torch.randn(Bd, Id, device=device)
>>> state, observation = lti(state, input)
tensor([[[-8.5639,  0.0523, -0.2576]],
        [[ 4.1013, -1.5452, -0.0233]]]),
tensor([[[-3.5780, -2.2970, -2.9314]],
        [[-0.4358,  1.7306,  2.7514]]]))

Note

In this general example, all variables are in a batch. User definable as appropriate.

Note

More practical examples can be found at examples/module/dynamics.

property A

System transision matrix.

property B

System input matrix.

property C

System output matrix.

property D

System observation matrix.

property c1

Constant term generated by state-transition.

property c2

Constant term generated by observation.

forward(state, input)[source]

Perform one step advance for the LTI system.

Parameters:
  • state (Tensor) – The state (\(\mathbf{x}\)) of the system

  • input (Tensor) – The input (\(\mathbf{u}\)) of the system.

Returns:

The state and observation of the system in next time step.

Return type:

tuple of Tensor

observation(state, input)[source]

Return the observation of LTI system.

\[\mathbf{y}_k = \mathbf{C}\mathbf{x}_k + \mathbf{D}\mathbf{u}_k + \mathbf{c}_2 \]
Parameters:
  • state (Tensor) – The state (\(\mathbf{x}\)) of the system

  • input (Tensor) – The input (\(\mathbf{u}\)) of the system.

Returns:

The observation of the system in next time step.

Return type:

Tensor

state_transition(state, input)[source]

Perform one step of LTI state transition.

\[\mathbf{x}_{k+1} = \mathbf{A}\mathbf{x}_k + \mathbf{B}\mathbf{u}_k + \mathbf{c}_1 \]
Parameters:
  • state (Tensor) – The state (\(\mathbf{x}\)) of the system

  • input (Tensor) – The input (\(\mathbf{u}\)) of the system.

Returns:

The state the system in next time step.

Return type:

Tensor

Docs

Access documentation for PyPose

View Docs

Tutorials

Get started with tutorials and examples

View Tutorials

Get Started

Find resources and how to start using pypose

View Resources