Chamber re-authored for the gravity feedforward: hold pose fit on SeatedBody (-0.68, -0.25), box half 0.155, idle drift and flinch control restated

The flinch control reads a flinch's rise above the gap at its own tick; seed 3 reads 1.92 cm against the 2.3 cm bound, reported not loosened.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-26 18:01:25 +01:00
commit bb75bc07c7
3 changed files with 18 additions and 15 deletions

View file

@ -73,8 +73,8 @@ in 15-bit colour with the 4x4 ordered dither. No `Light3D` exists: the shader li
`[shader_globals]`), which `Look` (constants), `Main` (`ps1_res`) and `Chamber` (the glow light, 0.9 m range) write.
Needs the .NET 8+ SDK, cmake and a C compiler (MinGW gcc on Windows), the sibling Lodur and Ymir (with joint origin lanes, ABI 8) checkouts
(`..\Lodur`, `..\Ymir`, or `LODUR_ROOT` and `YMIR_ROOT`), and Godot 4.7.2 mono. Nothing in this repository pins or checks the siblings' revisions
(BDS's graph references no CultLib project, so Ymir's own revision check never runs here); the client was last verified against Lodur d7a626b and
Ymir 5104b17 (its `extern/box3d` submodule initialised).
(BDS's graph references no CultLib project, so Ymir's own revision check never runs here); the client was last verified against Lodur 2359142 (the gravity subtree gate) and
Ymir 1d27114 (its `extern/box3d` submodule initialised).
```
dotnet build client/BadDay.Client.csproj # Lodur, Ymir (cmake) and BDS, plus ymir_box3d.dll, into client/.godot/mono/temp/bin/Debug

View file

@ -32,7 +32,7 @@ public static class BodyPainBox
/// <summary>The ragdoll's gains are tuned at 120 Hz.</summary>
public const double TickSeconds = 1.0 / 120.0;
/// <summary>Centre of the box and the right hand's hold point: where the right palm settles at the hold pose (a copy of Lodur's ConnectedPainBox.Box).</summary>
/// <summary>Centre of the box and the right hand's hold point: where the hold pose below is fit to put the strength-1 right palm (mean palm 3-4 s of a quiet seed-1 run on <see cref="SeatedBody"/>, 0.15 cm off). The client's orbit camera and render checks centre on it.</summary>
public static readonly (float X, float Y, float Z) HoldPoint = (-0.210f, 1.116f, 0.441f);
/// <summary>The hand is out when it has stayed outside the box this long after the break.</summary>
@ -69,8 +69,8 @@ public static class BodyPainBox
/// </summary>
public sealed class BodyPainBoxSession : IDisposable
{
/// <summary>The box's half extent, equal to Lodur's ConnectedPainBox (0.125 m: the palm holds in it until the break).</summary>
private const float BoxHalf = 0.125f;
/// <summary>The box's half extent: the smallest 0.005 m step that keeps the hand in the box from the end of the ramp to the break on <see cref="BodyPainBox.Run"/> (on-body parameters, seed 1) at the hold pose below. Readings by half extent, ticks out from 2 s: 0.140 6, 0.145 3, 0.150 0, 0.155 0; excursions after the ramp: 0.150 1, 0.155 0.</summary>
private const float BoxHalf = 0.155f;
/// <summary>After the deliberate withdrawal begins the run waits this long for the hand to come out.</summary>
private const double SettleSeconds = 1.0;
@ -106,13 +106,13 @@ public sealed class BodyPainBoxSession : IDisposable
_handR = plan.SenseIndex("Hand", Side.Right);
int shoulderR = plan.JointIndex("Shoulder", Side.Right), elbowR = plan.JointIndex("Elbow", Side.Right);
// Hold: the right arm raised and bent so the hand sits in the box. Withdraw: the arm pulled back and folded.
// Hold: the shoulder and elbow angles fit on this body so the settled strength-1 palm sits on HoldPoint: grid 0.04 then 0.01 over both (the refine reaches 0.08 either side, the fit is a ridge), seed 1, mean palm 3-4 s, box intensity 0, FlinchGain 0, StrainShake 0 give -0.68 and -0.25 at 0.15 cm (the 0.04 grid alone: -0.64, -0.32 at 0.43 cm). Under the gravity feedforward the controller no longer sags the arm onto the box, so the pose is the intent. Withdraw: the arm pulled back and folded.
var hold = new Quat[joints];
var withdraw = new Quat[joints];
Array.Fill(hold, Quat.Identity);
Array.Fill(withdraw, Quat.Identity);
hold[shoulderR] = Quat.FromAxisAngle(1f, 0f, 0f, -1.0f);
hold[elbowR] = Quat.FromAxisAngle(0f, 0f, 1f, -0.6f);
hold[shoulderR] = Quat.FromAxisAngle(1f, 0f, 0f, -0.68f);
hold[elbowR] = Quat.FromAxisAngle(0f, 0f, 1f, -0.25f);
withdraw[shoulderR] = Quat.FromAxisAngle(1f, 0f, 0f, 0.3f);
withdraw[elbowR] = Quat.FromAxisAngle(0f, 0f, 1f, -2.0f);

View file

@ -184,10 +184,11 @@ public static class Program
{
var r = BodyPainBox.Run(OnBody with { BoxIntensity = 0.0, MaxSeconds = 10.0 }, 1);
Check(r.Run.Outcome == Outcome.Endured && r.Run.Flinches == 0 && r.Run.TimeToBreakMs is null, r.Run.Summary());
// Measured idle drift of the palm from the hold point (seed-independent without pain), substeps 2 to 8: the arm settles
// slowly and sags under gravity, so from 3 s the largest drift is 1.8 to 1.9 cm, from 8 s 1.0 to 1.2 cm; at 1 substep it is 3.35 cm
// from 3 s and 1.8 cm from 8 s. A flinch moves the hand over 2.3 cm from where a leak-free arm is; the limits sit 83% and 70% above the
// largest measurement at 2 to 8 substeps, and 4% and 10% above the 1-substep one.
// Measured idle drift of the palm from the hold point (seed 1; without pain the drift is seed-independent): under the gravity feedforward the arm no longer sags,
// it settles onto the hold pose. At 4 substeps (the tuned count) the largest drift is 1.35 cm from 3 s and 0.66 cm from 8 s, at 8 substeps 1.16 and 0.48 cm: the
// limits sit 2.6 and 3.0 times the 4-substep reading, 3.0 and 4.2 times the 8-substep one. The limits hold at 4 and 8 substeps only: at 2 the drift is 5.75 cm
// from 3 s and 0.90 cm from 8 s, at 1 it is 20.5 cm and 20.4 cm.
// A flinch moves the hand over 2.3 cm from where a leak-free arm is; the limits stay at 0.035 and 0.020.
for (int i = 3 * Hz; i < r.Hand.Count; i++) Check(Dist(r.Hand[i]) <= 0.035f, $"drift {Dist(r.Hand[i]):F3} m at tick {i}");
for (int i = 8 * Hz; i < r.Hand.Count; i++) Check(Dist(r.Hand[i]) <= 0.020f, $"late drift {Dist(r.Hand[i]):F3} m at tick {i}");
}),
@ -213,7 +214,7 @@ public static class Program
}
}),
("body: the flinch moves the hand: against a flinch-gain-0 control on the same seed the tracks part by over 2.3 cm within 200 ms of a flinch, and not before the first flinch", () =>
("body: the flinch moves the hand: against a flinch-gain-0 control on the same seed the gap rises by over 2.3 cm within 200 ms of a flinch, above the gap at that flinch", () =>
{
for (ulong seed = 1; seed <= 3; seed++)
{
@ -223,9 +224,11 @@ public static class Program
var flinches = full.Run.Timeline.Where(e => e.Kind == EntryKind.Flinch).Select(e => Tick(e.TimeMs)).ToList();
float Gap(int i) => MathF.Sqrt(MathF.Pow(full.Hand[i].X - control.Hand[i].X, 2) + MathF.Pow(full.Hand[i].Y - control.Hand[i].Y, 2) + MathF.Pow(full.Hand[i].Z - control.Hand[i].Z, 2));
float after = flinches.Max(f => Enumerable.Range(f, Hz / 5 + 1).Max(Gap));
float before = Enumerable.Range(0, flinches[0]).Max(Gap);
// The gap before the first flinch is the continuous leak of the feedforward (the two runs part with the box ramp, before any flinch), so what a flinch adds is read
// against the gap at its own tick: some flinch's 200 ms window raises the gap by over 2.3 cm above it.
float rise = flinches.Max(f => Enumerable.Range(f, Hz / 5 + 1).Max(Gap) - Gap(f));
Check(after > 0.023f, $"seed {seed}: the largest gap from the control after a flinch is {after:F4} m");
Check(before < after / 2, $"seed {seed}: the gap before the first flinch is {before:F4} m, after {after:F4} m");
Check(rise > 0.023f, $"seed {seed}: the largest rise of the gap within 200 ms of a flinch, above the gap at that flinch, is {rise:F4} m");
}
}),