virtualmodelcontrol.sim.run

run(plant, controller, clock, T, guard=None, z0=None, record=(), window=None)

Run controller on plant for T [s]; returns the recorded run.

Each step reads the plant, asks the controller for a command (zero torque if the guard trips), writes it, then advances a simulated plant by clock.dt or, with a WallClock, waits for the next step. On real time, T=None runs until Ctrl-C, and Ctrl-C ends the run with the log so far, after the step that is running. z0 sets the controller’s initial virtual state, or is a function of the first reading that returns it. The log holds, at every step, the measurements, the command (and the law’s torque before any output stage), the virtual state z when the controller has one, and what record asks for (see RECORDS); a value the step did not compute is NaN. Its meta holds the Params at the start and the plant’s hardware profile. On real time, window [s] keeps only the last seconds of a run that goes on for hours (up to a quarter more, until the next trim); info["steps"] still counts them all.

Parameters:
plant : Any

controller : Any

clock : SimClock | WallClock

T : float | None

guard : Guard | None

z0 : Any

record : Iterable[str] | str

window : float | None

Return type:

RunLog