Envelope Margins: Sliding-Window Bounds on Fast Disturbances for Control Barrier Functions

Safety filters for robots and vehicles often take the form of control barrier functions. A control barrier function (CBF) is a scalar function of the state that is positive inside the safe region. At every control step, a small quadratic program chooses the command closest to the one the policy asked for while keeping that function from decreasing too fast. The guarantee depends on knowing how much an unknown disturbance can push the system. Current practice estimates the disturbance with an observer, and it bounds the observer's error by assuming the disturbance changes smoothly, with a known Lipschitz constant on its rate of change. Many real disturbances do not behave this way. Road roughness, structural resonance, motor cogging and gusts are fast and oscillatory, so their rate-of-change bound is enormous. What changes slowly is their amplitude. A margin built on the Lipschitz assumption is then either uselessly conservative or wrong.

We propose to bound the fast part of the disturbance by its recent amplitude, measured with sliding-window extrema of the observer's residual, and to feed that bound into the CBF as a time-varying robustness margin. The key change is to the assumption. We replace "the disturbance is smooth" with "the disturbance's envelope drifts slowly and its peaks recur within a known time". Under the second assumption, a windowed maximum gives a valid upper bound on the next few control steps. Running several window lengths in parallel and taking the smallest resulting bound is still valid, because the minimum of valid upper bounds is valid. The contribution is a CBF safety filter whose margin comes from multi-scale window statistics. It carries a stated forward-invariance guarantee under a weaker assumption than current disturbance-observer CBFs, and it can be updated within a control step using incremental window aggregation.

Core Claim

Write the disturbance as $d(t) = d_s(t) + d_f(t)$. The slow component $d_s$ is tracked by a standard first-order disturbance observer. The fast component $d_f$ has an unknown envelope $A(t) \ge |d_f(t)|$. We assume two things. The envelope is Lipschitz with constant $L_A$. And within any interval of length $T$, $|d_f|$ reaches at least $(1-\rho_T)A$, where $\rho_T \in [0,1)$ is a recurrence slack. Let $M_T(t)$ be the maximum of the measured residual magnitude over the last $T$ seconds, let $\eta$ bound measurement and observer noise, and let $H$ be the look-ahead horizon over which the margin must hold. Then

$$ \sup_{s \in [t, t+H]} |d_f(s)| \;\le\; \bar\sigma_T(t) := \frac{M_T(t) + \eta}{1-\rho_T} + L_A (T + H). $$

The derivation is short. The windowed maximum is at least $(1-\rho_T)$ times the smallest envelope value in the window. That smallest value is at least $A(t) - L_A T$. The envelope can then grow by at most $L_A H$ over the horizon. The filter enforces

$$ \nabla h(x)^\top\big(f(x) + g(x)u + \hat d_s\big) \;\ge\; -\alpha(h(x)) + \|\nabla h(x)\|\big(\sigma_s + \min_{T \in \mathcal{T}} \bar\sigma_T(t)\big). $$

Here $h$ is the barrier and $\alpha$ is the usual class-$\mathcal{K}$ decay function. The term $\sigma_s$ is the slow-observer error margin inherited from Disturbance Observers for Robust Safety-Critical Control With Control Barrier Functions, and $\mathcal{T}$ is a bank of window lengths.

The claim to be tested is that this filter keeps violations at the level of the robust baselines on disturbances with large fast components while giving up much less performance. The margin shrinks when the environment is quiet and grows within one window when it is rough. The claim is also explicitly falsifiable: it should fail on disturbances that break the recurrence assumption, such as isolated shocks, and we intend to show where.

Relation to Prior Work

