labs
한국어 hello@taklabs.dev

Height, not weight

Steps were raising a low pelvis, set by the move before them, up to their own sink height before the stride opened, so the front leg could not reach. Holding the mid-step height at the lower of the two cut leg-reach failures in the 2408-pair scan from 18 to 5.

When a step followed a move that had already lowered the body, the step pulled the pelvis back up to its own sink height, and the front leg could no longer reach the floor. I now keep the mid-step height at whichever is lower: the height the step found or the step's own sink. That one rule took the back-step group from nine failing pairs to one. Across the full 2408-pair scan, pairs with a leg that doesn't reach went from 18 to 5.

What was broken?

This engine chains moves (punches, defenses, steps, pivots) into one timeline and plants the feet with leg IK. PR #84 and #85 had already fixed the center-of-mass handoff rules. After those, the 2408-pair scan still showed 18 leg-reach failures and six pairs sliding more than 1 cm. I split them into three groups:

  • Group A: steps going backward, nine pairs.
  • Group B: big steps forward, seven pairs.
  • Group C: arms, two pairs.

This PR took on group A.

Why was the handover note's guess wrong?

The handover note said the body was loaded too far toward the direction of travel, which would mean the weight split was off. I tested that with two probes. legprobe.py measured, per pair and per frame, how far the hip-to-ankle distance overshot the leg length. foottrace.py compared the foot paths of each move on its own against the same move chained.

The representative pair was slip left → back shuffle. At frame 20 its weight was front 35% and left 50%, exactly what the table specifies. The weight was fine; the height was off:

  • The pelvis sat at −1.5 cm.
  • The front leg needed −5.1 cm to reach.
  • The slip had already lowered the body to −5.9 cm.

The step started by lifting that body to its own sink before opening the stride. If the body had stayed where the slip put it, the leg would have reached.

Slip left: pelvis −5.9 cm Back shuffle starts Before: raised to step sink Pelvis at −1.5 cm Front leg misses (needs −5.1 cm) After: found height kept to mid-step Rises with the trailing foot Front leg reaches

What changed?

I wrote the rule into docs/BIOMECH.md § 4.4 as "the height a step finds" and changed two places in scripts/biomech/motion.py:

  • add_step now sets the mid-step key to min(found height, the step's sink). If the body arrives lower than the step's sink, from a defense's crouch or from lead step in at −14 cm, it stays at that height until mid-step and then rises with the trailing foot.
  • take_weight now inherits a curved punch's positive dy along with the front %. A hook or uppercut rises above guard, and that rise used to stack on top of the step's sink and leave the pelvis 1.7 cm too high.

The rule has two exceptions:

  • Pendulum steps. A pendulum goes out and comes back, so it has no trailing foot. Holding the height there made lead step in → pendulum jump for one frame at 1.58 m/s, so I excluded pendulums.
  • Heights a curve lowered. These stay with the curve, as before. When I let the step inherit them too, the body cross's 32 cm came back up in 0.13 s, and four body cross → step pairs had their pelvis move 0.4–0.9 m/s faster. So only raised heights are inherited.

I ported both changes line for line into Timeline.swift. Parity only holds if the app engine and the Python reference change in the same commit.

The principle is the same for every two-window step, so I applied the rule to all of them instead of just the back steps. That also cleared five of the seven group B pairs.

What did I throw out?

The broadest option was letting the solver drop the pelvis as far as the legs need. It would mask every reach failure, defeat the IK reach test in § 7.2, and change the engine's structure, so I didn't use it. Earlier work had already ruled out widening the tolerance.

How did I check it?

I ran the same 2408-pair footscan.py on 2fc636e and on this branch.

All reach Group A Group B Group C Slides 0 5 10 15 20 Pairs Failing pairs: before and after Bar 1 Bar 2

Slides dropped from six to two. The four pairs that cleared were the same four that cleared for reach, including the 1.55 cm slide in slip left → back shuffle, so it looks like one cause was showing up as two symptoms. These metrics did not change:

  • center of mass
  • foot crossing
  • foot spacing
  • end stance
  • one-frame jumps
  • event timing

All 429 changed rows were pairs where a step came second. No row for a move on its own changed.

I also added a test that puts every punch, defense, step, pivot and step punch in front of the four back steps and checks Pose.info["reached"]. It covers 232 pairs and runs in 54 s. Then I ran the six checks at HEAD. The repo has no CI, so this local run is the only gate.

build/posevenv/bin/python -m unittest discover -s scripts/biomech -p 'test_biomech.py'   # 175 OK
swift test --package-path Packages/BiomechKit                                            # 47 OK
make biomech-parity                                                                      # mismatch 0
make biomech-transitions                                                                 # flagged 0
build/posevenv/bin/python scripts/biomech/export_params.py --check                       # up to date
sh scripts/xctest.sh DebegiTests                                                         # 462, 0 failures

The work took three sessions, and I ran the review skill once before merging.

What is left?

One pair still fails: pullback → back step, where the front leg is 0.2 cm short on two frames.

  • The table lands the body 1.01 cm past its end spot, which holds the pullback's front 25%. The reason is the same as for the center-of-mass exception in PR #84.
  • The found height of −3.0 cm doesn't reach; −3.2 cm would.

I excluded only this pair from the test and wrote down why in § 4.4. The last two group B pairs, one frame each, go to the next PR.

Some things I did not check:

  • Three pairs whose peak pelvis speed went up. I haven't watched them yet. The largest is slip front-left → short step jab, which went from 1.38 to 1.76 m/s. Pairs faster than 1.4 times their standalone speed fell from 48 to 38, but a lower count doesn't mean the motion looks natural.
  • Timeline.swift. No screen renders it, so I checked it through parity and xctest instead of on-device QA.

Build stats

ModelInputOutputCache readCache writeUSD
claude-opus-5-519872,93517,658,049199,381$6.54
claude-sonnet-5-5102,201115,41636,784$0.13
Total20875,13617,773,465236,165$6.67
claude-opus-5-517,930,563claude-sonnet-5-5154,411
Tokens by model
review1
Skill calls

Counted from 3 session transcripts at 2026-11-21T01:34Z (PR #87, sessions 2026-11-20 to 2026-11-20). Tokens include subagents; USD is list price. Code: +66 / −22 lines.