pySimBlocks.blocks.controllers.state_feedback

class pySimBlocks.blocks.controllers.state_feedback.StateFeedback(name: str, K: ArrayLike, G: ArrayLike, sample_time: float | None = None)[source]

Bases: Block

Discrete-time state-feedback controller block.

Implements a static discrete-time state-feedback control law:

u = G @ r - K @ x

Both inputs must be column vectors. No implicit flattening is performed.

K

State feedback gain matrix of shape (m, n).

G

Reference feedforward gain matrix of shape (m, p).

direct_feedthrough = True

True if outputs depend directly on inputs.

initialize(t0: float) None[source]

Set the output to zero, or compute u if inputs are already available.

Parameters:

t0 – Initial simulation time in seconds.

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

Compute the control output u = G @ r - K @ x.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

Raises:
  • RuntimeError – If input r or x is not connected.

  • ValueError – If input shapes do not match the gain matrices.

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

No-op: StateFeedback carries no internal state.