Close the sim2real gap for the Furuta pendulum (swings up but can't balance on hardware). Root causes were (a) no domain randomization, so the policy overfit one deterministic sim instance, and (b) reward design flaws that produced degenerate policies. Domain randomization (runner-level, backend-agnostic): - BaseRunner: domain_rand config; per-env action-delay buffer (latency), Gaussian qpos/qvel sensor noise, per-env dynamics-scale sampling (friction/damping/torque), resampled per episode. Sensor noise per step. - privileged_obs/privileged_dim expose normalized DR factors (mu) for RMA. - step() now uses clean state for reward/termination, noisy state for the observation the policy sees. - MuJoCoRunner: applies per-env friction/damping/torque scales. - robot.py: compute_motor_force gains friction/damping scale args. - Configs: DR blocks for mujoco (full) and mjx (delay+noise); clean defaults for mujoco_single/serial; noise/delay anchored to recordings. Reward fixes (rotary_cartpole): - Shift upright reward to [0,1] (was [-1,1]) + alive_bonus, so surviving always beats ending early (kills the "suicide into the limit" policy). - Add balance_bonus * upright * stillness so reward requires upright AND near-zero pendulum velocity (kills the "spin in full loops" policy). Deploy: - eval.py load_policy reconstructs the history/adaptation encoder (auto-detects its dim from the checkpoint) so DR+embedding policies load. Fixes: - MuJoCoRunner._sim_reset referenced self._env (typo) -> self.env, which was breaking every rotary-cartpole reset. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
18 lines
875 B
YAML
18 lines
875 B
YAML
num_envs: 1024 # MJX shines with many parallel envs
|
||
device: auto # auto = cuda if available, else cpu
|
||
dt: 0.002
|
||
substeps: 10
|
||
history_length: 10 # RMA-style: 10-step window of (obs, action) pairs
|
||
|
||
rma_mode: "none" # "none" | "teacher" | "deploy"
|
||
|
||
# ── Domain randomization (sim-to-real) ──────────────────────────────
|
||
# NOTE: action-delay and sensor-noise are applied for MJX, but the
|
||
# per-env dynamics *scales* (friction/damping/torque) are NOT yet wired
|
||
# into the JIT step — use runner=mujoco for scale randomization, or keep
|
||
# this block to delay+noise only on MJX.
|
||
domain_rand:
|
||
qpos_noise_std: 0.01 # rad — encoder angle noise
|
||
qvel_noise_std: 0.5 # rad/s — velocity-estimate noise (measured)
|
||
action_delay_steps: [0, 2] # control-step latency (0–40 ms)
|