# Tube-sort expert and contact improvements — 22 September 2026

## Scope

Acceptance tests now cover tube sorting, not nested boxes. Nested-box trials
remain historical diagnostics only. We keep the user's free 16 g boxes and
10 g hollow tubes. Nominal sliding friction remains 0.6 for boxes and 0.5 for
tubes; the existing randomization spans 0.7–1.3 times nominal. No real friction
calibration is required for this work. Physics remains MJLab / MuJoCo Warp in
`mjlab_gs`, not Superdex.

## Implemented expert changes

- Hermite travel and vertical motion with no sideways jitter during descent,
  lowering or retreat; eased shortest-arc orientation and gripper commands.
- v5 additionally budgets spline duration for wrist rotation: cubic easing's
  peak angular rate stays below the configured 1 degree per control step.
  Earlier translation-only timing caused false orientation timeouts. The
  v4 regression table predates this correction; the 20 fps recording uses v5.
- Three side-grasp locations along each tube: centre and ±20 mm. Candidate
  clearance checks include neighbours, walls and the height of tilted tubes.
- Symmetric gripper orientations avoid unnecessary half-turns. Retry scoring
  preserves each mode's own clearance; a wall-blocked end grasp can no longer
  inherit a side grasp's score.
- Transport over the destination, lower slowly into a lane that includes open
  finger clearance, release to the approach gap, verify separation and retreat
  vertically before opening fully. Destination poses and pile support are live.
- Bilateral target-pad contacts plus target rise verify a lift. Box motion,
  excessive robot–box penetration, lost carried tubes and motion timeouts trigger
  bounded recovery. A timeout never authorizes the next descent or closure.

## Geometry and timestep findings

The 177 box collision pieces and 32 pieces in each tube are convex and
nondegenerate in the mesh audit. The centre cross-section aligns with the visual
wall/rim/floor profile. This is not a volumetric proof that every internal seam
is harmless. No unsupported collision-mesh simplification was made. Thickness
and some shape details remain authored estimates.

The eight task cases cover four/ten-tube piles, low tube/rim drops, a tilted
tube, an occupied destination, a box push and gentle tube extraction. With the
0.5 ms step all eight remain finite; their largest measured active-object
penetration is 0.784 mm. The 0.25 ms step produces a nonfinite box-push case and
is rejected. Smaller timesteps are not automatically a better configuration.
These trials retain a 20 Hz policy period; instrumented wall time is not a
training-throughput benchmark. See `task_contact_matrix.png` and `summary.json`.

## Measured expert trials

| Expert | Seed / world | Friction scale | Sorted | Horizon | Box–tube peak | Box rise | Recoveries |
|---|---|---:|---:|---:|---:|---:|---:|
| v3 | 22 / 0 | 1.0 | 1/4 | 80 s | 0.453 mm | 0.000 mm | 4 |
| v3 | 7 / 0 | 0.7 | 1/1 | 40 s | 0.297 mm | 0.000 mm | 0 |
| v3 | 7 / 1 | 1.0 | 1/4 | 40 s | 0.317 mm | 0.004 mm | 3 |
| v3 | 7 / 2 | 1.3 | 0/10 | 40 s | 0.476 mm | 0.019 mm | 4 |
| v4 | 22 / 0 | 1.0 | 1/4 | 80 s | 0.414 mm | 0.000 mm | 6 |
| v4 | 7 / 0 | 0.7 | 1/1 | 40 s | 0.297 mm | 0.000 mm | 0 |
| v4 | 7 / 1 | 1.0 | 1/4 | 40 s | 0.339 mm | 0.009 mm | 2 |
| v4 | 7 / 2 | 1.3 | 0/10 | 40 s | 0.404 mm | 0.033 mm | 4 |