Three papers supply the machinery and motivate the gap. Disturbance Observers for Robust Safety-Critical Control With Control Barrier Functions puts a high-gain observer estimate into the CBF constraint with a robustness parameter $\sigma$. It proves forward invariance under Lipschitz disturbances and shows that high gains destabilize the loop under input delay. Disturbance Observer-Parameterized Control Barrier Function with Adaptive Safety Bounds moves the barrier itself with the estimate, as $h_d(x,\hat d)$. It reports a 100% safety rate over 1,000 road-grade trials and 22.73% smoother control. Both methods use only an instantaneous point estimate and a worst-case Lipschitz bound on its error. We keep their slow observer and replace the error model for the fast part. That is precisely the regime their Lipschitz assumption handles poorly.

The closest existing method is Safety Filter for Robust Disturbance Rejection via Online Optimization. It already derives a time-varying clipping bound from past input and output history. That paper certifies stability of an adaptive finite-impulse-response canceller through a small-gain argument on a linear plant. We instead certify a state constraint on a nonlinear system, and our history enters as an amplitude envelope rather than a gain bound.

Two lines of work supply method and constraints. N-BaIoT shows that parallel windows from 100 ms to 1 minute capture both fast and slow behaviour cheaply, and we borrow the multi-scale bank from it. General Incremental Sliding-Window Aggregation provides FlatFAT, which updates non-invertible aggregates like the maximum in logarithmic time. With it, a bank of window maxima fits well inside a 1 kHz control step.

Several constraints shape the design. Monitoring with verified guarantees found that stream-monitor bugs concentrate at window boundaries, where defaults apply before the window fills. For that reason, our margin falls back to the static worst-case bound until a window has filled, and again after any Simplex-style switch.

We avoid conformal calibration on overlapping windows. Learning-Based Approaches to Predictive Monitoring with Conformal Statistical Guarantees notes that the autocorrelation between overlapping windows breaks the exchangeability conformal methods need. Our bound is deterministic given the recurrence parameter $\rho_T$. That parameter is estimated offline from independent episodes, never from overlapping windows within a single trajectory.

Provable Robustness for Streaming Models with a Sliding Window finds that longer windows weaken certificates. Our bound shows a matching effect, since the $L_A T$ term grows with $T$. The multi-scale minimum is our answer to that trade-off.

Research Program

The work has three parts.

Theory. We will state and prove forward invariance of the safe set under the envelope and recurrence assumptions. We will add discrete-time sampling and a bounded input delay, following the delay analysis of the observer-CBF paper. We will also characterize when the multi-scale minimum is strictly tighter than any single window.

Implementation. We will build a residual pipeline in which finite-difference residuals minus the slow estimate feed a FlatFAT maximum per window length. Each window has a cold-start guard. The pipeline outputs $\min_T \bar\sigma_T$ to a standard CBF quadratic program.

Calibration. We will define a procedure for $\rho_T$ and $L_A$. Each parameter is estimated on held-out episodes as the worst observed value, plus a safety factor whose effect we sweep. This makes explicit which part of the guarantee rests on data and which on proof.

Baselines

The naive reference is a nominal CBF with no disturbance compensation. It shows how often the unprotected problem actually fails.

The static robust CBF uses a margin equal to the global worst-case disturbance magnitude over the whole test distribution. It should be safe and maximally conservative. It shows the performance headroom that any adaptive margin can recover.

The first strongest competitor is the observer CBF of Disturbance Observers for Robust Safety-Critical Control With Control Barrier Functions. The second is DOp-CBF from Disturbance Observer-Parameterized Control Barrier Function with Adaptive Safety Bounds, which reports a 100% safety rate across 1,000 randomized road-grade trials and a 22.73% average smoothness gain over non-parameterized observer methods. These two are the right comparison because they are the most recent methods that adapt margins online with a guarantee. For fairness, they receive the same slow observer, and their observer gain and Lipschitz constant are tuned with the same grid budget we give our calibration. Tuning happens on the same held-out episodes, and the tuned constant must achieve zero violations there before testing.

For the linear flexible-stage task only, we also compare against the RLS-AFDR safety filter from Safety Filter for Robust Disturbance Rejection via Online Optimization, which reports a tracking standard deviation of 0.0920 on the uncertain plant.

