Driving a model live: Start paused and waveforms
"Running a simulation" introduced online runs, which pace a model against the clock so that you can watch it and touch it while it moves. This page covers two things that make that more useful: starting a run paused, so that nothing happens until you are ready, and putting a waveform on a live parameter, so that a value can be made to swing by itself instead of being nudged by hand.
The example is the Position Controlled Joint from the Examples dialog: a controller drives a joint towards a target angle, the setpoint, which is a live parameter that starts at 1.2 radians.
Starting paused
Open the Run dialog and switch Online simulation on. The dialog now offers Start paused beside Start.
Start paused holds the run before its first step. The starting state is written as the first sample and nothing is integrated until you press Resume. The live controls open by themselves and so does the Control changes panel, so you can set things up first.
This is different from starting a run and pressing Pause quickly. The hold is part of the run's settings, so anything you set while it lasts applies from the very first step, with no race against the engine.
Putting a waveform on a parameter
Each live parameter has a slider and a number box, and below them a transition menu. Step, Ramp and Pulse are the original three. The menu also offers five waveforms: Sine, Square, Triangle, Sawtooth and Noise. Choosing one reveals its fields and draws a preview.
A waveform is a signal around the parameter's value at the moment it starts. It has:
- Amplitude, the largest swing either side of the value.
- Frequency, in cycles per second.
- Phase, in degrees, which sets where in its cycle it starts.
- Duration, optional, after which the parameter goes back to its own value. Left empty, the wave runs until the run ends.
- Duty cycle, for a square wave only: the fraction of each cycle spent high, one half by default.
- Seed, for noise only. Noise draws a new value within the amplitude as many times per second as the frequency says and holds it between draws, and the same seed gives the same noise every time.
Sine, triangle and sawtooth begin at the parameter's value and rise. A square wave begins high. Setting a value outright, with the slider or the number box, ends any waveform running on that parameter.
Here the setpoint gets a sine wave of 0.4 radians at 0.2 Hz, so it swings between 0.8 and 1.6 once every five seconds. The Start button beside the fields starts it. Because the run is paused, it starts at zero. Then Resume lets the run go.
Watching what you did
The Control changes panel on the left plots every parameter that has been changed during the run, one chart each, as the changes are made. The axis spans the whole run so that it does not move, the line grows along it, a dot marks the latest value and the changes are marked on it. A cursor follows the playback position.
The panel opens by itself when a live run starts and can be closed and reopened with the Changes button in the transport bar.
Run to 20 seconds, the result is complete and the panel shows the whole wave:
What the joint did
The joint follows the setpoint but does not keep up with it. After the first eight seconds, once the start-up is over, the setpoint still swings between 0.8 and 1.6, but the joint's angle only ranges from 1.02 to 1.38. At this frequency the controller and motor cannot swing the joint through the whole range before the target turns round again. Try other amplitudes and frequencies, live, to see where it stops keeping up.
A note on the stability monitor
The stability counter in the transport bar reads 8 by the end of this run. The same finding raised again and again for one state is listed once, so the panel's title reads "8 findings · 46 occurrences".
A hollow dot marks an early check, which is the monitor's cheap test for a state that has grown for four steps in a row. A controller moving a joint from rest does that early on, so ordinary behaviour raises it too, and a confirmed problem gets an orange dot instead. A finding is a reason to look, not proof of a problem: Check convergence re-runs the flagged node at higher substep counts and says whether the result actually converged. "Numerical stability diagnostics" explains the findings and what each costs.
What to remember
- Start paused is part of the run's settings. Values set during the hold apply from step zero.
- A waveform is relative to the parameter's value when it starts, and it ends when you set a value outright.
- The same seed gives the same noise, so a noisy live run can be repeated exactly.
- The changes you make are recorded with the result, and a fork keeps the history before its fork. "Forking a run to try a what-if" shows how to branch from any moment of a run.
Follow Konjugate on LinkedIn for updates, or subscribe via RSS.
Comments
Post a Comment