HOCBF Safety Shield for Neural Policies
Implementation & benchmark of arXiv:2608.17259 — Safe whole-body backstepping control for quadcopter path-following
Source paper: Safe whole-body backstepping control for quadcopter path-following arXiv:2608.17259 ⓘ · analyzed Sep 1, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Use a neural policy only to generate a nominal action, then project that action onto the set satisfying a high-order control-barrier inequality derived from a smooth obstacle-distance function. This preserves the policy's behavior away from obstacles while enforcing a forward-invariant safety region near obstacles, and it can be used either as an inference-time shield or as a differentiable training layer.
Formulas
Mathematical statement
Let the system be control-affine, $\dot{x}=f(x)+G(x)u$, with state $x$, drift $f$, and input matrix $G$. Let $h(x)>0$ define the safe set, for example $h(p)=d(p,\mathcal{O})-d_{\mathrm{safe}}$, where $p$ is position, $\mathcal{O}$ is the obstacle set, and $d_{\mathrm{safe}}$ is the safety margin. If $h$ has relative degree two, define $\psi_0=h$, $\psi_1=\dot h+\alpha_1(h)$, and require $\psi_2=\dot\psi_1+\alpha_2(\psi_1)\geq0$, where $\alpha_1$ and $\alpha_2$ are strictly increasing class-$\mathcal{K}$ functions, commonly $\alpha_i(z)=k_i z$ with $k_i>0$. Since $\psi_2=L_f^2h+L_G L_fh\,u+\alpha_1'(h)L_fh+\alpha_2(\psi_1)$, the safety constraint is affine in $u$. The neural action $u_\pi=\pi_\theta(o)$ is replaced by the closest feasible action $u^*=\arg\min_u\frac12\|u-u_\pi\|_R^2$ subject to $\psi_2(x,u)\geq0$ and actuator bounds. Forward invariance follows when the model is correct, the initial state satisfies $h\geq0$ and $\psi_1\geq0$, and the constraint remains feasible.
Implementation notes
1. Integration point: attach the shield after a policy network and before the environment or actuator. For a first implementation, use a 2D point-mass or quadrotor position controller with state $x=(p,v)$ and known dynamics $\dot p=v$, $\dot v=a$, where $a$ is the policy output; later replace $a$ with thrust and attitude commands using the quadrotor model. Define each obstacle's smooth barrier as $h_j(p)=\sqrt{\|p-c_j\|^2+\epsilon^2}-r_j-d_{\mathrm{safe}}$, where $c_j$ and $r_j$ are obstacle center and radius and $\epsilon>0$ smooths the distance. 2. Pseudocode: compute $u_\pi=\pi_\theta(o)$; evaluate $h_j$, $\dot h_j$, $L_f^2h_j$, and $L_G L_fh_j$ from the differentiable dynamics model; solve a small quadratic program minimizing $(u-u_\pi)^TR(u-u_\pi)$ subject to $L_f^2h_j+L_G L_fh_j u+k_1\dot h_j+k_2(\dot h_j+k_1h_j)\geq0$ for every obstacle and actuator bounds; execute $u^*$. During training, backpropagate through the analytic QP layer or use the shielded action while logging the projection distance. 3. Computed quantities are barrier derivatives and constraints from the control model; estimate model error empirically from one-step prediction residuals and optionally tighten each constraint by $\delta=\beta\hat\sigma(x)$, where $\hat\sigma$ is a residual standard deviation. 4. First cheap experiment: train PPO or SAC on a 2D obstacle-navigation task with an MLP policy, comparing no shield, a penalty-only baseline, and the HOCBF shield. Use $k_1=k_2=2$, $R=I$, and sweep initial distances and policy action scales. The falsifiable signature is a sharp feasibility and violation transition: as nominal action magnitude increases, violations should remain near zero while the QP is feasible, then rise abruptly when the fraction of infeasible states becomes nonzero. For correctly modeled dynamics, the measured minimum barrier should satisfy $\min_t h_j(t)\geq0$ up to discretization error; with timestep $\Delta t$, halve $\Delta t$ and verify that minimum-barrier violation decreases approximately quadratically for the second-order position integrator. The activation rate should grow primarily when $h_j$ or $\psi_{1,j}$ approaches zero, while navigation reward away from obstacles should remain within 5% of the unshielded policy.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Not reproduced ✗
Stage 2 · Practical benchmark result: No measurable effect
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 8/10
Built an analytic 2-D double-integrator HOCBF safety shield with actuator-bounded Euclidean projection and reproducible numerical experiments. The derivative identities were confirmed with maximum absolute errors of 2.7e-6 for h-dot and 1.4e-5 for psi1-dot; required normal acceleration scaled exactly linearly with k2, with observed slope -0.170955 versus predicted -psi1=-0.170955. Shield activation began at the predicted boundary transition, and shielded rollouts maintained positive minimum h while unshielded rollouts collided. This demonstrates the mechanism in the toy setting, but not improved learned-policy reward.
- Agent confidence
- 8/10
- Baseline
- Unshielded fixed policy: minimum h approximately -0.816 to -0.820 across tested scales and timesteps.
- Idea
- HOCBF shield: minimum h approximately 0.0038 to 0.0056, activation rate 0.884–0.968, infeasible rate 0.0; derivative errors 2.7e-6 and 1.4e-5; observed k2 slope -0.170955 versus predicted -0.170955.
Limitations: Only a known-model 2-D point-mass system and one fixed nominal policy were tested. No PPO/SAC training, differentiable QP backpropagation, model uncertainty, multiple obstacles, disturbances, or repeated statistical trials were evaluated; discrete-time safety results are not a formal continuous-time guarantee.
How to run: python3 hocbf_experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2608.17259)
Ahead of the baseline (−0.6%) but not statistically significant (p=0.3172, wins 5 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0108
- Idea mean
- 0.0107
- Effect (Δ)
- -0.0001 (−0.6%; negative = idea better)
- Wins
- 5 / 8 paired seeds
- p-value
- 0.3172 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Not confirmed ✗
- Practical effect
- No effect
- Baseline tuning
- swept over 3 configs
Only the built-in supervised pendulum dynamics track was tested, not PPO or SAC online policy learning. The barrier used a simplified scalar theta safety condition and approximate known dynamics; disturbances, uncertainty tightening, multiple obstacles, and deployment latency were not tested. Actuator-infeasible states can still violate the barrier.
How to run: python3 bench_hocbf.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 9/10
Implemented an end-to-end HOCBF projection around the shared rnn_small dynamics model and ran the full eight-seed paired protocol. Baseline MSE was 0.0107554 and idea MSE was 0.0106944, with paired delta -0.0000609 but permutation p=0.3172, so the improvement is not significant. The shield reduced measured trained-model constraint violations from 9.86% nominally to 1.27% shielded, but the predeclared mechanism confirmation criterion was not met.
- Baseline
- Best lr=0.01; eight-seed mean MSE 0.0107553606, std 0.0007592926.
- Idea
- lr=0.01, k1=2, k2=2; eight-seed mean MSE 0.0106944281, std 0.0008047806; paired delta=-0.0000609325; p=0.3172; 5/8 wins.
Benchmark result
Ahead of the baseline (−0.6%) but not statistically significant (p=0.3172, wins 5 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0108
- Idea mean
- 0.0107
- Effect (Δ)
- -0.0001 (−0.6%; negative = idea better)
- Wins
- 5 / 8 paired seeds
- p-value
- 0.3172 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Not confirmed ✗
- Practical effect
- No effect
- Baseline tuning
- swept over 3 configs
Only the built-in supervised pendulum dynamics track was tested, not PPO or SAC online policy learning. The barrier used a simplified scalar theta safety condition and approximate known dynamics; disturbances, uncertainty tightening, multiple obstacles, and deployment latency were not tested. Actuator-infeasible states can still violate the barrier.
How to run: python3 bench_hocbf.py
Artifacts
- bench_hocbf.py 5.9 KB View Raw
- bench_report.json 2.5 KB View Raw
- hocbf_experiment.py 4.9 KB View Raw
- report.md 1.6 KB View
- report_bench_2026-09-01T164201.md 3.6 KB View
- results.json 10.2 KB View Raw