DynamicalSystem

A dynamical system is defined by two functions:

  • f: State transition function (optional) - computes next state

  • h: Output/observation function (required) - computes output from state

The dynamical system abstraction can model any control system componenent (e.g. plants, controllers, observers, signal generators, etc…) and enables their composition via the discrete-time diagram.

class dynamicalnodes.dynamical_system.DynamicalSystem(*, f=None, h)[source]

Bases: object

A discrete-time dynamical system with (optional) state transition and (required) output functions.

Examples

Autonomous System with Parameters – Exponential Growth

(put math and background explanation here.)

>>> def fexp(x_k):
...     return x_k dt
>>> def hexp(x_k, u_k, dt):
...     return x_k
>>> plant = DynamicalSystem(f=f_plant, h=h_plant)
>>> x_next, y = plant.step(x_k=0.0, u_k=1.0, dt=0.1)
>>> x_next
0.1

Non-autonomous System with control input and parameters – Car Dynamics

(put math and background explanation here.)

Signal Generator (stateless DTDS)

(put math and background explanation here.)

>>> def h_ref(tk, params):
...     u0, t_step = params
...     return u0 if tk >= t_step else 0.0
>>> ref_signal = DynamicalSystem(h=h_ref)
>>> ref_signal.step(tk=0.0, params=(100, 15))  # Before step time
0.0
>>> ref_signal.step(tk=20.0, params=(100, 15))  # After step time
100

Note: All functions have type hints in their signature. This is the modern (and much better) way of writing functions.

See also

ROSNode

Wraps a DynamicalSystem as a ROS2 node for deployment.

Parameters:
  • f (Callable | None)

  • h (Callable)

property f: Callable | None

State transition function f(x_k, u_k, …) -> x_{k+1}, or None if stateless.

property h: Callable

Observation function h(x_k, u_k, …) -> y_k.

step(**kwargs)[source]

Compute x_{k+1}, y_k = (f(*f_args, **f_kwargs), h(*h_args, **h_kwargs)). For each keyword=value in **kwargs, step binds the value to the keyword and then passes it to any function that declares that keyword as a parameter. See examples below.

Return type:

Any

Returns:

  • Any

  • If f is None (stateless system) – Returns y_k = h(…)

  • If f is defined (stateful system) – Returns (x_{k+1}, y_k) = (f(…), h(…))

Parameters:

kwargs (Any)

Examples

Autonomous System with Parameters – Exponential Growth

(put math and background explanation here.)

>>> def fexp(x_k):
...     return x_k dt
>>> def hexp(x_k, u_k, dt):
...     return x_k
>>> plant = DynamicalSystem(f=f_plant, h=h_plant)
>>> x_next, y = plant.step(x_k=0.0, u_k=1.0, dt=0.1)
>>> x_next
0.1

Non-autonomous System with control input and parameters – Car Dynamics

(put math and background explanation here.)

Signal Generator (stateless DTDS)

(put math and background explanation here.)

>>> def h_ref(tk, params):
...     u0, t_step = params
...     return u0 if tk >= t_step else 0.0
>>> ref_signal = DynamicalSystem(h=h_ref)
>>> ref_signal.step(tk=0.0, params=(100, 15))  # Before step time
0.0
>>> ref_signal.step(tk=20.0, params=(100, 15))  # After step time
100

Note: All functions have type hints in their signature. This is the modern (and much better) way of writing functions.