pub fn replay(
entry: &MachineEntry,
cfg: &Config,
trace: &Trace,
) -> Result<Trace, TraceError>Expand description
Plays the position setpoints of a trace through the simulator and returns what the simulated drives
did at the times of the trace’s rows. The replay starts from the trace’s own state, whatever the config’s start pose:
at rest at a pose before it, it runs up to the first row’s position setpoint at the first row’s measured speed, so a
recording cut out of a longer motion replays without the jolt of a start from rest. The run-up is a smootherstep of
the speed (rest to that speed, zero acceleration at both ends, RUN_UP_S or more, so that its acceleration stays
within a quarter of each axis’s limit), the way covered half the speed times its time; the pose it starts at has to
be within the axes’ ranges; the run-up starts where the machine’s setpoint stands at rest there (its motors, a sag
away from the tool) and takes that difference up on the way. A trace that starts at rest where the config’s own
machine stands at rest (a trace written by a run of the config) is replayed from that state with no run-up, the
first row the machine at rest, as before the run-up existed: it replays onto itself to rounding.
The setpoints become tool poses (the machine’s forward transformation) and run with their speeds and accelerations
as Command::RatedTrajectory, so the simulator’s own controller makes the speed and torque feedforward from them, as
it does for any path. With a row per profile cycle the position setpoints are reproduced exactly. Where the trace
carries the tool’s speed and acceleration setpoints (Trace::tool_rates, a file written by a run), those are the
rates; a drive’s trace has none, and they are derived from the rows (slopes: the quartic through the five rows
around each that do not straddle a step of the jerk), which gives a planned motion’s own. Slopes between rows were
off by up to jerk x row, which moved what the fit finds on a run’s own trace by up to 0.63 % (11 of its standard
errors on the six-strut platform). Behind the last row the motion carries on (below): the trace’s end is not forced to rest.