newton.controllers.ControllerBase#

class newton.controllers.ControllerBase[source]#

Bases: ABC, Generic[InputT, OutputT]

Abstract interface for a single Newton control law.

Every concrete control law (joint impedance, differential IK, …) subclasses ControllerBase directly. There is no framework-level composition: users who want to combine multiple control laws call each one’s step() in sequence themselves.

Subclasses are responsible for:

  • is_graphable(): predicate the user can query to decide whether graph capture is possible.

  • input(), output(): allocate fresh typed input/output structs. Baked-in arrays (gains passed as a wp.array at construction) are stored on the controller and do not appear on the input struct.

  • step(): read the input struct’s live arrays, run kernels, write the output struct’s live arrays. Writes are slot-replacing (=, not +=); composing laws is the user’s job.

abstractmethod input()#

Allocate a fresh input struct with zero-initialised arrays.

The user typically reassigns fields to point at live data buffers. Fields for disabled features are None.

abstractmethod is_graphable()#

Whether step() is safe to capture in a graph.

abstractmethod output()#

Allocate a fresh output struct.

abstractmethod step(*, inputs, outputs, dt)#

Run one control step.

Parameters:
  • inputs (InputT) – Populated input struct (see input()).

  • outputs (OutputT) – Output struct to write into (see output()).

  • dt (float | wp.array[wp.float32]) – Step duration [s].