pySimBlocks.blocks.observers.luenberger

class pySimBlocks.blocks.observers.luenberger.Luenberger(name: str, A: ArrayLike, B: ArrayLike, C: ArrayLike, L: ArrayLike, x0: TypeAliasForwardRef('ArrayLike') | None = None, sample_time: float | None = None)[source]

Bases: Block

Discrete-time Luenberger state observer block.

Estimates the state of a linear system using the correction law:

y_hat[k] = C x_hat[k]

x_hat[k+1] = A x_hat[k] + B u[k] + L (y[k] - y_hat[k])

The D matrix is intentionally not supported. Input column-vector shapes are frozen after the first call and must remain constant.

A

State transition matrix of shape (n, n).

B

Input matrix of shape (n, m).

C

Output matrix of shape (p, n).

L

Observer gain matrix of shape (n, p).

direct_feedthrough = False

True if outputs depend directly on inputs.

initialize(t0: float) None[source]

Set initial outputs from the initial state estimate.

Parameters:

t0 – Initial simulation time in seconds.

output_update(t: float, dt: float) None[source]

Compute x_hat and y_hat outputs from the committed state.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

state_update(t: float, dt: float) None[source]

Update the state estimate using the observer correction law.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

Raises:
  • RuntimeError – If inputs u or y are not connected.

  • ValueError – If input shapes are incompatible or have changed.