Skip to main content

sim_components/
accuracy.rs

1//! Static positioning accuracy and repeatability (`study`), judged along ISO 230-2 (a numerically controlled axis) and
2//! ISO 9283 (the pose of a robot's tool): the machine runs to a line of targets along each tool axis, approaching each
3//! target several times from below and from above, and the tool's real pose at rest is compared with the target.
4//!
5//! What puts the tool off its target is what the simulation already has: backlash, gearbox twist, belt stretch under
6//! the load it holds, guide and frame compliance, the encoder's step, sensor noise, and friction where the axis comes to
7//! rest. Two more effects move the axis's real position against what its motor encoder reads (`AxisErrors`):
8//! effects.thermal_growth, the screw or belt grown with its temperature, and effects.lead_error, a lead (pitch) error
9//! table. Both are a map from the position the controller holds to the real one, applied to the tool pose the
10//! simulation reports; they are not fed back into the dynamics (a change of lead of a few 1e-5 changes the inertia the
11//! motor sees by as little), and the run's axis signals do not carry them.
12
13use crate::analysis::Verdict;
14use crate::control::Command;
15use crate::sim::Sim;
16use sim_core::{Config, ConfigError, MachineEntry};
17
18/// Linear expansion of steel (a ball screw), per K: 11.5e-6 for a hardened bearing steel (EN 1.3505 / 100Cr6, DIN EN
19/// ISO 683-17; ball screw makers give 11 to 12e-6).
20pub const STEEL_EXPANSION_PER_K: f64 = 11.5e-6;
21/// Linear expansion of a toothed belt along its length, per K: [estimate] that of its steel tension cords, which carry
22/// its tension and fix its pitch (the polyurethane body is some thousand times less stiff); no belt maker's datasheet
23/// found gives one (16 November 2026). A glass fibre cord would be about 5e-6, an aramid one about -2e-6.
24pub const BELT_EXPANSION_PER_K: f64 = 11.5e-6;
25
26/// How the test is run.
27#[derive(Debug, Clone, Copy, PartialEq)]
28pub struct Settings {
29    /// Targets per axis, evenly over the middle 80 % of its stroke.
30    pub points: usize,
31    /// Approaches of each target from each side (ISO 230-2 asks for 5).
32    pub repeats: usize,
33    /// How long the axis rests at a target before it is measured, s; the pose is averaged over the last tenth.
34    pub dwell_s: f64,
35}
36
37impl Default for Settings {
38    fn default() -> Self {
39        Self { points: 5, repeats: 5, dwell_s: 0.3 }
40    }
41}
42
43/// The map from the position an axis's motor encoder holds to its real one, for one tool axis (see the module).
44#[derive(Debug, Clone, PartialEq)]
45pub struct AxisErrors {
46    pub axis: usize,
47    /// Linear expansion of the screw or belt, per K; 0 with effects.thermal_growth off.
48    pub expansion: f64,
49    /// Where the axis does not grow from (a screw's fixed bearing, a belt axis's home), in the axis's unit.
50    pub fixed_end: f64,
51    /// A temperature rise of the screw or belt the config gives, K, and the heated part (`Sim::heated`, by index) whose
52    /// rise it takes on top.
53    pub rise: f64,
54    pub part: Option<usize>,
55    /// The lead error table, (position, error) by rising position, in the axis's unit; empty with effects.lead_error
56    /// off.
57    pub table: Vec<(f64, f64)>,
58}
59
60impl AxisErrors {
61    /// The real position less the one the encoder holds, at that position `x` with the heated part at `part_rise` (K).
62    /// The error of the table is linear between its rows and that of the nearest row beyond them.
63    pub fn offset(&self, x: f64, part_rise: f64) -> f64 {
64        let growth = self.expansion * (self.rise + part_rise) * (x - self.fixed_end);
65        let lead = match self.table.iter().position(|r| r.0 > x) {
66            None => self.table.last().map_or(0.0, |r| r.1),
67            Some(0) => self.table[0].1,
68            Some(i) => {
69                let ((x0, e0), (x1, e1)) = (self.table[i - 1], self.table[i]);
70                e0 + (e1 - e0) * (x - x0) / (x1 - x0)
71            }
72        };
73        growth + lead
74    }
75}
76
77/// The optional switch `effects.<name>`: off where the config does not have it.
78fn switch(cfg: &Config, name: &str) -> Result<bool, ConfigError> {
79    let path = format!("effects.{name}");
80    if cfg.get(&path).is_ok() { cfg.bool(&path) } else { Ok(false) }
81}
82
83/// The axes of `[[accuracy.axes]]` that grow or have a lead error, for `sim` (its axes and heated parts), with the
84/// effects that are off left out: none at all with both off, or with effects.load_encoder, whose scale reads the
85/// carriage itself (its own expansion is not modelled). Each entry has `axis` (a tool axis's id) and may have
86/// `drive` ("screw", the default, or "belt": which of `accuracy.screw_expansion_per_k` and
87/// `accuracy.belt_expansion_per_k` it takes, else `STEEL_EXPANSION_PER_K` and `BELT_EXPANSION_PER_K`), `fixed_end`
88/// (0), `rise_k` (0), `heated_part` (the id of one of the machine's `thermal_parts`) and `lead_error` (rows
89/// [position, error], positions rising).
90pub fn axis_errors(cfg: &Config, sim: &Sim) -> Result<Vec<AxisErrors>, ConfigError> {
91    let (growth, lead) = (switch(cfg, "thermal_growth")?, switch(cfg, "lead_error")?);
92    if !(growth || lead) || switch(cfg, "load_encoder")? {
93        return Ok(Vec::new());
94    }
95    let Ok(entries) = cfg.array("accuracy.axes") else { return Ok(Vec::new()) };
96    let coefficient = |key: &str, default: f64| if cfg.get(key).is_ok() { cfg.f64(key) } else { Ok(default) };
97    let (screw, belt) = (
98        coefficient("accuracy.screw_expansion_per_k", STEEL_EXPANSION_PER_K)?,
99        coefficient("accuracy.belt_expansion_per_k", BELT_EXPANSION_PER_K)?,
100    );
101    let bad = |what: &str| ConfigError::Invalid(format!("accuracy.axes.{what}"));
102    let number = |v: &toml::Value| v.as_float().or_else(|| v.as_integer().map(|i| i as f64)).filter(|x| x.is_finite());
103    let axes = sim.machine.axes();
104    let mut out = Vec::new();
105    for entry in entries {
106        let table = entry.as_table().ok_or_else(|| bad("axis"))?;
107        if let Some(key) = table
108            .keys()
109            .find(|k| !["axis", "drive", "fixed_end", "rise_k", "heated_part", "lead_error"].contains(&k.as_str()))
110        {
111            return Err(ConfigError::Unknown(format!("accuracy.axes.{key}")));
112        }
113        let id = table.get("axis").and_then(toml::Value::as_str).ok_or_else(|| bad("axis"))?;
114        let axis = axes.iter().position(|a| a.id == id).ok_or_else(|| bad("axis"))?;
115        let get = |key: &str| table.get(key).map_or(Some(0.0), number).ok_or_else(|| bad(key));
116        let expansion = match table.get("drive").map(|d| d.as_str()) {
117            None | Some(Some("screw")) => screw,
118            Some(Some("belt")) => belt,
119            _ => return Err(bad("drive")),
120        };
121        let part = match table.get("heated_part") {
122            None => None,
123            Some(p) => {
124                let id = p.as_str().ok_or_else(|| bad("heated_part"))?;
125                Some(sim.heated.iter().position(|h| h.part.id == id).ok_or_else(|| bad("heated_part"))?)
126            }
127        };
128        let mut rows = Vec::new();
129        for row in table.get("lead_error").map_or(Ok(&Vec::new()), |v| v.as_array().ok_or_else(|| bad("lead_error")))? {
130            match row.as_array().map(|r| r.iter().map(number).collect::<Option<Vec<f64>>>()) {
131                Some(Some(r)) if r.len() == 2 && rows.last().is_none_or(|l: &(f64, f64)| r[0] > l.0) => {
132                    rows.push((r[0], r[1]))
133                }
134                _ => return Err(bad("lead_error")),
135            }
136        }
137        out.push(AxisErrors {
138            axis,
139            expansion: if growth { expansion } else { 0.0 },
140            fixed_end: get("fixed_end")?,
141            rise: get("rise_k")?,
142            part: if growth { part } else { None },
143            table: if lead { rows } else { Vec::new() },
144        });
145    }
146    Ok(out)
147}
148
149/// ISO 230-2 on one tool axis, in its unit: the targets and, per target, the mean deviation (real less target) and its
150/// standard deviation over the approaches from below (↑) and from above (↓).
151#[derive(Debug, Clone, PartialEq)]
152pub struct AxisResult {
153    pub axis: usize,
154    pub targets: Vec<f64>,
155    pub mean_up: Vec<f64>,
156    pub mean_down: Vec<f64>,
157    pub std_up: Vec<f64>,
158    pub std_down: Vec<f64>,
159    /// B, the largest reversal error |x̄↑ - x̄↓| (backlash and what friction leaves where the axis settles).
160    pub reversal: f64,
161    /// R, the bidirectional repeatability: the largest of max(2s↑ + 2s↓ + |B_j|, 4s↑, 4s↓).
162    pub repeatability: f64,
163    /// E, the bidirectional systematic positional deviation: the range of all x̄↑ and x̄↓.
164    pub systematic: f64,
165    /// M, the range of the mean bidirectional positional deviation (x̄↑ + x̄↓) / 2.
166    pub mean_range: f64,
167    /// A, the bidirectional accuracy: max(x̄ + 2s) - min(x̄ - 2s) over both directions.
168    pub accuracy: f64,
169    /// The largest |x̄↑| or |x̄↓|.
170    pub mean_deviation: f64,
171}
172
173/// The ISO 230-2 figures from the deviations `up[j][i]`, `down[j][i]` (target j, approach i).
174pub fn iso_230_2(axis: usize, targets: Vec<f64>, up: &[Vec<f64>], down: &[Vec<f64>]) -> AxisResult {
175    let mean = |v: &Vec<f64>| v.iter().sum::<f64>() / v.len() as f64;
176    let std = |v: &Vec<f64>| {
177        let m = mean(v);
178        if v.len() < 2 { 0.0 } else { (v.iter().map(|x| (x - m).powi(2)).sum::<f64>() / (v.len() - 1) as f64).sqrt() }
179    };
180    let (mean_up, mean_down): (Vec<f64>, Vec<f64>) = (up.iter().map(mean).collect(), down.iter().map(mean).collect());
181    let (std_up, std_down): (Vec<f64>, Vec<f64>) = (up.iter().map(std).collect(), down.iter().map(std).collect());
182    let max = |it: &mut dyn Iterator<Item = f64>| it.fold(f64::NEG_INFINITY, f64::max);
183    let min = |it: &mut dyn Iterator<Item = f64>| it.fold(f64::INFINITY, f64::min);
184    let n = targets.len();
185    let both = || mean_up.iter().chain(&mean_down).copied();
186    let reversal = max(&mut (0..n).map(|j| (mean_up[j] - mean_down[j]).abs()));
187    let repeatability = max(&mut (0..n).map(|j| {
188        let r = 2.0 * std_up[j] + 2.0 * std_down[j] + (mean_up[j] - mean_down[j]).abs();
189        r.max(4.0 * std_up[j]).max(4.0 * std_down[j])
190    }));
191    let bidirectional: Vec<f64> = (0..n).map(|j| 0.5 * (mean_up[j] + mean_down[j])).collect();
192    let high = (0..n).flat_map(|j| [mean_up[j] + 2.0 * std_up[j], mean_down[j] + 2.0 * std_down[j]]);
193    let low = (0..n).flat_map(|j| [mean_up[j] - 2.0 * std_up[j], mean_down[j] - 2.0 * std_down[j]]);
194    AxisResult {
195        axis,
196        reversal,
197        repeatability,
198        systematic: max(&mut both()) - min(&mut both()),
199        mean_range: max(&mut bidirectional.iter().copied()) - min(&mut bidirectional.iter().copied()),
200        accuracy: max(&mut high.into_iter()) - min(&mut low.into_iter()),
201        mean_deviation: max(&mut both().map(f64::abs)),
202        targets,
203        mean_up,
204        mean_down,
205        std_up,
206        std_down,
207    }
208}
209
210/// ISO 9283 at the tool, over the axes in metres (all of them on a machine without one), from the attained poses of
211/// each target and direction: the largest pose accuracy AP (the distance of their barycentre from the target), the
212/// largest pose repeatability RP (l̄ + 3 S_l, l the distance from the barycentre) and the largest distance between the
213/// barycentres of the two directions (vAP, the multi-directional pose accuracy variation).
214#[derive(Debug, Clone, Copy, PartialEq, Default)]
215pub struct ToolResult {
216    pub accuracy: f64,
217    pub repeatability: f64,
218    pub direction_variation: f64,
219}
220
221/// One target's attained deviation vectors (over the axes of `ToolResult`) from below and from above.
222fn iso_9283(up: &[Vec<f64>], down: &[Vec<f64>], into: &mut ToolResult) {
223    let barycentre = |v: &[Vec<f64>]| -> Vec<f64> {
224        (0..v[0].len()).map(|k| v.iter().map(|p| p[k]).sum::<f64>() / v.len() as f64).collect()
225    };
226    let distance = |a: &[f64], b: &[f64]| a.iter().zip(b).map(|(x, y)| (x - y).powi(2)).sum::<f64>().sqrt();
227    let (bu, bd) = (barycentre(up), barycentre(down));
228    for (poses, b) in [(up, &bu), (down, &bd)] {
229        into.accuracy = into.accuracy.max(b.iter().map(|x| x * x).sum::<f64>().sqrt());
230        let l: Vec<f64> = poses.iter().map(|p| distance(p, b)).collect();
231        let mean = l.iter().sum::<f64>() / l.len() as f64;
232        let s = if l.len() < 2 {
233            0.0
234        } else {
235            (l.iter().map(|x| (x - mean).powi(2)).sum::<f64>() / (l.len() - 1) as f64).sqrt()
236        };
237        into.repeatability = into.repeatability.max(mean + 3.0 * s);
238    }
239    into.direction_variation = into.direction_variation.max(distance(&bu, &bd));
240}
241
242/// What `study` found, and the verdicts: `positioning-accuracy`, the largest A of the axes in metres against
243/// `ratings.max_positioning_error_m`, and `positioning-repeatability`, their largest R against `ratings.max_repeatability_m`,
244/// each where the config has the rating. On a machine without an axis in m the axes are in rad and the ratings are the
245/// `_rad` ones (`ratings.max_positioning_error_rad`, `ratings.max_repeatability_rad`); a rad value is never held against a
246/// metre limit.
247#[derive(Debug, Clone, PartialEq)]
248pub struct Study {
249    pub axes: Vec<AxisResult>,
250    pub tool: ToolResult,
251    pub verdicts: Vec<Verdict>,
252}
253
254/// The longest a move may take before the test gives up on it, s.
255const LONGEST_MOVE_S: f64 = 20.0;
256
257/// Moves the tool to `pose`, lets it rest `dwell_s` and returns its real pose, averaged over the last tenth of the
258/// rest, with the encoder-to-real map of `errors` applied.
259fn attain(sim: &mut Sim, pose: &[f64], dwell_s: f64, errors: &[AxisErrors]) -> Result<Vec<f64>, ConfigError> {
260    crate::analysis::check_cancelled();
261    sim.command(Command::MoveTo(pose.to_vec())).map_err(|e| ConfigError::Invalid(e.key.into()))?;
262    let start = sim.time();
263    while sim.control.busy() && sim.time() - start < LONGEST_MOVE_S {
264        sim.step();
265    }
266    let steps = (dwell_s / sim.dt).round().max(1.0) as u64;
267    let averaged = (steps / 10).max(1);
268    let n = pose.len();
269    let (mut sum, mut at, mut rate) = (vec![0.0; n], vec![0.0; n], vec![0.0; n]);
270    for i in 0..steps {
271        sim.step();
272        if i >= steps - averaged {
273            sim.machine.tool_state(&sim.state, &mut at, &mut rate);
274            for e in errors {
275                let rise = e.part.map_or(0.0, |p| sim.heated[p].rise);
276                at[e.axis] += e.offset(at[e.axis], rise);
277            }
278            sum.iter_mut().zip(&at).for_each(|(s, x)| *s += x);
279        }
280    }
281    Ok(sum.into_iter().map(|s| s / averaged as f64).collect())
282}
283
284/// The test: for each tool axis with a stroke, `settings.points` targets evenly over the middle 80 % of it (those the
285/// machine can reach, the other axes at the start pose), run `settings.repeats` times forth and back as ISO 230-2's
286/// linear cycle (each target approached from below on the way up, from above on the way down, with an overrun of 5 %
287/// of the stroke beyond the end targets), in one simulation from the start pose, so that the parts warm as they run.
288pub fn study(entry: &MachineEntry, cfg: &Config, settings: Settings) -> Result<Study, ConfigError> {
289    if settings.points < 2 || settings.repeats < 1 || !(settings.dwell_s > 0.0 && settings.dwell_s.is_finite()) {
290        return Err(ConfigError::Invalid("accuracy settings".into()));
291    }
292    let mut sim = Sim::new(entry, cfg)?;
293    let errors = axis_errors(cfg, &sim)?;
294    let axes = sim.machine.axes().to_vec();
295    let start = cfg.f64s("start.pose")?;
296    let metres: Vec<bool> = if axes.iter().any(|a| a.unit == "m") {
297        axes.iter().map(|a| a.unit == "m").collect()
298    } else {
299        vec![true; axes.len()]
300    };
301    let on_metres = |dev: &[f64]| dev.iter().zip(&metres).filter(|(_, m)| **m).map(|(d, _)| *d).collect::<Vec<_>>();
302    let (mut results, mut tool) = (Vec::new(), ToolResult::default());
303    for (k, a) in axes.iter().enumerate() {
304        let stroke = a.max - a.min;
305        if stroke <= 0.0 {
306            continue;
307        }
308        let at = |x: f64| {
309            let mut p = start.clone();
310            p[k] = x;
311            p
312        };
313        let overrun = 0.05 * stroke;
314        let reach = |x: f64| sim.machine.unreachable(&at(x), 0.0).is_none();
315        let targets: Vec<f64> = (0..settings.points)
316            .map(|j| a.min + stroke * (0.1 + 0.8 * j as f64 / (settings.points - 1) as f64))
317            .filter(|&x| reach(x) && reach(x - overrun) && reach(x + overrun))
318            .collect();
319        if targets.len() < 2 {
320            continue;
321        }
322        let m = targets.len();
323        let (mut up, mut down) = (vec![Vec::new(); m], vec![Vec::new(); m]);
324        let (mut up_poses, mut down_poses) = (vec![Vec::new(); m], vec![Vec::new(); m]);
325        for _ in 0..settings.repeats {
326            attain(&mut sim, &at(targets[0] - overrun), settings.dwell_s, &errors)?;
327            for j in 0..m {
328                let p = at(targets[j]);
329                let got = attain(&mut sim, &p, settings.dwell_s, &errors)?;
330                up[j].push(got[k] - targets[j]);
331                up_poses[j].push(on_metres(&got.iter().zip(&p).map(|(g, t)| g - t).collect::<Vec<_>>()));
332            }
333            attain(&mut sim, &at(targets[m - 1] + overrun), settings.dwell_s, &errors)?;
334            for j in (0..m).rev() {
335                let p = at(targets[j]);
336                let got = attain(&mut sim, &p, settings.dwell_s, &errors)?;
337                down[j].push(got[k] - targets[j]);
338                down_poses[j].push(on_metres(&got.iter().zip(&p).map(|(g, t)| g - t).collect::<Vec<_>>()));
339            }
340        }
341        for j in 0..m {
342            iso_9283(&up_poses[j], &down_poses[j], &mut tool);
343        }
344        results.push(iso_230_2(k, targets, &up, &down));
345        // Back to the start pose, so that the next axis's line runs through it as the config sets it up.
346        attain(&mut sim, &start, settings.dwell_s, &errors)?;
347    }
348    let judged: Vec<&AxisResult> = results.iter().filter(|r| metres[r.axis]).collect();
349    let mut verdicts = Vec::new();
350    let rad = !axes.iter().any(|a| a.unit == "m");
351    for (check, key, value) in [
352        (
353            "positioning-accuracy",
354            if rad { "ratings.max_positioning_error_rad" } else { "ratings.max_positioning_error_m" },
355            judged.iter().map(|r| r.accuracy).fold(0.0, f64::max),
356        ),
357        (
358            "positioning-repeatability",
359            if rad { "ratings.max_repeatability_rad" } else { "ratings.max_repeatability_m" },
360            judged.iter().map(|r| r.repeatability).fold(0.0, f64::max),
361        ),
362    ] {
363        // 0 or absent: not judged.
364        if cfg.get(key).is_ok() && cfg.f64(key)? > 0.0 {
365            let limit = cfg.f64(key)?;
366            verdicts.push(Verdict { check, motor: None, value, limit, ok: value <= limit });
367        }
368    }
369    Ok(Study { axes: results, tool, verdicts })
370}
371
372#[cfg(test)]
373mod tests {
374    use super::*;
375
376    fn errors() -> AxisErrors {
377        AxisErrors { axis: 0, expansion: 0.0, fixed_end: 0.0, rise: 0.0, part: None, table: Vec::new() }
378    }
379
380    /// A ball screw at 5 K above its surroundings, 0.4 m from its fixed bearing: 11.5e-6 / K * 5 K * 0.4 m = 23 um,
381    /// half from the config's own rise (2 K) and the rest from the heated part (3 K).
382    #[test]
383    fn a_warm_screw_grows_from_its_fixed_end() {
384        let e = AxisErrors { expansion: STEEL_EXPANSION_PER_K, fixed_end: 0.05, rise: 2.0, ..errors() };
385        assert!((e.offset(0.45, 3.0) - 23.0e-6).abs() < 1e-12);
386        // At the fixed bearing nothing moves; on its other side the growth turns.
387        assert_eq!(e.offset(0.05, 3.0), 0.0);
388        assert!((e.offset(0.0, 3.0) + 11.5e-6 * 5.0 * 0.05).abs() < 1e-15);
389    }
390
391    /// A pitch table of three rows: at 0.15 m, halfway from (0.1 m, +4 um) to (0.2 m, -2 um), +1 um; beyond the table
392    /// the nearest row's error.
393    #[test]
394    fn the_lead_error_is_interpolated_between_its_rows() {
395        let e = AxisErrors { table: vec![(0.1, 4e-6), (0.2, -2e-6), (0.4, 6e-6)], ..errors() };
396        assert!((e.offset(0.15, 0.0) - 1e-6).abs() < 1e-15);
397        assert!((e.offset(0.3, 0.0) - 2e-6).abs() < 1e-15);
398        assert_eq!(e.offset(0.0, 0.0), 4e-6);
399        assert_eq!(e.offset(0.5, 0.0), 6e-6);
400    }
401
402    /// Two targets, two approaches each way, by hand: target 0 up {+3, +5} um, down {-3, -5} um: x̄↑ = 4, x̄↓ = -4,
403    /// s = sqrt(2) um each; B = 8 um; R = 2 s + 2 s + B = 4 sqrt(2) + 8 = 13.657 um. Target 1 up {+1, +1}, down {-1,
404    /// -1}: s = 0, B = 2. E = 4 - (-4) = 8 um; M = 0; A = (4 + 2 sqrt(2)) - (-4 - 2 sqrt(2)) = 8 + 4 sqrt(2) um.
405    #[test]
406    fn iso_230_2_figures_match_a_hand_calculation() {
407        let r = iso_230_2(
408            0,
409            vec![0.1, 0.2],
410            &[vec![3e-6, 5e-6], vec![1e-6, 1e-6]],
411            &[vec![-3e-6, -5e-6], vec![-1e-6, -1e-6]],
412        );
413        let s = 2f64.sqrt() * 1e-6;
414        assert!((r.reversal - 8e-6).abs() < 1e-15);
415        assert!((r.repeatability - (4.0 * s + 8e-6)).abs() < 1e-15);
416        assert!((r.systematic - 8e-6).abs() < 1e-15);
417        assert!(r.mean_range.abs() < 1e-15);
418        assert!((r.accuracy - (8e-6 + 4.0 * s)).abs() < 1e-15);
419        assert!((r.mean_deviation - 4e-6).abs() < 1e-15);
420    }
421
422    /// ISO 9283 by hand: from below the poses (1, 0) and (3, 0) um about the target, barycentre (2, 0): AP = 2 um, l =
423    /// 1, 1, RP = 1 um; from above (0, -1) twice: AP = 1, RP = 0; vAP = |(2, 0) - (0, -1)| = sqrt(5) um.
424    #[test]
425    fn iso_9283_figures_match_a_hand_calculation() {
426        let mut t = ToolResult::default();
427        iso_9283(&[vec![1e-6, 0.0], vec![3e-6, 0.0]], &[vec![0.0, -1e-6], vec![0.0, -1e-6]], &mut t);
428        assert!((t.accuracy - 2e-6).abs() < 1e-15);
429        assert!((t.repeatability - 1e-6).abs() < 1e-15);
430        assert!((t.direction_variation - 5f64.sqrt() * 1e-6).abs() < 1e-15);
431    }
432}