Fix throttle-detent Abs() macro bug + KB analog-throttle + slide diagnostics (task #50)
Uncommitted work from the speed-model + peer-motion investigation: - btl4mppr.cpp: the L4MechControlsMapper full-throttle detent used the unparenthesized Abs() macro (STYLE.H:118) on an expression -- Abs(throttlePos - 1.0f) mis-expands to -(throttlePos + 1.0f), always <= 0.05, so the detent snapped throttle to full EVERY frame. Diff into a temp first (same class as the7615ecdangular-resync Abs fix). - context/pod-hardware.md: document the decomp-verified analog-continuous pod throttle path (RIO Ranger 0-800 counts, 0.05 deadband, no notching; '5 speeds' is false) from workflow w0odszxro. - mech4.cpp: BT_SLIDE/[mslide] per-frame slide diagnostics (peer position moving while legs in stand; master decel profile) -- used to prove the stop-slide is a peer leg-SM-winds-down-early desync, not master momentum. Env-gated. The 'pretty good' coupled-motion gameplay state is already shipped (a9ab3db). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
a9ab3db952
commit
3792a04661
@@ -349,7 +349,12 @@ L4MechControlsMapper::MessageHandlerSet&
|
||||
//
|
||||
// (1) Full-throttle detent.
|
||||
//
|
||||
if (Abs(throttlePosition - 1.0f) <= 0.05f) // _DAT_004d1ac0 / _DAT_004d1ac4
|
||||
// NB: the Abs() macro (STYLE.H:118) is unparenthesized -- Abs(throttlePosition
|
||||
// - 1.0f) mis-expands to -(throttlePosition + 1.0f) on the false branch (always,
|
||||
// since throttle <= 1), which is <= 0.05 UNCONDITIONALLY -> the detent used to
|
||||
// snap throttle to full every frame. Diff into a temp so the macro sees one token.
|
||||
const Scalar _thrOff = throttlePosition - 1.0f;
|
||||
if (((_thrOff < 0.0f) ? -_thrOff : _thrOff) <= 0.05f) // _DAT_004d1ac0 / _DAT_004d1ac4
|
||||
{
|
||||
throttlePosition = 1.0f; // @0x11c
|
||||
}
|
||||
|
||||
@@ -2189,6 +2189,30 @@ void
|
||||
localToWorld = localOrigin; // refresh with the coupled position
|
||||
}
|
||||
|
||||
// SLIDE probe (BT_SLIDE): per-frame, log when the peer position MOVES
|
||||
// while its legs are in STAND (legState 0) -- the user's "sliding after
|
||||
// legs stopped". Reports move magnitude, offset to authority, leg state.
|
||||
if (getenv("BT_SLIDE"))
|
||||
{
|
||||
static Point3D s_slPrev; static int s_slInit = 0;
|
||||
const int ls = (int)legStateAlarm.GetLevel();
|
||||
if (s_slInit)
|
||||
{
|
||||
const float dx = (float)(localOrigin.linearPosition.x - s_slPrev.x);
|
||||
const float dz = (float)(localOrigin.linearPosition.z - s_slPrev.z);
|
||||
const float mv = sqrtf(dx * dx + dz * dz);
|
||||
if (ls == 0 && mv > 0.02f) // standing but moving = slide
|
||||
{
|
||||
Vector3D off; off.Subtract(updateOrigin.linearPosition, localOrigin.linearPosition);
|
||||
DEBUG_STREAM << "[slide] move=" << mv
|
||||
<< " legAdv=" << replLegAdv
|
||||
<< " offToAuth=" << (float)off.Length()
|
||||
<< " legState=" << ls << "\n" << std::flush;
|
||||
}
|
||||
}
|
||||
s_slPrev = localOrigin.linearPosition; s_slInit = 1;
|
||||
}
|
||||
|
||||
// PEER-DRIFT probe (BT_MIRDIV, 1s max): how far the peer's coupled
|
||||
// position wanders from the last-received authority (updateOrigin)
|
||||
// before a record re-anchors it -- the other end of the snap.
|
||||
@@ -3422,6 +3446,21 @@ void
|
||||
// impact freezes travel as before.)
|
||||
const Scalar travelAdv = s_realControls ? legAdv : adv;
|
||||
const Scalar localAdv = travelAdv * dir;
|
||||
// MASTER-SLIDE probe (BT_SLIDE): does the MASTER itself advance while its
|
||||
// legs are in STAND (legState 0)? If yes -> authentic momentum coast, the
|
||||
// peer correctly mirrors it. If the master travelAdv reaches 0 exactly
|
||||
// when legState reaches 0 -> the master stops clean and the peer's stand-
|
||||
// slide is a peer leg-SM-too-fast desync. Logs the decel profile.
|
||||
if (getenv("BT_SLIDE"))
|
||||
{
|
||||
const int mls = (int)legStateAlarm.GetLevel();
|
||||
const float ta = (float)(travelAdv < 0 ? -travelAdv : travelAdv);
|
||||
if (ta > 0.005f) // master still moving
|
||||
DEBUG_STREAM << "[mslide] travelAdv=" << travelAdv
|
||||
<< " legState=" << mls
|
||||
<< " legCycle=" << legCycleSpeed
|
||||
<< " thr=" << throttle << "\n" << std::flush;
|
||||
}
|
||||
linearSpeed = (localAdv < 0.0f ? -localAdv : localAdv) * invDt; // forward ground speed -> LinearSpeed gauge
|
||||
Vector3D localVel(0.0f, 0.0f, -localAdv * invDt); // exact frame distance as velocity
|
||||
Matrix34 orient; // rotation from the heading (set @ line ~626)
|
||||
|
||||
Reference in New Issue
Block a user