# Domain randomization

`randomization.py`. A per-episode scale `s` multiplies zero-centred offsets; multiplicative factors
interpolate from 1. Each family has its own switch and its own random stream (policy_training), so
e.g. turning off image effects leaves layouts, physics and camera draws identical for a seed
(`tests/test_randomization.py`). Presets: `nominal`, `teacher` (layout, robot start, physics,
observation noise, disturbances; narrower layout/joint ranges), `visual` (everything).
`s` may exceed 1 for widened evaluation (policy_training's camera ×1.5 suite). `nominal_fraction`
keeps a share of episodes exactly nominal (mjlab_gs).

Sources: **PT** policy_training/real2sim BottleEnv, **MG** mjlab_gs, **RL** rl_training, **new** = first implemented here.

| Family | Quantity | Range at s = 1 (visual preset) | Source |
|---|---|---|---|
| layout | table XY / yaw | ±0.30 m / ±30° (teacher ±0.15 m / ±15°) | MG (PT ±1.5 cm / ±1.4°) |
| layout | bottle position | interpolates nominal → uniform over tabletop minus 5 cm margin (±0.340, ±0.182 m) | MG |
| layout | bottle yaw | ±180° relative to table | MG, PT |
| layout | robot base + pedestal XY / yaw (Gaussian pedestal moves with it) | ±0.20 m / ±30° about the pedestal origin (teacher ±0.10 / ±15°) | MG (PT ±5 mm / ±1°) |
| robot_init | arm joint offsets | ±[45, 20, 30, 45, 30, 90]° (teacher ±[15, 10, 10, 15, 15, 30]°); guard halves offsets until the TCP is ≥ 4 cm above the table and clear of the bottle | MG; guard new |
| robot_init | Cartesian start (`start_mode="cartesian"`) | TCP = grasp + 17 cm stratum {11, 14.5, 18} cm, XY ±7 / ±4.5 cm, grasp yaw ±0.12 rad; IK from nominal | PT |
| robot_init | initial gripper openness | U(0.85, 1) | MG |
| physics | friction (bottle, pads, fingertips, table, floor) | ×0.7–1.3 | MG |
| physics | bottle mass + inertia | ×0.8–1.2 | MG |
| physics | bottle COM offset | ±3 mm per axis | new |
| physics | drive damping (arm kd, RG2 joint viscous) | ×0.8–1.2 | MG |
| physics | arm position gains | ×0.9–1.1 (gravity feed-forward uses the randomized gain) | new |
| physics | gripper force limit | ×0.8–1.2 | new |
| camera | mount position / rotation | ±1 cm / ±5° | MG (PT ±2 mm / ±1°) |
| camera | focal lengths fx, fy | ×(1 ± 0.02) | MG, PT |
| camera | principal point | ±6.4 / ±3.6 px of the 1280×720 sensor (0.5%) | MG, PT (rescaled to D415) |
| lighting | key light position / direction | ±0.3 m / ±0.15 per component | PT |
| lighting | key light intensity and tint | ×0.7–1.3, per-channel ×0.9–1.1 | MG, PT |
| lighting | two fill lights | each on with p = 0.5, intensity U(0, 0.3), random position above the table | PT (multi-light) |
| materials | per-material RGB gain | ×0.8–1.2 per channel, independent per material | PT (MG shared one gain) |
| materials | per-material specular | ×0.5–1.5 | PT |
| materials | table texture | p = 0.5: calibrated scan, else 2 stripe patterns (PT formula) or 3 builtin patterns | PT |
| background | Gaussian room brightness and tint | ×0.85–1.15 and ×0.95–1.05 per channel | new |
| image | exposure / white balance | ×0.85–1.15 / ×0.95–1.05 per channel | MG, PT |
| image | sensor noise | σ ~ U(0.3, 2)/255 per episode, per pixel per frame | PT (MG fixed σ) |
| image | contrast / gamma | ×0.9–1.1 each | PT augmentation |
| image | 3×3 blur | p = 0.1 per episode | PT augmentation |
| timing | action latency | one-tick delay for the episode with p = 0.2 | new |
| timing | stale camera frame | p = 0.05 per tick | new |
| timing | AR(1) correlated translation noise | σ mm (default 0), ρ 0.9 | PT (evaluation option) |
| observation_noise | teacher joints / velocities / relative positions | ±0.01 rad / ±0.05 rad/s / ±2 mm | MG/RL teacher |
| disturbance | bottle push | p = 0.2 per episode, 0.05–0.2 N horizontal, random time 4–10 s, 0.1 s | MG/RL (evaluation push schedules) as a training DR |
| goal | commanded position | nominal TCP ± 5/5/3 cm | MG |

Curriculum: set `DRConfig.scale` per reset from training code (mjlab_gs step schedule or rl_training's
performance gate: advance after two consecutive complete validations > 90% within 3 points).

Not implemented: Gaussian relighting / recolouring of individual scene regions, distractor objects,
lens distortion (the D415 reports zero coefficients), rolling shutter, depth noise, JPEG artefacts.