The v3 trials motivated the retry and grasp-candidate fixes in v4. A completed
single-tube case is an isolated pickup diagnostic, not evidence of crowded-pile
reliability. Truncated horizons are not full-episode success rates. v3 could
temporarily count a stationary held tube as placed; v4 adds explicit pad-contact
exclusion, and evaluation waits for expert release/retreat before scoring.
Use the v4 `valid` field for the new complete physical-validity gate; that field
was not recorded in the v3 results. No bodies are welded, pinned, teleported
during execution, or made heavier to obtain a favourable result.

- v5 recording: 0/4 sorted in 30.0 s; physical gate passed.

The v5 recording is a limited-horizon development check, not a rerun of the
whole v4 regression matrix. Dense-pile reliability remains unresolved.

## Data collection

The collector now checks active box–box, box–tube, box–table, tube–tube,
tube–robot and tube–room penetration at every physics substep. The box limit is
0.8 mm and the tube limit 1.5 mm, in addition to existing robot/speed/force gates.
A tube touching a gripper pad is not scored as sorted. Failed attempts are
retroactively excluded from BC supervision, while earlier successful attempts
remain labelled. Bad initial scenes are rejected without removing tubes from
the task. Automatic simulator resets are disabled in collection/evaluation;
the workflow scores the failed state first. Attempt budgets prevent an endless
collection loop when episodes fail quality checks.

The collection CLI defaults to the explicit `hard2` contact preset and fully
sorted episodes. Generic task defaults remain available for old experiments;
evaluation requires an explicit `--contact-profile hard2`. Existing students
have not been retrained or validated on this new demonstrator.

Validation: 60 tests pass across tube sorting, motion, contact/collection
validity and bin picking (`tests_final_v5.log`). A real-camera collector smoke
run captured two control steps, rejected the deliberately truncated episode,
and stopped at its one-attempt budget (`collection_smoke_v5/summary.json`).
It also serialized the updated physics/task contract successfully. No accepted
training dataset or student retraining is claimed by this update.

```sh
source env.sh
python scripts/collect_tubesort.py --contact-profile hard2 --num-envs 4 \
  --episodes 10 --max-attempts 40 --min-sorted-fraction 1 \
  --randomize --dr-scale 0.3 --output datasets/tubesort_contact_v4
python scripts/evaluate_tubesort.py unused --expert --contact-profile hard2 \
  --num-envs 4 --episodes 4 --videos 4 --external-video \
  --output evaluations/tubesort_contact_v4
```

## Evidence and reproduction

`geometry_audit.json`, `geometry_surface_audit.json` and
`box_collision_section.png` record the geometry inspection. Surface signed
distance was not available without an optional dependency; visual OBJ seam
topology is not used as a collision-solid validation claim.
`axial_candidate_audit.json` records a saved crowded pose: a shifted grasp
reduces obstruction but does not clear it fully. The oblique-angle experiment
in `grasp_candidate_audit.json` did not free that pose and was not adopted.

```sh
source env.sh
python scripts/test_tubesort_contacts.py --task-only --profile hard2 \
  --steps 120 --device cuda:0 --output reports/new_task_contacts
python scripts/test_tubesort_expert_contacts.py --profile hard2 --steps 1600 \
  --seed 22 --tube-counts 4 --device cuda:0 --output reports/new_expert_full
python scripts/test_tubesort_expert_contacts.py --profile hard2 --steps 800 \
  --seed 7 --tube-counts 1 4 10 --friction-scales 0.7 1.0 1.3 \
  --device cuda:1 --output reports/new_expert_friction
```

Runs save their expert source hash, contact peaks, recorded poses and trajectory
data. Interrupted prototypes are excluded from the tables. Diagnostic videos
replay saved poses without integrating replacement physics; the separate
20 fps recording captures control frames during actual task execution.
The prior MuJoCo references are
in `../tubesort_contact_audit/RESEARCH.md`; Warp's float-precision tracking issue
https://github.com/google-deepmind/mujoco_warp/issues/1000 is relevant background,
not a proven explanation for our failed smaller-step trial.
