types.core.DynamicsFunction
types.core.DynamicsFunction
Dynamics function f(x, u).
Continuous: f(x, u, t) → dx/dt (rate of change) Discrete: f(x, u) → x[k+1] (next state)
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| x | StateVector | Current state (nx,) | required |
| u | Optional[ControlVector] | Control input (nu,) or None for autonomous | required |
Returns
| Name | Type | Description |
|---|---|---|
| StateVector | Dynamics evaluation (nx,) |
Examples
>>> # Linear dynamics
>>> def f_linear(x: StateVector, u: ControlVector) -> StateVector:
... return A @ x + B @ u
>>>
>>> # Nonlinear dynamics
>>> def f_nonlinear(x: StateVector, u: ControlVector) -> StateVector:
... x1, x2 = x
... return np.array([x2, -np.sin(x1) + u[0]])
>>>
>>> # Autonomous
>>> def f_autonomous(x: StateVector, u: Optional[ControlVector] = None) -> StateVector:
... return -alpha * x