#!/usr/bin/env bash # ========================================================================= # Sauron: "toggled through advanced controls from standard to advanced and # back to standard -- lost torso control." # # THE MECHANISM (@004afbe0, the binary's CycleControlModeMessageHandler): # the mode cycles 0 Basic -> 1 Standard -> 2 Veteran -> WRAPS TO BASIC. So # getting from Veteran/"advanced" back to Standard PASSES THROUGH BASIC, and # the Basic arm re-centres the torso. # # The port set that re-centre with CommandRecenter() -> centerCommand (@0x208). # That is the HELD-BUTTON cell: TorsoSimulation re-arms `recenterActive` from # it EVERY frame it is non-zero and only the input path clears it -- and a mode # switch has no button release to follow. One visit to Basic pinned it at 1 # forever. Digital twist commands are processed BEFORE the centerCommand # block, so they were overridden as fast as they were applied = "lost torso # control". The binary writes recenterActive (@0x274) instead: a ONE-SHOT that # self-clears on settle and is cancelled by any twist input. # # THE MEASUREMENT. BT_MODECYCLE_EVERY= cycles the control mode every n mapper ticks # frames from that frame. BT_TORSO_LOG's gate probe now prints the two cells: # [torso] ... ctrCmd= recen= vLim=(lo..hi) # # PASS: ctrCmd stays 0 across every cycle (the one-shot is used instead), and # vLim SWAPS between the Basic pair and the assisted pair as the mode # changes -- proving the elevation-limit swap (@0x228/@0x22C vs # @0x230/@0x234) that the port previously never implemented. # FAIL: ctrCmd latches to 1 after the first pass through Basic and never # returns to 0 -> the torso re-centres forever. # # Single node: this is entirely local control state, no peer needed. # ========================================================================= set -x . /c/git/bt411/scratchpad/night6/bench_common.sh cd /c/git/bt411/content || exit 1 taskkill //F //IM btl4.exe > /dev/null 2>&1 sleep 2 rm -f mc_a.log bt_expert_egg MP.EGG MC.EGG sed -i "s/^map=.*/map=grass/; s/^time=.*/time=day/; s/^vehicle=.*/vehicle=madcat/" MC.EGG ( export BT_MODECYCLE_EVERY=400 export BT_TORSO_LOG=1 BT_KEY_NOFOCUS=1 BT_KEY_BRIDGE=0 BT_TWIST_PULSE=150 ${LEGACY:+BT_LEGACY_MODE_RECENTER=1} bt_launch mc_a.log MC.EGG 0x03 ) sleep 150 bt_kill_ours; sleep 2; taskkill //F //IM btl4.exe > /dev/null 2>&1; sleep 3 echo "=================== CONTROL-MODE TORSO STATE ===================" echo "--- the mode cycles that happened ---" grep -a "\[mode\] control mode" mc_a.log | head -10 echo echo "--- centerCommand must NEVER latch (ctrCmd=1 with no button = the bug) ---" echo -n " samples with ctrCmd=1 : "; grep -ao "ctrCmd=[0-9]*" mc_a.log | grep -c "ctrCmd=1" echo -n " samples with ctrCmd=0 : "; grep -ao "ctrCmd=[0-9]*" mc_a.log | grep -c "ctrCmd=0" echo echo "--- the elevation-limit SWAP (should differ between Basic and assisted) ---" grep -ao "vLim=([^)]*)" mc_a.log | sort | uniq -c | sort -rn | head -5 echo echo "--- torso state around each mode change ---" grep -aE "\[mode\] control mode|ctrCmd=" mc_a.log | grep -aA1 "\[mode\]" | head -12