-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathchecks.ts
More file actions
734 lines (714 loc) · 24.3 KB
/
Copy pathchecks.ts
File metadata and controls
734 lines (714 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
/**
* Invariant checks: the "does it look like the movement it claims to be"
* layer. Generic checks apply to every document; movement checks encode the
* biomechanical signature of specific canonical movements (verified against
* the playground render).
*/
import type { PhasePose, ProbeResult } from "./probe.js";
import { REACH_TOLERANCE } from "posecode-render";
import {
balanceOverflow,
distanceBetween,
feetCenterSkateDistance,
fistFloorAngleDeg,
footIsSupported,
footSkateDistance,
footWorldSkateDistance,
forwardCoordinate,
headPropClearance,
heightOf,
kneeFlexionDeg,
lowestPoint,
palmFloorAngleDeg,
palmForwardAngleDeg,
palmInwardAngleDeg,
palmUpAngleDeg,
phaseMaxLandmarkSpeed,
propPenetrationDepth,
segmentTiltDeg,
soleUpAngleDeg,
spineCurlDeg,
torsoForwardPitchDeg,
torsoPitchDeg,
} from "./metrics.js";
export interface CheckOutcome {
id: string;
pass: boolean;
/** Human-readable measurement, e.g. "torso pitch 68.2° (want ≥ 55)". */
detail: string;
}
export interface MovementChecks {
/** Matches ProbeResult docs by fixture file name (without extension). */
movement: string;
checks: ((result: ProbeResult) => CheckOutcome)[];
}
/** Maximum positional error for a declared reach/pin/grip contact. */
export const CONTACT_ERROR_MAX = REACH_TOLERANCE;
/**
* Foot-to-floor contact tolerance while the clip travels. A stance foot's
* contact point legitimately shifts a few centimetres as the body passes over
* it and rolls toward push-off (the ankle-only leg chain cannot pivot onto the
* toe to hold the ball of the foot exactly). Static contacts keep the strict
* CONTACT_ERROR_MAX; only planted/landing feet in a locomotion clip relax.
*/
export const LOCOMOTION_FOOT_CONTACT_MAX = 0.06;
/**
* Compare contact residuals at the same millimetre precision shown in reports.
* This avoids displaying an apparent equality such as 0.030m ≤ 0.030m while
* failing because of a sub-millimetre solver difference.
*/
export function withinDisplayedContactTolerance(
error: number,
tolerance: number,
): boolean {
return Math.round(error * 1000) <= Math.round(tolerance * 1000);
}
/** Find a phase by name; throws a failing outcome path if missing. */
function phase(result: ProbeResult, name: string): PhasePose | null {
return result.phases.find((p) => p.name === name) ?? null;
}
/** Expanded identities of every body part explicitly supported by the floor. */
function floorSupportEffectors(pose: PhasePose): Set<string> {
const supports = new Set<string>();
const add = (effector: string): void => {
const groups: Readonly<Record<string, readonly string[]>> = {
feet: ["foot_left", "foot_right"],
hands: ["hand_left", "hand_right"],
fists: ["fist_left", "fist_right"],
knees: ["knee_left", "knee_right"],
forearms: ["elbow_left", "elbow_right"],
};
for (const item of groups[effector] ?? [effector]) supports.add(item);
};
pose.groundLock.forEach(add);
pose.reaches.filter((reach) => reach.target === "floor").forEach((reach) => add(reach.effector));
pose.pins.filter((pin) => pin.anchor === "floor").forEach((pin) => add(pin.effector));
return supports;
}
function footSupportKind(
pose: PhasePose,
side: "left" | "right",
): "ground-lock" | "pin" | null {
if (pose.pins.some((pin) =>
(pin.effector === "feet" || pin.effector === `foot_${side}`) && pin.anchor === "floor")) {
return "pin";
}
if (pose.groundLock.includes("feet") || pose.groundLock.includes(`foot_${side}`)) {
return "ground-lock";
}
return null;
}
/** Build a check on one named phase with a measured value and a predicate. */
export function phaseCheck(
id: string,
phaseName: string,
measure: (pose: PhasePose) => number,
test: (value: number) => boolean,
want: string,
): (result: ProbeResult) => CheckOutcome {
return (result) => {
const p = phase(result, phaseName);
if (!p) return { id, pass: false, detail: `phase "${phaseName}" not found` };
const value = measure(p);
return {
id,
pass: test(value),
detail: `${value.toFixed(1)} (want ${want})`,
};
};
}
/** Generic invariants every well-formed movement must satisfy. */
export function genericChecks(result: ProbeResult): CheckOutcome[] {
const out: CheckOutcome[] = [
{
id: "parses-clean",
pass: result.ok && result.errors.length === 0,
detail: result.errors.map((e) => e.message).join("; ") || "no errors",
},
{
id: "no-clamp-warnings",
pass: result.warnings.length === 0,
detail:
result.warnings
.map((w) => `${w.joint} ${w.action} ${w.requested}→${w.clamped}`)
.join("; ") || "no warnings",
},
{
id: "has-phases",
pass: result.phases.length > 0,
detail: result.phases.length > 0
? `${result.phases.length} phase(s)`
: "no movement phases to evaluate",
},
];
// A clip that authors root travel is locomotion: its planted/landing feet
// push off and roll, so foot-to-floor contacts use the looser locomotion
// tolerance instead of the strict static-contact bar.
const clipTravels = result.phases.some(
(p) => Math.hypot(p.rootOffset[0], p.rootOffset[2]) > 0.02,
);
for (const p of result.phases) {
// The one universal contact invariant: nothing sinks through the floor.
// (A stricter "declared effector is planted" check isn't portable across
// the library: the renderer grounds the visible MESH, so a planted foot
// leaves its ankle BONE ~0.04m up and a supporting hand leaves the wrist
// bone higher still; stepping/travel movements lift feet by design.)
out.push({
id: `above-floor:${p.name}`,
pass: lowestPoint(p) > -0.05,
detail: `lowest bone ${lowestPoint(p).toFixed(3)}m (want > -0.05)`,
});
// A ground-locked phase declares its effectors planted, so the visible mesh
// must actually rest on the floor — not hover above it. Guards the
// levitating-squat/deadlift regression where levelPlantedFeet lifted the
// sole after ground-lock and an up-only clamp left the whole figure floating.
if (p.floorBound) {
out.push({
id: `grounded-not-floating:${p.name}`,
pass: p.meshMinY > -0.02 && p.meshMinY < 0.02,
detail: `mesh floor offset ${p.meshMinY.toFixed(3)}m (want -0.020 to +0.020)`,
});
}
// A contact declaration is an executable promise, not metadata. Every
// reach/pin/grip must either resolve within tolerance or fail explicitly;
// unsupported targets/solver paths must never disappear into a green score.
p.contactResiduals.forEach((contact, index) => {
const suffix = `${p.name}:${contact.kind}:${contact.effector}:${contact.target}:${index}`;
if (contact.status === "unsupported" || contact.error === null) {
out.push({
id: `contact-supported:${suffix}`,
pass: false,
detail: contact.reason ?? "contact could not be evaluated",
});
return;
}
const footFloorContact =
contact.target === "floor" && contact.effectorBone.startsWith("ankle_");
const tolerance =
clipTravels && footFloorContact ? LOCOMOTION_FOOT_CONTACT_MAX : CONTACT_ERROR_MAX;
out.push({
id: `contact-position:${suffix}`,
pass: withinDisplayedContactTolerance(contact.error, tolerance),
detail: `${contact.error.toFixed(3)}m residual (want ≤ ${tolerance.toFixed(3)}m)`,
});
});
const floorHands = new Set<string>();
const floorFists = new Set<string>();
const collectFloorHand = (effector: string): void => {
if (effector === "hands" || effector === "hand_left") floorHands.add("left");
if (effector === "hands" || effector === "hand_right") floorHands.add("right");
if (effector === "fists" || effector === "fist_left") floorFists.add("left");
if (effector === "fists" || effector === "fist_right") floorFists.add("right");
};
p.reaches.filter((reach) => reach.target === "floor").forEach((reach) => collectFloorHand(reach.effector));
p.pins.filter((pin) => pin.anchor === "floor").forEach((pin) => collectFloorHand(pin.effector));
p.groundLock.forEach(collectFloorHand);
for (const side of floorHands) {
const angle = palmFloorAngleDeg(p, side as "left" | "right");
out.push({
id: `palm-normal:${p.name}:${side}`,
pass: angle < 55,
detail: `${angle.toFixed(1)}° from palm-down (want < 55°)`,
});
}
for (const side of floorFists) {
const angle = fistFloorAngleDeg(p, side as "left" | "right");
out.push({
id: `fist-normal:${p.name}:${side}`,
pass: angle < 55,
detail: `${angle.toFixed(1)}° from knuckles-down (want < 55°)`,
});
}
const overflow = balanceOverflow(p);
out.push({
id: `balance:${p.name}`,
pass: overflow < 0.3,
detail: `COM ${overflow.toFixed(3)}m outside support base (want < 0.30m)`,
});
const clearance = headPropClearance(result, p);
if (Number.isFinite(clearance)) {
out.push({
id: `head-prop-clearance:${p.name}`,
pass: clearance > -0.01,
detail: `${clearance.toFixed(3)}m clearance (want > -0.01m)`,
});
}
// Props are solid: no body capsule may sit inside a prop's blocking face
// (the wall-sit-through-the-wall class of bug). Independent re-derivation
// of the face geometry, so it fails loudly if resolvePropContacts or a
// prop's collider declaration regresses.
const penetration = propPenetrationDepth(result, p);
if (Number.isFinite(penetration)) {
out.push({
id: `solid-props:${p.name}`,
pass: penetration < 0.03,
detail: `${penetration.toFixed(3)}m into a solid prop face (want < 0.030)`,
});
}
}
for (let i = 1; i < result.phases.length; i++) {
const previous = result.phases[i - 1]!;
const current = result.phases[i]!;
const bothSupported = (["left", "right"] as const).every((side) =>
footIsSupported(previous, side) && footIsSupported(current, side));
if (bothSupported) {
const skate = feetCenterSkateDistance(previous, current);
out.push({
id: `foot-skate:${current.name}:pair`,
pass: skate < 0.08,
detail: `${skate.toFixed(3)}m planted support-center drift (want < 0.08m)`,
});
}
for (const side of ["left", "right"] as const) {
// With both feet down, a deliberate stance-width change may move each
// foot symmetrically while the support center stays fixed (checked
// above). A single carried support, however, must not jump when the
// author switches between ground-lock and pin semantics.
if (bothSupported || !footIsSupported(previous, side) || !footIsSupported(current, side)) continue;
const previousKind = footSupportKind(previous, side);
const currentKind = footSupportKind(current, side);
// Releasing a world pin into a ground-locked landing deliberately lets
// the foot travel to its new planted position during this phase (step
// closes, marches, and dance phrases). Endpoint displacement is motion,
// not a boundary snap, so it is covered by speed/contact checks instead.
if (previousKind === "pin" && currentKind === "ground-lock") continue;
// Ground-lock anchors travel/yaw with the figure, so compare in its
// choreography-relative frame. A floor pin is a fixed WORLD anchor;
// subtracting authored travel fabricates skate (forward lunge reported
// 30 cm while the pinned foot was actually motionless). Handoffs to or
// from a pin are continuity checks in world space too.
const skate = previousKind === "ground-lock" && currentKind === "ground-lock"
? footSkateDistance(previous, current, side)
: footWorldSkateDistance(previous, current, side);
out.push({
id: `foot-skate:${current.name}:${side}`,
pass: skate < 0.03,
detail: `${skate.toFixed(3)}m single-support drift (want < 0.03m)`,
});
}
const speed = phaseMaxLandmarkSpeed(previous, current);
out.push({
id: `transition-speed:${current.name}`,
pass: speed < 4,
detail: `${speed.toFixed(2)}m/s fastest landmark (want < 4.0m/s)`,
});
if (current.easing === "linear" && speed > 0.15) {
out.push({
id: `transition-easing:${current.name}`,
pass: false,
detail: `moving linear phase enters at ${speed.toFixed(2)}m/s (use a flow/settle/drive mode)`,
});
}
}
return out;
}
/**
* Movement-specific signatures. Thresholds were set from the verified
* playground renders with margin; a regression that flattens a deadlift into
* a leg-swing (the pre-hinge bug) fails these loudly.
*/
export const MOVEMENT_CHECKS: MovementChecks[] = [
{
movement: "glute-bridge",
checks: [
phaseCheck(
"bridge-pelvis-raised",
"Bridge up",
(p) => heightOf(p, "pelvis"),
(v) => v > 0.5,
"pelvis > 0.50m",
),
phaseCheck(
"lower-pelvis-on-floor",
"Lower",
(p) => heightOf(p, "pelvis"),
(v) => v < 0.16,
"pelvis < 0.16m",
),
(result) => {
const up = phase(result, "Bridge up");
const down = phase(result, "Lower");
if (!up || !down) return { id: "bridge-has-real-height-change", pass: false, detail: "bridge phase missing" };
const delta = heightOf(up, "pelvis") - heightOf(down, "pelvis");
return {
id: "bridge-has-real-height-change",
pass: delta > 0.4,
detail: `${delta.toFixed(3)}m pelvis height change (want > 0.40m)`,
};
},
],
},
{
// A demi-plié keeps the turnout established at the hips while both feet
// remain planted. Checking each ankle independently catches the symmetric
// outward/inward skate that a center-only ground-lock metric cannot see.
movement: "demi-plie",
checks: [
(result) => {
if (result.phases.length < 2) {
return { id: "demi-plie-feet-stay-planted", pass: false, detail: "plié phases missing" };
}
let maxDrift = 0;
for (let i = 1; i < result.phases.length; i++) {
for (const side of ["left", "right"] as const) {
maxDrift = Math.max(
maxDrift,
footSkateDistance(result.phases[i - 1]!, result.phases[i]!, side),
);
}
}
return {
id: "demi-plie-feet-stay-planted",
pass: maxDrift < 0.015,
detail: `${maxDrift.toFixed(3)}m maximum ankle drift (want < 0.015m)`,
};
},
],
},
{
// Three-point landing: the front sole, rear knee, and opposite fist must
// form distinct supports while the torso stays above the floor. Contact
// residuals alone once allowed a folded body with a vertical planted foot.
movement: "superhero-landing",
checks: [
phaseCheck(
"torso-forward-not-collapsed",
"Hold the landing",
torsoForwardPitchDeg,
(v) => v >= 65 && v <= 100,
"65–100° character-forward pitch",
),
phaseCheck(
"planted-fist-palm-inward",
"Hold the landing",
(p) => palmInwardAngleDeg(p, "left"),
(v) => v < 30,
"< 30° from inward",
),
(result) => {
const p = phase(result, "Hold the landing");
if (!p) return { id: "exact-three-supports", pass: false, detail: "phase \"Hold the landing\" not found" };
const actual = floorSupportEffectors(p);
const expected = ["foot_right", "knee_left", "fist_left"];
const pass = actual.size === expected.length && expected.every((item) => actual.has(item));
return {
id: "exact-three-supports",
pass,
detail: `floor supports: ${[...actual].sort().join(", ") || "none"} (want ${expected.join(", ")})`,
};
},
(result) => {
const phases = [
phase(result, "Drop into the landing"),
phase(result, "Make three-point contact"),
phase(result, "Hold the landing"),
];
if (phases.some((item) => !item)) {
return { id: "three-supports-stay-planted", pass: false, detail: "landing phase missing" };
}
let maxDrift = 0;
for (let i = 1; i < phases.length; i++) {
const a = phases[i - 1]!;
const b = phases[i]!;
for (const boneId of ["ankle_right", "knee_left", "wrist_left"]) {
const pa = a.bones.get(boneId)!;
const pb = b.bones.get(boneId)!;
maxDrift = Math.max(maxDrift, Math.hypot(pb[0] - pa[0], pb[2] - pa[2]));
}
}
return {
id: "three-supports-stay-planted",
pass: maxDrift < 0.03,
detail: `${maxDrift.toFixed(3)}m maximum support drift (want < 0.03m)`,
};
},
phaseCheck(
"front-sole-planted",
"Hold the landing",
(p) => soleUpAngleDeg(p, "right"),
(v) => v < 25,
"< 25° from flat",
),
phaseCheck(
"rear-knee-down",
"Hold the landing",
(p) => heightOf(p, "knee_left"),
(v) => v < 0.12,
"left knee < 0.12m",
),
phaseCheck(
"fist-down",
"Hold the landing",
(p) => heightOf(p, "wrist_left"),
(v) => v < 0.13,
"left fist < 0.13m",
),
phaseCheck(
"head-clear-of-floor",
"Hold the landing",
(p) => heightOf(p, "head"),
(v) => v > 0.4,
"head > 0.40m",
),
phaseCheck(
"front-knee-up",
"Hold the landing",
(p) => heightOf(p, "knee_right"),
(v) => v > 0.3,
"right knee > 0.30m",
),
phaseCheck(
"supports-separated",
"Hold the landing",
(p) => Math.min(
distanceBetween(p, "ankle_right", "knee_left"),
distanceBetween(p, "ankle_right", "wrist_left"),
distanceBetween(p, "knee_left", "wrist_left"),
),
(v) => v > 0.2,
"every support pair > 0.20m apart",
),
phaseCheck(
"supports-front-to-back",
"Hold the landing",
(p) => Math.min(
forwardCoordinate(p, "ankle_right") - forwardCoordinate(p, "knee_left"),
forwardCoordinate(p, "wrist_left") - forwardCoordinate(p, "knee_left"),
),
(v) => v > 0.12,
"front foot and fist > 0.12m ahead of rear knee",
),
phaseCheck(
"free-arm-raised",
"Hold the landing",
(p) => heightOf(p, "wrist_right") - heightOf(p, "pelvis"),
(v) => v > 0.12,
"right wrist > 0.12m above pelvis",
),
],
},
{
// `pelvis: hinge`: torso tips forward over vertical legs (deadlift phases
// "Lower"/"Lift"). Regressing the hinge into a leg-swing or a backward
// bend fails these loudly.
movement: "deadlift",
checks: [
phaseCheck("torso-hinged", "Lower", torsoPitchDeg, (v) => v >= 50, "≥ 50° pitch"),
phaseCheck(
"soft-knees-only",
"Lower",
(p) => kneeFlexionDeg(p, "left"),
(v) => v < 45,
"< 45° knee flexion",
),
phaseCheck(
"legs-vertical",
"Lower",
(p) => segmentTiltDeg(p, "knee_left", "hip_left"),
(v) => v < 20,
"< 20° leg tilt",
),
phaseCheck("stands-back-up", "Lift", torsoPitchDeg, (v) => v < 12, "< 12° pitch"),
phaseCheck(
"feet-stay-planted",
"Lower",
(p) => Math.max(heightOf(p, "ankle_left"), heightOf(p, "ankle_right")),
(v) => v < 0.15,
"both ankles < 0.15m",
),
],
},
{
// Good morning: same hinge, hands stay behind the head. Phases "Hinge"/"Stand".
movement: "good-morning",
checks: [
phaseCheck("torso-hinged", "Hinge", torsoPitchDeg, (v) => v >= 55, "≥ 55° pitch"),
phaseCheck(
"legs-vertical",
"Hinge",
(p) => segmentTiltDeg(p, "knee_left", "hip_left"),
(v) => v < 20,
"< 20° leg tilt",
),
phaseCheck("stands-back-up", "Stand", torsoPitchDeg, (v) => v < 12, "< 12° pitch"),
],
},
{
movement: "squat",
checks: [
phaseCheck(
"pelvis-drops",
"Descend",
(p) => heightOf(p, "pelvis"),
(v) => v < 0.78,
"pelvis < 0.78m",
),
phaseCheck(
"knees-bend-deep",
"Descend",
(p) => kneeFlexionDeg(p, "left"),
(v) => v >= 75,
"≥ 75° knee flexion",
),
phaseCheck(
"stands-back-up",
"Drive up",
(p) => heightOf(p, "pelvis"),
(v) => v > 0.9,
"pelvis > 0.9m",
),
],
},
{
// forward-fold.posecode is a standing roll-down (spinal flexion). The
// pre-fix rig curled the spine BACKWARD (-Z); forward is +Z.
movement: "forward-fold",
checks: [
phaseCheck(
"curls-forward",
"Roll down",
(p) => p.bones.get("head")![2],
(v) => v > 0.05,
"head z > 0.05m (forward)",
),
phaseCheck("spine-curls", "Roll down", spineCurlDeg, (v) => v >= 25, "≥ 25° spine curl"),
],
},
{
movement: "biceps-curl",
checks: [
phaseCheck(
"forearm-raises",
"Curl",
(p) => heightOf(p, "wrist_left"),
(v) => v > 1.0,
"wrist > 1.0m",
),
phaseCheck(
"left-palm-up",
"Curl",
(p) => palmUpAngleDeg(p, "left"),
(v) => v < 55,
"< 55° from palm-up at peak flexion",
),
phaseCheck(
"right-palm-up",
"Curl",
(p) => palmUpAngleDeg(p, "right"),
(v) => v < 55,
"< 55° from palm-up at peak flexion",
),
phaseCheck(
"left-palm-forward-at-bottom",
"Lower",
(p) => palmForwardAngleDeg(p, "left"),
(v) => v < 25,
"< 25° from forward",
),
phaseCheck(
"right-palm-forward-at-bottom",
"Lower",
(p) => palmForwardAngleDeg(p, "right"),
(v) => v < 25,
"< 25° from forward",
),
],
},
{
movement: "jab-cross",
checks: [
phaseCheck(
"jab-palm-down",
"Jab",
(p) => palmFloorAngleDeg(p, "left"),
(v) => v < 35,
"< 35° from palm-down",
),
phaseCheck(
"cross-palm-down",
"Cross",
(p) => palmFloorAngleDeg(p, "right"),
(v) => v < 35,
"< 35° from palm-down",
),
phaseCheck(
"lead-guard-palm-in",
"Recoil cross",
(p) => palmInwardAngleDeg(p, "left"),
(v) => v < 20,
"< 20° from inward",
),
phaseCheck(
"rear-guard-palm-in",
"Recoil cross",
(p) => palmInwardAngleDeg(p, "right"),
(v) => v < 20,
"< 20° from inward",
),
phaseCheck(
"lead-guard-high",
"Recoil cross",
(p) => heightOf(p, "wrist_left"),
(v) => v > 1.45,
"> 1.45m",
),
phaseCheck(
"rear-guard-high",
"Recoil cross",
(p) => heightOf(p, "wrist_right"),
(v) => v > 1.45,
"> 1.45m",
),
],
},
{
movement: "lateral-raise",
checks: [
phaseCheck(
"arms-out-to-sides",
"Raise",
(p) => Math.abs(p.bones.get("wrist_left")![0]),
(v) => v > 0.5,
"wrist |x| > 0.5m",
),
],
},
{
movement: "plank-hold",
checks: [
phaseCheck(
"forearms-support-body",
"Hold",
(p) => Math.max(heightOf(p, "elbow_left"), heightOf(p, "elbow_right")),
(v) => v < 0.08,
"both elbows < 0.08m",
),
],
},
{
movement: "crunch",
checks: [
phaseCheck("pelvis-stays-down", "Curl up", (p) => heightOf(p, "pelvis"), (v) => v < 0.18, "pelvis < 0.18m"),
phaseCheck(
"feet-stay-down",
"Curl up",
(p) => Math.max(heightOf(p, "ankle_left"), heightOf(p, "ankle_right")),
(v) => v < 0.18,
"both ankles < 0.18m",
),
],
},
{
movement: "bicycle-crunch",
checks: [
phaseCheck("right-elbow-nears-left-knee", "Right to left", (p) => distanceBetween(p, "elbow_right", "knee_left"), (v) => v < 0.45, "distance < 0.45m"),
phaseCheck("left-elbow-nears-right-knee", "Left to right", (p) => distanceBetween(p, "elbow_left", "knee_right"), (v) => v < 0.45, "distance < 0.45m"),
],
},
{
movement: "superman",
checks: [
phaseCheck("pelvis-remains-supported", "Lift", (p) => heightOf(p, "pelvis"), (v) => v < 0.16, "pelvis < 0.16m"),
],
},
];