Skip to main content

Module testkit

Module testkit 

Source
Expand description

The standard machine test suite. Every kinematics must pass it unchanged: transformation round trip, static hold, energy conservation, step-size convergence, determinism, and the energy balance with the losses the machine reports.

Structs§

Noise
Repeatable measurement noise from a linear congruential generator: for tests, and for the drives’ sensor noise, which has to be the same in every run.
PulseRun
A run that starts at rest, gets one smooth torque pulse and then only the holding torques.
StopRun
A run into a stop: at rest under the holding torques in the middle of the axes but axis axis, which stands 5 % of its range short of the end it is pushed towards, a constant push on top that asks for acc (signed) of its acceleration limit, for seconds in base steps dt, each cut as the machine asks (advance_refined), and no longer than settle after the first step cut (the contact and its bounce; a push held on can take a parallel machine through a singular pose). The energy less the work of the constant torques changes only by what the losses take.

Constants§

DT
LOSS_BUDGET_TOLERANCE
Tolerance of loss_budget, as a share of the work the motor torques did either way.
SUBSTEPS

Functions§

determinism
The same config and the same commands give bit-identical traces.
energy_conservation
With friction and control off, total energy drifts less than 0.1 % over 10 s. The drift is measured against the energy the pulse put in, which is far stricter than measuring against the gravitational potential.
energy_drift
The run of energy_conservation: how far the energy drifted at most over the 10 s after the pulse, and what the pulse put in (J).
frame_momentum_moves_its_first_moment
Where a machine tells its frame_momentum, the linear momentum is the rate of the first moment of what moves: at the middle of the axes, every axis moving at a tenth of its top speed, d/dt sum m r by central differences over +-1 us along the state’s rate equals sum m v within 1e-6 of it (plus 1e-9 N s).
loss_budget
The energy balance with losses: over a run with a strong torque pulse, the work of the motor torques (sum of torque times rotor angle turned, exact for torques held over a step) equals the change of the machine’s energy plus the time integral of every loss power it reports (signals starting with LOSS_PREFIX), to within LOSS_BUDGET_TOLERANCE. The run takes the integrator’s own sub-steps (DT / SUBSTEPS, one each) as its steps; the powers are taken at the end of each and summed times the step, which is the trapezoid rule but for the two ends of the run. What is left is that rule’s error on powers that change within a step (the bristles of a friction contact settle within microseconds when the speed reverses), and on a power that jumps, up to half of it times the step: a stop’s damper takes c v^2 as soon as the axis touches it. On the linear delta, whose carriages the pulse takes into their upper stops, one touches at 0.533 m/s 1.7 us before the end of a step: 5000 N s/m * 0.533^2 = 1422 W, of which the trapezoid booked 0.5 * 1422 W * 62.5 us = 0.044 J where 0.002 J were lost, 0.042 J off against the 0.018 J allowed; on the 15.6 us sub-steps at most 0.011 J. The energy parts it reports (energy.*) add up to Machine::energy. A machine that reports no loss powers is not checked.
mid_pose
record_check
Appends one check against an outside number as a JSON line to the file KS_VALIDATION_OUT names, for the validation dashboard (tools/validation_dashboard.py); nothing when the variable is unset. It asserts nothing: the test’s own assert stays the judge. allowed is the largest difference the test accepts, in the reference’s unit (a relative tolerance times |reference|, or the absolute one). The test is the running thread’s name, as libtest and nextest name it, and the source line is the caller’s.
round_trip
Forward of inverse returns the starting pose within 1e-9, on a grid over the whole workspace: the box of the axis ranges, less the poses the machine reports it cannot go to (Machine::unreachable).
run_standard_suite
static_hold
At the equilibrium state, under the holding torques, nothing moves for one second.
step_convergence
Halving the time step changes the result by less than 1 %.
stop_run
weight_is_at_the_first_moment
Where a machine tells its frame_momentum, its weight sits at the first moment: at the middle of the axes, every axis moving at a tenth of its top speed, the potential energy (energy.potential) changes along the state’s rate as -g . d/dt sum m r, by central differences over +-1 us, within 1e-6 of it (plus 1e-9 W). V + g . c is then the same along any motion, as it is for any body whose weight is m g at its centre of mass.
weight_is_at_the_first_moment_at
weight_is_at_the_first_moment at pose: off the middle a part whose shape changes with the pose (a beam’s mode under a carriage) moves its first moment with the pose too.