Gyro tail + audio (task #66): the INSTABILITY MODEL -- mech+0x3F0 reconstructed

Byte-decoded the un-exported master-perf block @0x4aad3d-0x4aaf14 (capstone;
the same gap that held the F5 footstep code) [T1]:

  instab  = (min(|AccelerationLastFrame| / maxUnstableAcceleration, 1)
             x unstableAccelerationEffect)^2
  instab += clamp((demand - legCycleSpeed)/demand, <=1)      # "gun the engine"
             x unstableGunTheEngineEffect                    # (demand clamped to
                                                             #  [gimpStride(neg), runMax2])
  if (legAnimationState == 4 /*turn-in-place*/) instab += unstableStopedTurnEffect
  clamp to 1  ->  mech+0x3F0  ->  gyro->swayBias (gyro+0x3A8)

Every piece resolves to already-reconstructed structure: the model-record
tuning block rec+0x80..0x94 (ctor copy @0x4a2593 -- the six authored
Unstable* fields, previously parked in the Wword scratch bank, now real
members); AccelerationLastFrame@0x82c = the snapshot of the ring-derived
localAcceleration (copied at the perf tail @0x4ab142); CurrentSpeed@0x348 =
legCycleSpeed; the trn state 4 gate; and the gyro feed lands in the
EXISTING swayBias member + GyroscopeSimulation consumer (task #56) --
GyroFrameJointWrite's "0.0f model TBD" argument is now the live value.

UnstablePercentage (binary id 52 @0x3F0) binds the real member: the LAST
dead audio attribute is live -- the authored instability alarm (start
thresh 0.01 + volume = the fraction) sounds under hard maneuvers, and the
cockpit ambient sway now scales with reckless driving.

Live verification (30s, 0.6-throttle run): instab 0.38 during the walk->run
chase (cyc 22.2 vs demand 33.6), settling to 0.002-0.12 per-stride ripple at
steady run; attribute binds with live float values; [instab] trace under
BT_GYRO_TRACE.  unstableSuperStopEffect/unstableHighVelocityEffect writers
remain unlocated (plausibly the airborne perf variant) -- noted on members.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
arcattack
2026-07-16 15:51:10 -05:00
co-authored by Claude Opus 4.8
parent c581553a6c
commit c51d64a6b8
5 changed files with 77 additions and 11 deletions
+42 -1
View File
@@ -5244,13 +5244,54 @@ void
//
if (GetInstance() == MasterInstance)
{
// (task #66) INSTABILITY MODEL -- byte-decoded from the binary master
// perf @0x4aad3d-0x4aaf14 [T1] (the un-exported gap; capstone disasm).
// Runs HERE, right before the gyro dispatch, exactly as the binary
// does: it reads LAST frame's acceleration snapshot (the tail updates
// localAcceleration afterwards -- "AccelerationLastFrame", the same
// vector the binary copies to +0x82c after this point).
{
// term 1: acceleration sway, squared
Scalar a = localAcceleration.linearMotion.Length();
a = (maxUnstableAcceleration > 0.0f) ? a / maxUnstableAcceleration : 0.0f;
if (a > 1.0f) a = 1.0f;
a *= unstableAccelerationEffect;
unstablePercentage = a * a;
// term 2: "gun the engine" -- commanded speed the legs haven't
// reached, as a fraction of the command (negative when coasting
// past the demand -- the binary does not floor it)
MechControlsMapper *im = MappingMapper();
Scalar u = (im != 0) ? im->speedDemand : 0.0f;
if (u > reverseSpeedMax2) u = reverseSpeedMax2; // @0x7a0 run cap
if (u < gimpStrideLength) u = gimpStrideLength; // @0x350 (negative reverse cap)
Scalar r = 0.0f;
if (u > 0.0f)
r = (u - legCycleSpeed) / u;
else if (u < 0.0f)
{
r = u - legCycleSpeed;
r = ((r <= 0.0f) ? -r : r) / (-u);
}
if (r > 1.0f) r = 1.0f;
unstablePercentage += r * unstableGunTheEngineEffect;
// term 3: turning in place (trn, leg state 4)
if (legAnimationState == 4)
unstablePercentage += unstableStopedTurnEffect;
if (unstablePercentage > 1.0f) unstablePercentage = 1.0f;
if (getenv("BT_GYRO_TRACE")) { static long s_it=0; if ((++s_it % 120)==0)
DEBUG_STREAM << "[instab] " << unstablePercentage
<< " (|a|=" << localAcceleration.linearMotion.Length()
<< " demand=" << u << " cyc=" << legCycleSpeed
<< " legState=" << legAnimationState << ")\n" << std::flush; }
}
extern void GyroFrameJointWrite(Subsystem *, Scalar, int, int);
static int s_gyrodbg = 0;
if (getenv("BT_GYRO_LOG") && s_gyrodbg++ == 0)
DEBUG_STREAM << "[gyro] dispatch: gyro=" << (void *)gyroSubsystem
<< " legAnim=" << legAnimationState
<< " death=" << deathAnimationLatched << "\n" << std::flush;
GyroFrameJointWrite(gyroSubsystem, 0.0f /* mech+0x3F0 model TBD */,
GyroFrameJointWrite(gyroSubsystem, unstablePercentage,
legAnimationState, deathAnimationLatched);
}
else if (getenv("BT_GYRO_LOG"))