Spaces:
Running on T4
Running on T4
|
Download docs/load-and-timing-for-coach-agent.md from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 7.76 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/docs/load-and-timing-for-coach-agent.md
- Command line
-
hf download hf://spaces/modventures/baseball-engine/docs/load-and-timing-for-coach-agent.md
-
curl -L -o load-and-timing-for-coach-agent.md https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/docs/load-and-timing-for-coach-agent.md
7.76 kB
| # Load and timing: measurements for the coach agent | |
| **Purpose:** Our engine measures when the movements happen. The coach agent uses those measurements to explain timing and compare swings. The coach agent chooses the problems, priority, drill and explanation. | |
| **Implementation status:** The engine now exposes these four fields through `GET /v1/analyses/{job_id}/load-timing`, using schema version `3.0`. The existing nine-field `/coach-payload` endpoint still uses `2.0`; the friend's validator needs to accept the new timing contract before using it. Load and foot timing are estimated when supported. Automatic actual contact, closest approach and early/late estimation remain unavailable. All example numbers below are made up to explain the calculations. See [API instructions](LOAD_TIMING_API.md). | |
| **Testing:** [load_and_swing_test.ipynb](../notebooks/load_and_swing_test.ipynb) is a separate Colab GPU notebook for these fields. It estimates supported body events, exports the proposed timing payload, and shows event frames and previews. Actual contact/closest approach can optionally be supplied as reviewed frames to test duration arithmetic. Automatic bat/ball tracking and early/late estimation remain unavailable. The existing API contract is unchanged. | |
| ## What the agent receives | |
| Each swing has four timing measurements. All numbers use **actual recording time**, in milliseconds (`ms`), rather than slowed playback time. | |
| | Field | Calculation | Meaning | | |
| | --- | --- | --- | | |
| | `load_to_swing_ms` | Forward swing start − preparation start | Time from starting preparation, such as moving the hands/bat backward, to starting the forward swing. | | |
| | `foot_down_to_swing_ms` | Forward swing start − front-foot contact | Time between the front foot first touching the ground and the forward swing starting. A negative value means the swing started before the foot landed. Only applies if the player steps. | | |
| | `swing_duration_ms` | Ball contact − forward swing start | Time taken by the forward swing to reach the ball. For a miss, measure to closest bat–ball approach and label the ending separately. | | |
| | `early_late_shift_ms` | Estimated time adjustment needed for a miss | How much earlier or later the same recorded bat movement would need to happen to meet the ball. Requires reliable bat/ball tracking. | | |
| For `early_late_shift_ms`, the sign describes the **suggested adjustment**: | |
| - `-40`: move the swing **40 ms earlier**. | |
| - `+40`: move the swing **40 ms later**. | |
| Front-foot contact means the first ground contact. It does not mean the foot has finished settling or that the player has transferred their weight. | |
| ## Example | |
| Suppose preparation starts at **1,000 ms**, the front foot lands at **1,250 ms**, the forward swing starts at **1,300 ms**, and the bat contacts the ball at **1,450 ms**. | |
| The calculations are: | |
| - Load-to-swing time: `1300 - 1000 = 300 ms`. | |
| - Foot-down-to-swing time: `1300 - 1250 = 50 ms`. | |
| - Swing duration: `1450 - 1300 = 150 ms`. | |
| - Early/late adjustment: not applicable because this example is a hit. | |
| The timing payload keeps the `reps[].metrics[]` structure. This illustrative hit example describes the contract, not independently validated measurements. The tracking-enabled API can now establish estimated visual hit intervals when actual bat/ball observations support them; it returns unknown when evidence is missing. Physical misses and timing corrections require calibrated synchronized two-view paths. Default version 3.0 remains compatible; opt-in 3.1 includes reason codes, event intervals and supplied practice context. See [API requests and evidence](LOAD_TIMING_API.md). | |
| ```json | |
| { | |
| "schema_version": "3.0", | |
| "discipline": "hitting", | |
| "time_basis": "capture", | |
| "capture": { | |
| "ok": true, | |
| "reasons": [] | |
| }, | |
| "reps": [ | |
| { | |
| "rep": 1, | |
| "outcome": "hit", | |
| "stepped": true, | |
| "metrics": [ | |
| { | |
| "key": "load_to_swing_ms", | |
| "value": 300, | |
| "unit": "ms", | |
| "status": "estimated", | |
| "confidence": "est", | |
| "note": "Load start to forward swing start." | |
| }, | |
| { | |
| "key": "foot_down_to_swing_ms", | |
| "value": 50, | |
| "unit": "ms", | |
| "status": "estimated", | |
| "confidence": "est", | |
| "note": "First front-foot ground contact to forward swing start." | |
| }, | |
| { | |
| "key": "swing_duration_ms", | |
| "value": 150, | |
| "unit": "ms", | |
| "end_event": "contact", | |
| "status": "estimated", | |
| "confidence": "est", | |
| "note": "Forward swing start to ball contact." | |
| }, | |
| { | |
| "key": "early_late_shift_ms", | |
| "value": null, | |
| "unit": "ms", | |
| "status": "not_applicable", | |
| "confidence": "est", | |
| "note": "Timing correction is only estimated for misses." | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| ``` | |
| For a miss, use `outcome: "miss"` and `end_event: "closest_approach"` for swing duration. If the outcome cannot be established, use `outcome: "unknown"` and withhold measurements that depend on knowing it. | |
| ## How the coach agent uses the numbers | |
| | Measurement | What the agent can compare or explain | | |
| | --- | --- | | |
| | Load-to-swing time | Whether preparation takes a similar amount of time across swings, and whether it differs between successful swings and misses under similar conditions. | | |
| | Foot-down-to-swing time | Whether the swing starts before, around or after the front foot lands, and how that relationship changes across swings. | | |
| | Swing duration | How long the forward movement takes to reach contact or closest approach. It is not a bat-speed measurement. | | |
| | Early/late adjustment | A supported timing adjustment for a miss, such as: “For this pitch, the same swing would have needed to happen about 40 milliseconds earlier.” | | |
| The agent should compare similar situations: the same player, similar pitch speed and location, and the same type of practice. A tee swing is not a moving-pitch timing test. | |
| These durations alone do not prove the player is rushed, early or late. Calling the player **“rushed” requires comparison with their successful swings under similar conditions**. There is no separate “ready” or “pause” metric in this feature. | |
| ## How the early/late estimate works | |
| For a miss, the engine keeps the recorded ball movement unchanged and tests shifting the same recorded bat movement earlier or later in time. It checks whether a shift would allow the bat to meet the ball. | |
| This is an estimate based on repeating the same movement. It does not predict how the player would change their swing after receiving advice. | |
| If reliable tracking cannot support an adjustment, or shifting the timing would still leave the bat missing the ball, return `value: null`, `status: "unclear"` and a reason. Do not invent a timing correction for a bat path that cannot reach the ball. | |
| ## Missing data and interpretation rules | |
| - Missing or unreliable events: use `value: null`, `status: "unclear"` and explain the reason in `note`. | |
| - No step: foot-down-to-swing time is `null` with `status: "not_applicable"`. | |
| - Hit: early/late adjustment is `null` with `status: "not_applicable"`. | |
| - Miss with unreliable bat/ball tracking: early/late adjustment is `null` with `status: "unclear"`. | |
| - Unknown actual recording time: withhold timing numbers rather than calculate them from slowed playback time. | |
| - Do not replace missing values with zero. Zero is a valid measured timing relationship. | |
| - Do not treat `confidence: "est"` as proof of accuracy. It labels the number as an estimate. | |
| - The existing body-based arm-extension event is a contact proxy. It cannot be called actual ball contact without supporting bat/ball evidence. | |