--- library_name: stable-baselines3 pipeline_tag: reinforcement-learning tags: - reinforcement-learning - robotics - mujoco - sac - stable-baselines3 - franka-panda - quadratic-programming - safe-rl --- # Structure vs End-to-End in Reactive Control: training runs The learning process of every arm in one controlled MuJoCo experiment: what a constraint layer between a learned policy and a robot's joints buys (learning speed, safety) and what it costs (CPU time per control tick). Code, design and analysis: [https://github.com/appendix0/reactive-reach](https://github.com/appendix0/reactive-reach). A 7-DoF Franka Panda (MuJoCo Menagerie) follows a moving target to within 2 cm while up to two spheres, some moving, are in the way. Success = within 2 cm for 0.5 s with no robot-obstacle contact at any physics substep. | Arm | Policy outputs | Lower layer | Learns | |---|---|---|---| | `e2e` | 7 joint velocities | clip | SAC | | `ts_dls` | 3-D hand velocity | damped least squares | SAC | | `ts_qp` | 3-D hand velocity | joint-space QP (joint limits, speed limits, collision avoidance) | SAC | | `field_qp` | hand-designed straight-line field | the same QP | nothing to train | The three learned arms share observation, reward, network (256x256), hyper-parameters, budget, scenes and the PD low level. The policy decides at 25 Hz; the lower layer runs every 10 ms. ## Results Three seeds per learned arm, 100,000 policy decisions (400,000 control ticks of 10 ms) each, evaluated on 200 held-out scenes. Hypotheses, estimators and decision rules were sealed before any campaign run ([preregistration/](preregistration/)). | Arm | Success | 95 % CI | Episodes with obstacle contact | |---|---|---|---| | TS-QP | 0.758 | [0.723, 0.792] | 0.000 | | TS-DLS | 0.152 | [0.123, 0.182] | 0.303 | | E2E | 0.048 | [0.032, 0.067] | 0.373 | | Field-QP (no learning; exploratory) | 0.990 | [0.975, 1.000] | 0.000 | | Hypothesis | Outcome | Paired difference over scenes [95 % CI] | |---|---|---| | H1 (primary): TS-QP success > E2E | **supported** | +0.710 [+0.667, +0.753]; better on 185 scenes, worse on 0 | | H2: TS-QP contact < E2E and < TS-DLS | **supported** | −0.373 [−0.428, −0.318] and −0.303 [−0.357, −0.252] | | H3: TS-QP > straight-line Field-QP on 10 trap scenes | **not supported (null)** | −0.267 [−0.567, 0.000] (TS-QP 1 of 30 runs, Field-QP 3 of 10) | - **Robustness of the claims** ([challenge/REPORT.md](challenge/REPORT.md)): H1 stays positive with intervals excluding zero in all 12 pre-committed alternative analyses (+0.305 to +0.783; the success radius moves it most), and TS-QP has zero contact episodes in every one. A placebo passes: with no obstacles, TS-QP policies give identical outcomes through damped least squares and through the QP (189 of 189 episodes). - **Where the gain comes from (exploratory):** TS-QP-trained policies driven without the QP keep success 0.605 (TS-DLS-trained: 0.152) but lose the safety (contact 0.332). Most of the success gain comes from training with the QP in the loop; the zero-contact behaviour comes from the QP at run time. - **Cost:** on one idle Ampere Neoverse-N1 core, a whole TS-QP control tick (policy network, kinematics, Python QP build, DAQP solve) took 675 µs median, 914 µs p99, 1,726 µs at worst; no tick exceeded 2 ms. The DAQP solve alone took 62 µs median; OSQP took 1,034 µs on the same rollouts. - **Limits:** settings were chosen mostly from task-space pilots and E2E received only an action-scale search, so the size of H1 is not evidence that E2E cannot learn the task with more tuning. The 30 N push test was uninformative (the position controller absorbs it). Simulation only; 3 seeds; 3-D position control of the hand. - **Verification:** every number in [report/REPORT.md](report/REPORT.md) was recomputed independently from the raw runs ([audit/](audit/)). ## Layout ``` /s/model.zip final policy (load with stable_baselines3.SAC.load) /s/checkpoints/ snapshots during training (sac__steps.zip) /s/tb/ TensorBoard logs (see the Training metrics tab) /s/videos/ each checkpoint on two held-out scenes /s/eval.jsonl learning curve on held-out scenes /s/train_episodes.jsonl every training episode /s/meta.json commit, config, package versions, host field_qp/ the non-learned arm evaluations/// final, trap and robustness rollouts (episodes.jsonl, summary.json) report/ tables and figures (campaign) challenge/ alternative-analysis grid for H1/H2, its plan (committed before running), ledger preregistration/ the sealed preregistration audit/ independent recomputation of every number in report/ ``` Runs: `e2e` (3), `ts_dls` (3), `ts_qp` (3); seeds s0, s1, s2. Evaluation phases included: final, traps, robust_push, robust_fast, robust_delay. Code commit `93774d3`, config digest `b053159fb88a`, versions: python 3.12.3, mujoco 3.17.0, numpy 2.5.4, qpsolvers 4.13.0, torch 2.15.0+cu132, stable_baselines3 2.9.2, gymnasium 1.4.0. ## Load a policy ```python from huggingface_hub import hf_hub_download from stable_baselines3 import SAC path = hf_hub_download(repo_id="Appendix0/reactive-reach", filename="ts_qp/s0/model.zip") model = SAC.load(path, device="cpu") ``` The environment is `envs.reach_env.ReachEnv` in [https://github.com/appendix0/reactive-reach](https://github.com/appendix0/reactive-reach); create it with the same arm and the config recorded in `meta.json`.