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
) – The constant input of LTI system,c2 (
Tensor
) – The constant output of LTI system.
A linear time-invariant lumped system can be described by state-space equation of the form:
\[\begin{align*} \mathbf{z} = \mathbf{A}\mathbf{x} + \mathbf{B}\mathbf{u} + \mathbf{c}_1 \\ \mathbf{y} = \mathbf{C}\mathbf{x} + \mathbf{D}\mathbf{u} + \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) >>> 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.