Beating these baselines means matching their violation rate on every task, including 0 of 1,000 on the road-grade reproduction. It also means improving at least one performance measure by a margin that exceeds trial-to-trial spread: time headway or speed-tracking error, control smoothness, or the rate at which the quadratic program becomes infeasible.

Four ablations isolate the key ingredient. The first uses a single window instead of the bank. The second replaces the window maximum with a window standard deviation scaled by a constant. The third replaces the window with a leaky peak-hold that decays at rate $L_A$. The fourth removes the cold-start guard.

Why not just…?

Why not just use the observer CBF with a larger Lipschitz constant? That is always possible and always safe if the constant is large enough. For a fast oscillatory disturbance, however, the bound on its rate of change scales with amplitude times frequency. The margin then becomes the global worst case, even at moments when the actual disturbance is small. The tuned observer-CBF baseline tests this directly. If it matches our performance at equal safety, the idea fails on these tasks.

Why not just raise the observer gain so it tracks the fast component? The observer-CBF paper itself shows that high gains destabilize the loop under small input delays, and fast disturbances are exactly where gains would need to be high. We will sweep gain against injected delay and report where each approach breaks.

Why not just use a leaky peak detector or an exponential moving average of the residual magnitude? This is a real threat. A peak-hold that decays at rate $L_A$ satisfies essentially the same bound, so the finite window is not what carries the guarantee. We state this openly. The contribution is the envelope-and-recurrence assumption and the multi-scale minimum. The possible advantage of a window is that it forgets a large past burst after $T$ seconds, whereas a peak-hold forgets at the drift rate $L_A$, which may be slow. The peak-hold ablation will show whether that difference matters in practice. If it does not, we will report the simpler estimator as the recommended implementation. An exponential moving average of magnitude has no upper-bound property, so we expect it to violate constraints on bursty inputs, and it is included to show that.

Why not just learn the margin with a sequence model? Models like the transformer monitor in System-Level Safety Monitoring and Recovery for Perception Failures in Autonomous Vehicles reach high accuracy, but they give up formal guarantees. Here the target is a certified margin, not a classifier, so a learned margin would need its own validation on top.

Proposed Experiments

Adaptive cruise control. The first benchmark is the adaptive cruise control road-grade setting of the DOp-CBF paper. We will first reproduce its grade-only condition. We will then add a fast component with varying amplitude, representing road-roughness vibration from 5 to 30 Hz, whose envelope ramps between rough and smooth road segments. We will run 1,000 randomized trials per condition.

Flexible motion stage. The second benchmark is the flexible motion stage from the safety-filter paper. We add a position-error barrier and use the same 100 Monte Carlo uncertain plants. Its shifted resonances produce exactly the kind of fast, amplitude-modulated disturbance we target.

Constrained locomotion. The third benchmark is a velocity-constrained task from Safety Gymnasium, with injected oscillatory external forces. It tests whether the filter works under a learned policy in higher dimensions.

Hardware. If hardware is available, we will use the Quanser cart-pole described in Constraint-Guided Online Data Selection for Scalable Data-Driven Safety Filters in Uncertain Robotic Systems, with a shaker-induced disturbance.

Metrics. We will report violation rate and worst-case barrier value, performance (headway or tracking error, and reward), control smoothness measured as the root mean square of the input's rate of change, the rate at which the quadratic program becomes infeasible, and per-step compute time.

Decisive checks. There are three. First, on the amplitude-modulated condition, our filter should equal the robust baselines' zero-violation record while cutting conservatism, measured as excess headway or tracking error, substantially relative to the tuned observer CBF. Second, on a deliberately adversarial condition of isolated shocks with no recurrence, the bound should fail as the theory predicts, and violations should occur only when the measured $\rho_T$ exceeds the calibrated value. That result would confirm that the guarantee's assumptions, not luck, are carrying safety. Third, removing the cold-start guard should produce violations concentrated right after episode starts and controller switches, which reproduces the boundary failure mode reported by the stream-monitoring work in a control setting.