Correcting Learning-based Perception for Safety

arXiv cs.LG Papers

Summary

This paper proposes a two-step strategy to correct learning-based perception errors in autonomous systems, using offline uncertainty characterization and a runtime risk heuristic to improve safety with minimal impact on performance.

arXiv:2609.22108v1 Announce Type: new Abstract: Learning-enabled perception is important in many autonomous systems. Unlike traditional sensors, the boundary where ML perception does or does not work is poorly characterized. Incorrect perception can lead to unsafe or overtly conservative downstream control actions. In this paper, we propose a two-step strategy for correcting ML-based state estimation. First, an offline computation is used to characterize the uncertainties resulting from the ML module's state estimation, using preimages of perception contracts. Second, at runtime, a risk heuristic is used to choose particular states from the uncertain estimates to drive the control decisions. We perform extensive simulation-based evaluation of this runtime perception correction strategy on different vision-based adaptive cruise controllers (ACC modules), in different weather conditions, and road scenarios. Out of 45 ACC scenarios where the original perception-based control system using Yolo and LaneNet led to safety violations, in 73% of the scenarios, our runtime perception correction preserved safety; our method wouldn't be able to recover 27% of the scenarios where the construction of the preimages of perception contracts is not fully conformant. Further, our runtime perception correction strategy is not overly conservative---on the average only a 2.8% increase in completion time is experienced in the corrected scenarios, with mild interventions.
Original Article
View Cached Full Text

Cached at: 09/22/26, 09:10 AM

# Correcting Learning-based Perception for Safety
Source: [https://arxiv.org/html/2609.22108](https://arxiv.org/html/2609.22108)
###### Abstract

Learning\-enabled perception is important in many autonomous systems\. Unlike traditional sensors, the boundary where ML perception does or does not work is poorly characterized\. Incorrect perception can lead to unsafe or overtly conservative downstream control actions\. In this paper, we propose a two\-step strategy for correcting ML\-based state estimation\. First, an offline computation is used to characterize the uncertainties resulting from the ML module’s state estimation, using preimages of perception contracts\. Second, at runtime, a risk heuristic is used to choose particular states from the uncertain estimates to drive the control decisions\. We perform extensive simulation\-based evaluation of this runtime perception correction strategy on different vision\-based adaptive cruise controllers \(ACC modules\), in different weather conditions, and road scenarios\. Out of 45 ACC scenarios where the original perception\-based control system using Yolo and LaneNet led to safety violations, in 73% of the scenarios, our runtime perception correction preserved safety; our method wouldn’t be able to recover 27% of the scenarios where the construction of the preimages of perception contracts is not fully conformant\. Further, our runtime perception correction strategy is not overly conservative—on the average only a 2\.8% increase in completion time is experienced in the corrected scenarios, with mild interventions\.

###### Index Terms:

Autonoumous Vehicle, Safety, Learning\-based Perception, Cyber\-Physical System

## IIntroduction

Machine learning \(ML\) can play an important role in the creation of cyber\-physical and autonomous systems that operate in complex environments\. Inexpensive sensors coupled with powerful pre\-trained ML models can serve as an attractive alternative to traditional sensing and state estimation methods\. At the same time, it is also well\-known that ML models suffer from fragile decision boundaries and adversarial examples\[[1](https://arxiv.org/html/2609.22108#bib.bib1)\]\. Indeed, a major AI safety concern is the potentially out\-sized impact of this lack of robustness in safety critical applications\. On the other hand, for traditional control systems and cyber\-physical systems \(CPS\), there is a rich body of techniques for model\-based design and analysis of systems that are robust to certain types of disturbances\[[2](https://arxiv.org/html/2609.22108#bib.bib2),[3](https://arxiv.org/html/2609.22108#bib.bib3),[4](https://arxiv.org/html/2609.22108#bib.bib4),[5](https://arxiv.org/html/2609.22108#bib.bib5)\]\. These methods provide rigorous guarantees about safety, robustness, and stability, but only in relatively structured environments and with simple sensor models\. In this paper, we explore the middle\-ground and aim to provide semi\-formal safety guarantees for AI\-enabled CPS\.

![Refer to caption](https://arxiv.org/html/2609.22108v1/figs/combine_images.png)Fig\. 1:Screenshot of simulation of Autonomous Cruise Control \(ACC\) scenarios under different weather conditions\. Under rain and fog, ML\-enabled perception designed to estimate crosstrack error and distance to leading vehicles, can have larger errors\. For example, it cannot detect a vehicle in the the top\-right scenario, and the confidence score \(labeled outside the orange box\) for detecting nearby vehicle is lower\. Our approach corrects for such perception errors for a family of controllers\.Consider a vision\-based Autonomous Cruising Control \(ACC\) system in which a vehicle \(controller\) relies on perception for lane keeping and maintaining safe distance from a leading vehicle\. The perception modulehh\(specifically Yolo\[[6](https://arxiv.org/html/2609.22108#bib.bib6)\]and LaneNet\[[7](https://arxiv.org/html/2609.22108#bib.bib7)\]in this example\) provides estimates of distance to the leading vehicle \(provided there is one\) and crosstrack error with respect to the lane center\. The vehicle controllergguses these observations or estimates to compute the steering, throttle, and brake inputs for the vehicle \(see Figure[2](https://arxiv.org/html/2609.22108#S4.F2)\)\. Setting aside the ML\-based state estimatorhhfor a moment, we observe that the rest of this system is a classical cyber\-physical system \(CPS\)\. If only we could assume that the state estimator were perfecth∗h^\{\*\}or that it came with reasonable error bounds, then a whole arsenal of tools would become available for design and analysis: We could get stability envelops using Lyapunov analysis, we could compute invariants using reachability, and so on\. However, like other machine learning models,hhas implemented in Yolo and LaneNet do not have error specifications and is fragile\. Further, its output estimates depend on environmental factors like lighting and weather in complex ways, which can violate safety of ACC \(see Figure[1](https://arxiv.org/html/2609.22108#S1.F1)\)\. This near slip from grasp motivates us to investigate the following problem: Given a controllerggthat preserves some invariantRRwith perfect perceptionh∗h^\{\*\}, and given a real perception modulehh\(implemented using ML and thus afflicted by fragility, environment, lack of specs\), can we modify or correct the output ofhhso that the resulting system preserves the safety invariantRR\. We call this theperception correction problemand the formal statement appears in Definition[2](https://arxiv.org/html/2609.22108#Thmdefinition2)\.

We propose a solution to this problem usingpreimages of perception contracts\. A perception contractMM\[[8](https://arxiv.org/html/2609.22108#bib.bib8),[9](https://arxiv.org/html/2609.22108#bib.bib9)\]bounds the output of an ML\-based state estimatoras a function of the ground truth state, so that it preserves a closed\-loop invariant such asRR\(see Definition[1](https://arxiv.org/html/2609.22108#Thmdefinition1)\)\. Different representations for perception contracts have been proposed using piece\-wise affine set\-valued functions\[[8](https://arxiv.org/html/2609.22108#bib.bib8)\]and decision trees\[[9](https://arxiv.org/html/2609.22108#bib.bib9)\]\. Perception contracts have been used to verify a vision\-based lane\-keeping system\[[8](https://arxiv.org/html/2609.22108#bib.bib8)\], automated landing for a drone\[[10](https://arxiv.org/html/2609.22108#bib.bib10)\], and distributed formation flight\[[11](https://arxiv.org/html/2609.22108#bib.bib11)\]\. A closely related notion of weakest preconditions has been used to analyze vision\-based taxiing in the probabilistic setting\[[12](https://arxiv.org/html/2609.22108#bib.bib12)\]\. While these ideas have been fruitful for offline verification, at runtime, the ground truth state is not available, and therefore, perception contracts cannot be used for monitoring or for taking corrective actions\.

Our proposed method uses the simple observation that thepreimageM−1M^\{\-1\}of a preception contract \(PPC\)—which outputs the uncertainty in state given an input observation—can be used at runtime\. Specifically, if the set of statesM−1​\(y\)M^\{\-1\}\(y\)corresponding to an observationyyshows no risk of violating the target invariantRR, then no corrective action is needed\. On the other hand ifM−1​\(x\)M^\{\-1\}\(x\)could potentially compromise safety, then some corrective action may be necessary\.

Calculating the preimage perception contract \(PPC\) directly is a complex task, and hence, we use a Bayesian Neural Network \(BNN\) to construct the PPC based on data\.

We then introduce a concept of risk, which defines a monotonous function relative to the safety property across different states\. Our proposed risk heuristic, guides control actions by prioritizing the states within the inferred uncertain set that pose the highest level of risk, as illustrated in Figure[3](https://arxiv.org/html/2609.22108#S4.F3)

By integrating the correction module at runtime, we were able to effectively recover 33 out of the 45 unsafe scenarios, resulting in a 73% recovery rate\. It is important to note that our inability to address all unsafe scenarios may be attributed to conformance violations during the empirical construction of the preimage perception contract \(PPC\) from data\.

Additionally, our evaluations demonstrate that the intervention of the module is minimal and does not impose excessive or overly conservative control measures\. In fact, our experiments reveal only a 2\.8% increase in the time required to complete tasks when our module is integrated\.

In summary, our approach to addressing the runtime perception correction problem involves the incorporation of the preimage perception contract \(PPC\) and a risk heuristic into the existing closed\-loop system\. Initial findings have yielded promising results, indicating that this method is effective in enhancing the system’s safety\.

## IIRelated Work

With the emergence of increasingly sophisticated sensors, such as cameras, LiDAR, and radar, coupled with the development of advanced perception algorithms, the issue of seamlessly integrating these sensors and their associated machine learning\-based algorithms into the controller pipeline has become a prominent subject of research\. In recent studies, innovative methods like imitation learning\[[13](https://arxiv.org/html/2609.22108#bib.bib13)\]and reinforcement learning utilizing RGB cameras\[[14](https://arxiv.org/html/2609.22108#bib.bib14)\]have been introduced to tackle the challenge of vision\-based control for autonomous vehicles\. However, it’s important to note that these approaches are data\-driven, and they do not effectively characterize or bound the potential errors in perception, which ultimately limits their capacity to guarantee safety\.

Recent research efforts have been primarily directed towards ensuring safety through vision\-based control\. In the work by Dean et al\.\[[15](https://arxiv.org/html/2609.22108#bib.bib15)\], the authors synthesized a vision\-based controller for autonomous vehicles and carried out theoretical analyses to establish a robust safety guarantee\. However, their approach involved simplifying the vehicle model to a linear one\. In a subsequent study, as presented in\[[16](https://arxiv.org/html/2609.22108#bib.bib16)\], the author proposed a Measurement\-Robust Control Barrier Function \(MR\-CBF\) that incorporates an optimization method for synthesizing a safe controller\. Dawson et al\.\[[17](https://arxiv.org/html/2609.22108#bib.bib17)\]focused on working with high\-dimensional sensors like LiDAR\. They proposed a method for learning a control Lyapunov function \(CLF\) and a control barrier function \(CBF\) within the observation space, without making assumptions about the perception module\. Additionally, in the work by Chou et al\.\[[10](https://arxiv.org/html/2609.22108#bib.bib10)\], authors use the concept of perception contract to design a controller for a safe landing problem\.\[[18](https://arxiv.org/html/2609.22108#bib.bib18)\], the authors designed a neural network\-based perception module capable of outputting a set of potential states\. Subsequently, they applied contraction theory and robust motion planning algorithms to synthesize a robust and safe vision\-based controller\. This work is closely related to our research; however, our approach involves generating a set of potential states by learning the behavior of a black\-box perception model, in contrast to their method, which has to constructs such set of potential states while designing the perception model from data\.

## IIIRuntime Perception Correction

In this section, we introduce the different parts making up the perception\-based control system and then define the runtime perception correction problem\.

### III\-APerception\-Based Control System

The closed\-loop system, comprises of three components: the plant with dynamicsff, the controllergg, the learning\-based perception modulehh\.

#### Plant dynamics

The state of the physical part of the system is denoted by vectorx∈𝒳⊂ℝnx\\in\\mathcal\{X\}\\subset\\mathbb\{R\}^\{n\}, where𝒳\\mathcal\{X\}is called the state space\. We denote byx⁡\[i\]x\[i\]theit​hi^\{th\}component ofxx\. For example, for an autonomous vehicle, the state vectorxxmay include its position, velocity, heading, distance to front vehicle, etc\.

System\-level safety requirements are given in terms of a set ofunsafe states,𝑈𝑛𝑠𝑎𝑓𝑒⊂𝒳\\mathit\{Unsafe\}\\subset\\mathcal\{X\}, that the overall system must stay away from\. The set of safe states,𝑆𝑎𝑓𝑒=𝒳∖𝑈𝑛𝑠𝑎𝑓𝑒\\mathit\{Safe\}=\\mathcal\{X\}\\setminus\\mathit\{Unsafe\}, is the complement of the unsafe states\.

###### Example 1\.

Consider a vehicle \(ego\) following curvy lanes on a highway with objective of ensuring that the vehicle stays within its lane and does not deviate\. The state vector is defined by valuations of several variables:\{pE,vE,θ,dL\}\\\{p\_\{E\},v\_\{E\},\\theta,d\_\{L\}\\\}, wherepEp\_\{E\}is ego vehicle’s pose \(position and heading\),vEv\_\{E\}is ego vehicle’s velocity,θ\\thetais the angle between ego’s heading and the lane’s heading,dLd\_\{L\}is vehicle’s cross\-track error with respect to the center of the lane\. Since the vehicle enters an unsafe state when a lane departure occurs, then we can define the unsafe states as a set,𝑈𝑛𝑠𝑎𝑓𝑒=\{\(pE,vE,θ,dL\):\|dL\|≥L2\}\\mathit\{Unsafe\}=\\\{\(p\_\{E\},v\_\{E\},\\theta,d\_\{L\}\):\|d\_\{L\}\|\\geq\\frac\{L\}\{2\}\\\}, whereLLis the lane width\.

The evolution of the plant state is described by adynamic functionf:𝒳×𝒰↦𝒳f:\\mathcal\{X\}\\times\\mathcal\{U\}\\mapsto\\mathcal\{X\}, where𝒰\\mathcal\{U\}is thecontrol input space\. In Example[1](https://arxiv.org/html/2609.22108#Thmexample1), the control inputs for the vehicle are throttlet∈\[0,1\]t\\in\[0,1\], brakeb∈\[0,1\]b\\in\[0,1\], and steerings∈\[−1,\+1\]s\\in\[\-1,\+1\], here−1\-1stands for the maximum left steering input and\+1\+1stands for maximum right steering\. Given a statex∈𝒳x\\in\\mathcal\{X\}and an inputu∈𝒰u\\in\\mathcal\{U\}, the next state of the vehiclext\+1=f⁡\(xt,ut\)x\_\{t\+1\}=f\(x\_\{t\},u\_\{t\}\)\.

#### Perception and control

The method developed in this paper targets systems in which the control inputuuis computed in two stages: first, aperception modulehhinterprets the signals generated in statexxvia sensors to produce an observationy∈𝒴y\\in\\mathcal\{Y\}, and then, thecontrollerg:𝒴→𝒰g:\\mathcal\{Y\}\\rightarrow\\mathcal\{U\}takes as input this observationyyand computes the control input \(for the plant\)\. A diagram is shown in Figure[2](https://arxiv.org/html/2609.22108#S4.F2)\. In Example[1](https://arxiv.org/html/2609.22108#Thmexample1),hhcould output cross\-track\-errordLd\_\{L\}as the observationyy, and the controller could applies a hard brake whenever thedLd\_\{L\}is above some threshold\.

The perception modulehhgenerates observationyyfrom the actual plant statexx\. We name a perfect observerh∗:𝒳↦𝒴h^\{\*\}:\\mathcal\{X\}\\mapsto\\mathcal\{Y\}\. In Example[1](https://arxiv.org/html/2609.22108#Thmexample1), ifxxis known, the observationyy\(cross\-track errordLd\_\{L\}\) can be directly obtained fromxxby dropping the extra state components and retainingdLd\_\{L\}as observation\. However, in most autonomous systems, usually state informationxxcannot be directly obtained\. Therefore we rely on an observerhh, which encapsulates the behavior of the sensors that generate the raw signals \(e\.g\., images, LIDAR returns\) as well as the algorithms \(e\.g\., machine learning models, filters\), to generate the observationyyfrom those signals\. The signals also critically depend on certain environmental factors \(e\.g\., lighting, fog, rain, etc\.\)\. The space of all possible such environmental conditions is denoted byℰ\\mathcal\{E\}\. Thus, the perception module is modeled as a functionh:𝒳×ℰ→𝒴h:\\mathcal\{X\}\\times\\mathcal\{E\}\\rightarrow\\mathcal\{Y\}\. In Example[1](https://arxiv.org/html/2609.22108#Thmexample1), to achieve the lane following task, ego vehicle needs to first rely on the camera sensor to generate an RGB image\. Then the analysis of this image is done using a ML algorithm \(E\.g\. LaneNet\[[7](https://arxiv.org/html/2609.22108#bib.bib7)\]\), to produce lane information and subsequently cross\-track\-errordLd\_\{L\}\.

There are several reasons for this two\-stage architecture for the computation ofuu\. First, from the control theory point of view, it is standard to think of the whole pipeline as the composition of a state estimator \(hh\) and a controller \(gg\)\. Loosely speaking, the certainty equivalence principle assures that the optimality of controller design can be preserved by this decomposition, under appropriate assumptions\. The access to privileged state information, like the observables, have also been noted to benefit the development of reinforcement learning\-based controllers\[[19](https://arxiv.org/html/2609.22108#bib.bib19)\]\.

Identifying all possible environmental factors that influencehhcan be a complex problem\. This work is based on the premise that domain experts prescribe the dominant factors inℰ\\mathcal\{E\}with respect to which runtime perception correction should be applied\.

#### Closed\-loop system

The discrete time evolution of theclosed\-loop systemor simply thesystemSS, in an environmente∈ℰe\\in\\mathcal\{E\}, as shown in Figure[2](https://arxiv.org/html/2609.22108#S4.F2), is given by the following:

xt\+1=f⁡\(xt,g⁡\(h⁡\(xt,e\)\)CLOSE\.x\_\{t\+1\}=f\(x\_\{t\},g\(h\(x\_\{t\},e\)\)\.\(1\)
Anexecutionin an environmentee, is a sequence of statesα⁡\(e\)=x0,x1,…,\\alpha\(e\)=x\_\{0\},x\_\{1\},\\ldots,such that for eachtt,xt\+1x\_\{t\+1\}andxtx\_\{t\}satisfy \([1](https://arxiv.org/html/2609.22108#S3.E1)\)\. With respect to an unsafe set𝑈𝑛𝑠𝑎𝑓𝑒\\mathit\{Unsafe\}, the systemSSis safe over an environmentE′⊆ℰE^\{\\prime\}\\subseteq\\mathcal\{E\}and a set of initial statesX0⊆𝒳X\_\{0\}\\subseteq\\mathcal\{X\}, if for eache∈E′e\\in E^\{\\prime\}andx0∈X0x\_\{0\}\\in X\_\{0\}, none of the states inα⁡\(e\)\\alpha\(e\)are in𝑈𝑛𝑠𝑎𝑓𝑒\\mathit\{Unsafe\}, i\.e\., the reachable states ofSSare disjoint from𝑈𝑛𝑠𝑎𝑓𝑒\\mathit\{Unsafe\}\.

###### Definition 1\.

A control invariant setR⊆𝒳R\\subseteq\\mathcal\{X\}for the systemSSis a set such that:

1. 1\.R⊆SafeR\\subseteq\\text\{Safe\}
2. 2\.∀x∈R,∃u∈𝒰​s\.t\.​f​\(x,u\)∈R\\forall x\\in R,\\;\\exists\\,u\\in\\mathcal\{U\}\\;\\text\{s\.t\.\}\\;f\(x,u\)\\in R\.

There has been substantial progress in computing the control invariant sets for systems\. Notable techniques include barrier certificates\[[20](https://arxiv.org/html/2609.22108#bib.bib20),[21](https://arxiv.org/html/2609.22108#bib.bib21)\], formal controller synthesis\[[22](https://arxiv.org/html/2609.22108#bib.bib22)\], control barrier functions\[[23](https://arxiv.org/html/2609.22108#bib.bib23)\], and more recently neural barrier functions\[[24](https://arxiv.org/html/2609.22108#bib.bib24)\]\.

These techniques vary in terms of the levels of knowledge needed aboutf,g,hf,g,h, their computational complexity, and the level of formal guarantee that they provide\. However, our systemSSincludes learning\-enabled perceptionhh, which depends on the environment in complex ways, and therefore, some of the existing techniques will not be directly applicable\. Instead, our sufficient condition for proving safety of the overall system is based on using control invariant sets for anidealized controller\-observer pairg∗,h∗g^\{\*\},h^\{\*\}\. In the two\-staged observer\-controller design paradigm, it is indeed common for the controller design to assume that the observer is at least asymptotically correct\. The following codifies this assumption about such an idealized observer\-controller pair\.

###### Assumption 1\(Safety with perfect observer\-controller\)\.

There exists a perfect observerh∗:𝒳→𝒴h^\{\*\}:\\mathcal\{X\}\\rightarrow\\mathcal\{Y\}and controllerg∗:𝒴→𝒰g^\{\*\}:\\mathcal\{Y\}\\rightarrow\\mathcal\{U\}pair for a given safe invariant setR⊆𝑆𝑎𝑓𝑒R\\subseteq\\mathit\{Safe\}\. That is, for anyx∈Rx\\in R,f⁡\(x,g∗​\(h∗​\(x\)\)∈R𝐶𝐿𝑂𝑆𝐸\.f\(x,g^\{\*\}\(h^\{\*\}\(x\)\)\\in R\.

### III\-BRuntime Perception Correction Problem

Due to environmental uncertainty, sensor noise, and inaccuracies in the Deep Neural Network, the observationh⁡\(x,e\)h\(x,e\)may not be accurate and deviate fromh∗​\(x\)h^\{\*\}\(x\), which could lead to unsafe conditions \(e\.g\., incorrect lane detection causing lane invasion in foggy conditions\)\. As a result, in certain cases, even though the system has a safe controller under perfect perception \(Assumption[1](https://arxiv.org/html/2609.22108#Thmassumption1)\), there’s no guarantee the system is safe with the neural\-network based perception modulehh\.

###### Definition 2\(Runtime perception correction problem\)\.

Given:

- •a perfect observer\-controller pairg∗,h∗g^\{\*\},h^\{\*\}and a corresponding control invariant setRRthat proves safety of the closed\-loop systemSSwith respect to𝑆𝑎𝑓𝑒\\mathit\{Safe\}\.
- •an actual \(learning\-enabled\) observer modulehhthat depends on environment factors inℰ\\mathcal\{E\}\.

The objective is to synthesize a controllerg^:Y↦U\\hat\{g\}:Y\\mapsto Usuch that∀x0∈𝒳0,e∈ℰ0\\forall x\_\{0\}\\in\\mathcal\{X\}\_\{0\},e\\in\\mathcal\{E\}\_\{0\}, the new closed loop system withhh,ggis safe\.

In addition, to ruling out trivial solutions \(e\.g\., always brake and stop\), we have a soft\-requirement that the new system withggandhhshould be minimally invasive overSS\. Metrics for invasiveness are not straightforward to define, and we will consider some examples in Section[V](https://arxiv.org/html/2609.22108#S5)\.

## IVMethodology

Our idea for solving the above problem involves two stages: the first stage infers the uncertainty in the state of the system at runtime from the observations, and the second stage takes control action based on the riskiest states in inferred uncertain set\. For reasons that will become clear below, the first stage is calledPreimage of a Perception Contract \(PPC\)and the latter is called arisk heuristic\. The difficulty of inferring the uncertainty in the actual state from observations is addressed using using the recently invented notion of perception contracts

### IV\-APerception ContractsMM

Safety analysis of machine learning\-enabled and perception\-based control systems is hard since we do not have specifications for the ML modules\. Specification are not only necessary for formal verification, but they form the basis for modern, large\-scale software engineering by enabling unit tests, modular design, and assume\-guarantee reasoning\. In\[[8](https://arxiv.org/html/2609.22108#bib.bib8),[9](https://arxiv.org/html/2609.22108#bib.bib9)\]the authors introduce the notion ofperception contractsfor addressing this problem\. A perception contractMMfor an actual perception modulehh, in the context of a closed loop systemSS, and its control invariant setRR, captures two ideas: First,MMis an over\-approximation ofhh, over at least some part of the relevant environment spaceℰ\\mathcal\{E\}\. This is called theconformanceof the contract\. Second,MMpreserves system\-level correctness ofSSwith respect toRR\. That is, ifMMis plugged\-in toSS, then the resulting closed\-loop system,SMS\_\{M\}, should preserveRR\.

###### Definition 3\.

For a given perception moduleh:𝒳×ℰ→𝒴h:\\mathcal\{X\}\\times\\mathcal\{E\}\\rightarrow\\mathcal\{Y\}, an invariant setR⊆𝒳R\\subseteq\\mathcal\{X\}, and an environmentℰ′⊆ℰ\\mathcal\{E\}^\{\\prime\}\\subseteq\\mathcal\{E\}, a perception contract is a mapM:𝒳→2𝒴M:\\mathcal\{X\}\\rightarrow 2^\{\\mathcal\{Y\}\}that satisfies the two conditions:

1. 1\.Conformance:∀x∈R,e∈E′\\forall x\\in R,e\\in E^\{\\prime\},h⁡\(x,e\)⊆M⁡\(x\)h\(x,e\)\\subseteq M\(x\)\.
2. 2\.Correctness:∀x∈R,f⁡\(x,g⁡\(M⁡\(x\)\)⊆RCLOSE\\forall x\\in R,f\(x,g\(M\(x\)\)\\subseteq R\.

Note that here we use2𝒴2^\{\\mathcal\{Y\}\}to denote a powerset of𝒴\\mathcal\{Y\}\.

In the previous works, the authors have shown that it is possible to construct such contracts from data for vision\-based lane keeping systems and for automated landing systems\. The constructed contracts can indeed be used to rigorously prove system\-level safety \(e\.g\., car does not leave the lane boundaries\)\. In\[[8](https://arxiv.org/html/2609.22108#bib.bib8)\], for example,M⁡\(⋅\)M\(\\cdot\)is a piece\-wise affine set\-valued function constructed from data, and the correctness condition is verified using program analysis\. Owing to the complexity of the actual perception pipelinehhand its complex dependence on the environmentEE, the conformance property is empirically validated based on input\-output data\.

### IV\-BPreimage of Perception ContractsM−1M^\{\-1\}

Inspired by perception contracts, in this work we explore how such contracts can be used at runtime to possibly correct perception errors\. The challenge we face is that the ground truth statexxis not available at runtime to useM⁡\(x\)M\(x\), even though,M⁡\(⋅\)M\(\\cdot\)is computed offline\. Our key idea is to use thepreimageof perception contracts, that is,M−1:Y→2XM^\{\-1\}:Y\\rightarrow 2^\{X\}\. Conceptually, for a given observationy∈𝒴y\\in\\mathcal\{Y\}, its preimageM−1​\(y\)M^\{\-1\}\(y\)gives the set of all possible states that could generateyy, in some environmentℰ′\\mathcal\{E\}^\{\\prime\}\.

For a given perception contractM:𝒳→2𝒴M:\\mathcal\{X\}\\rightarrow 2^\{\\mathcal\{Y\}\}we defineM−1:𝒴→2𝒳M^\{\-1\}:\\mathcal\{Y\}\\rightarrow 2^\{\\mathcal\{X\}\}asM−1​\(y\):=\{x\|y∈M⁡\(x\)\}M^\{\-1\}\(y\):=\\\{x\\ \|\\ y\\in M\(x\)\\\}\. It follows that, if that for any realizabley∈𝒴,y\\in\\mathcal\{Y\},if observer functionhhconforms toMMoverℰ′\\mathcal\{E\}^\{\\prime\}, thenh−1​\(y\)⊆M−1​\(y\)h^\{\-1\}\(y\)\\subseteq M^\{\-1\}\(y\)\.

###### Proposition 1\.

Consider any realizable observationy∈𝒴y\\in\\mathcal\{Y\}, such that there existsx∈𝒳,e∈ℰ′x\\in\\mathcal\{X\},e\\in\\mathcal\{E\}^\{\\prime\}withh⁡\(x,e\)=yh\(x,e\)=y\. Ifhhconforms to the perception contractMM, thenh−1​\(y\)⊆M−1​\(y\)h^\{\-1\}\(y\)\\subseteq M^\{\-1\}\(y\)\.

###### Proof\.

Follows from the definitions\. Consider any realizabley∈𝒴y\\in\\mathcal\{Y\}and leth−1\(y\):=\{x\|∃e∈ℰ′,h\(x,e\)=y\}\.h^\{\-1\}\(y\):=\\\{x\\ \|\\ \\exists e\\in\\mathcal\{E\}^\{\\prime\},h\(x,e\)=y\\\}\.Consider anyx∈h−1​\(y\)x\\in h^\{\-1\}\(y\)\. Since,hhconforms toMMoverℰ′\\mathcal\{E\}^\{\\prime\},h⁡\(x,e\)=y∈M⁡\(x\)h\(x,e\)=y\\in M\(x\), for somee∈ℰ′e\\in\\mathcal\{E\}^\{\\prime\}\. By definition ofM−1M^\{\-1\}, thenx∈M−1​\(y\)x\\in M^\{\-1\}\(y\)\. ∎

![Refer to caption](https://arxiv.org/html/2609.22108v1/figs/original-system.png)Fig\. 2:This is the block diagram of the closed loop systemSS, which is mathematically described in Equation[1](https://arxiv.org/html/2609.22108#S3.E1)![Refer to caption](https://arxiv.org/html/2609.22108v1/figs/perception-correction.png)Fig\. 3:This is the block diagram of the new closed\-loop systemSM​JS\_\{MJ\}with our runtime perception correction module fromyytoy^\\hat\{y\}, which is mathematically described at Equation[6](https://arxiv.org/html/2609.22108#S4.E6)
### IV\-CConstructing PPC from data

Ideally, PPC should achieve perfect conformance, i\.e\., Proposition[1](https://arxiv.org/html/2609.22108#Thmproposition1)should always hold\. However, this perfect conformance requirement of PPC might be too strong for real autonomous system involving perception\. In this paper, instead of directly learningM−1M^\{\-1\}fromMM, we propose a method to empirically learn a PPC from data using Bayesian Neural Network\(BNN\)\. We choose BNN as our model architecture due to its ability to model uncertainty and its ability to generalize from limited training data\.

Let dataset𝒟:=\{\(yi,\(xi,ei\)\)\}\\mathcal\{D\}:=\\\{\(y\_\{i\},\(x\_\{i\},e\_\{i\}\)\)\\\}, whereyiy\_\{i\}is the input data,\(xi,ei\)\(x\_\{i\},e\_\{i\}\)is the output label\. Traditional neural networks output a point estimate for a given input, that is, they produce one deterministic value \(or vector of values\) given an input vector, i\.e\.\(x,e\)=fθ∗​\(y\)\(x,e\)=f\_\{\\theta^\{\*\}\}\(y\), where f is the neural network parameterized by a deterministic optimalθ∗\\theta^\{\*\}, andθ∗\\theta^\{\*\}in practise is obtained by conducting gradient descend to minimize the loss function\.

θ∗=argminθ∑\(xi,ei,yi\)∈𝒟ℒ\(fθ\(yi\),\(xi,ei\)\)\)\\theta^\{\*\}=\\argmin\_\{\\theta\}\\sum\_\{\(x\_\{i\},e\_\{i\},y\_\{i\}\)\\in\\mathcal\{D\}\}\\mathcal\{L\}\(f\_\{\\theta\}\(y\_\{i\}\),\(x\_\{i\},e\_\{i\}\)\)\)\(2\)
A Bayesian Neural Network\(BNN\), in contrast, produces a distribution over possible outputs for an input vector, since the parameters of the BNN are also random variables, i\.e\.x~,e~=fθ~​\(y\)\\widetilde\{x\},\\widetilde\{e\}=f\_\{\\widetilde\{\\theta\}\}\(y\)wherex~,e~,θ~\\widetilde\{x\},\\widetilde\{e\},\\widetilde\{\\theta\}are both random variables\. This probabilistic approach allows for the modeling of uncertainty, which can be essential in many applications, especially when decisions based on the output have significant implications, like in autonomous driving\[[25](https://arxiv.org/html/2609.22108#bib.bib25)\]\.

In this paper, we use a specific kind of BNN, where the prior distribution of the BNN weights follow a Gaussian distribution, i\.e\.,θ∼𝒩⁡\(μ,Σ\)\\theta\\sim\\mathcal\{N\}\(\\mu,\\Sigma\), the optimal weights are parameterized byμ∗,Σ∗\\mu^\{\*\},\\Sigma^\{\*\}\. Similarly to traditional neural networks, in practice, the optimal weight is found by doing gradient descend on the loss function\.

μ∗,Σ∗=argminμ,Σ∑\(xi,ei,yi\)∈𝒟ℒ\(fθ\(xi,ei\),yi\)−KL\(p\(θ\),p\(θ0\)\)\\mu^\{\*\},\\Sigma^\{\*\}=\\argmin\_\{\\mu,\\Sigma\}\\sum\_\{\(x\_\{i\},e\_\{i\},y\_\{i\}\)\\in\\mathcal\{D\}\}\\mathcal\{L\}\(f\_\{\\theta\}\(x\_\{i\},e\_\{i\}\),y\_\{i\}\)\-KL\(p\(\\theta\),p\(\\theta\_\{0\}\)\)

\(3\)whereθ0\\theta\_\{0\}is a normal distribution, i\.e\.,θ0∼𝒩⁡\(0,1\)\\theta\_\{0\}\\sim\\mathcal\{N\}\(0,1\)\. The KL divergence is added to to the loss function to prevent the weight from drifting away from normal distribution\. We use a Gaussian distribution as a prior for weight of the BNN, because the Gaussian prior acts as a natural form of regularization to avoid overfitting, and have been used as a common technique in training the BNN\.\[[26](https://arxiv.org/html/2609.22108#bib.bib26),[27](https://arxiv.org/html/2609.22108#bib.bib27),[28](https://arxiv.org/html/2609.22108#bib.bib28)\]\.

During the inference time of the BNN, we can get a set ofx^,e^\\hat\{x\},\\hat\{e\}given y, simply by sampling the querying the trained BNN N times\. We include bothxxandeeduring training process to increase the training accuracy\. But for the runtime perception correction problem, we only need to infer forxx, so we will drop theeedimension when making upM−1M^\{\-1\}as follows:

M−1​\(y\)=\{xi\|\(xi,ei\)∼fθ∗​\(y\)\}i=1NM^\{\-1\}\(y\)=\\\{x\_\{i\}\|\(x\_\{i\},e\_\{i\}\)\\sim f\_\{\\theta^\{\*\}\}\(y\)\\\}\_\{i=1\}^\{N\}\(4\)

### IV\-DRisk Heuristic

We introduce a notion of risk which defines a monotonic function over states with respect to the safety property\. A similar notion “Monotonic Safety” was used in\[[29](https://arxiv.org/html/2609.22108#bib.bib29)\]to remove the uncertainty of non\-deterministic models for Statistic Model Checking\.

###### Definition 4\.

For a given control invariant setR⊆𝒳R\\subseteq\\mathcal\{X\}, a risk functionJ:𝒳↦ℝ≥0J:\\mathcal\{X\}\\mapsto\\mathbb\{R\}\_\{\\geq 0\}assigns a real value to each state such that for any two safe statesx1,x2∈𝑆𝑎𝑓𝑒x\_\{1\},x\_\{2\}\\in\\mathit\{Safe\}, ifJ⁡\(x1\)≥J⁡\(x2\)J\(x\_\{1\}\)\\geq J\(x\_\{2\}\)and there exists anRR\-preserving controlu¯∈𝒰\\bar\{u\}\\in\\mathcal\{U\}forx1x\_\{1\}, thenu¯\\bar\{u\}also preservesRRforx2x\_\{2\}, that is,𝑂𝑃𝐸𝑁f⁡\(x2,u¯\)\)∈R\.f\(x\_\{2\},\\bar\{u\}\)\)\\in R\.

Informally, if a more risky state preserves the invariantRR, then a less risky state also preserves the same invariant by taking the same control action\. In Examaple[1](https://arxiv.org/html/2609.22108#Thmexample1), consider the ego vehicle following lanes on curvy highway and two statesx1x\_\{1\}=\(pE1,vE=5,θ=0,dL=L2\{p\_\{E\}\}\_\{1\},v\_\{E\}=5,\\theta=0,d\_\{L\}=\\frac\{L\}\{2\}\),x2x\_\{2\}=\(pE2,vE=5,θ=0,dL=0\{p\_\{E\}\}\_\{2\},v\_\{E\}=5,\\theta=0,d\_\{L\}=0\), and a risk functionJ⁡\(x\)=\|dL\|J\(x\)=\|d\_\{L\}\|, which measures the risk as distance to lane center\. It’s obvious thatJ⁡\(x1\)≥J⁡\(x2\)J\(x\_\{1\}\)\\geq J\(x\_\{2\}\)sincex1x\_\{1\}is on the lane boundary whilex2x\_\{2\}is in the lane center, and if the next state ofx1x\_\{1\}with full throttleu=\(t=1,b=0,s=0\)u=\(t=1,b=0,s=0\)under dynamics is inRR, thenx2x\_\{2\}with the same full throttle control will also stay inRR\.

Using the risk heuristicJJ, we can define a corresponding functionCJC\_\{J\}that chooses the riskiest state from the intersection of the PPCM−1M^\{\-1\}and the invariant setRR\. Here we take the intersection because, according to definition[1](https://arxiv.org/html/2609.22108#Thmdefinition1), states outsideRRcannot guarantee the existence of control values that will preserve the invariant setRR\.

CJ​\(M−1​\(y\)\)=argmaxx∈M−1​\(y\)∩RJ​\(x\)\.C\_\{J\}\(M^\{\-1\}\(y\)\)=\\argmax\_\{x\\in M^\{\-1\}\(y\)\\cap R\}J\(x\)\.\(5\)
Finally, we apply the perfect observerh∗h^\{\*\}and subsequently the control functionggto the state returned byCj​\(M−1​\(y\)\)C\_\{j\}\(M^\{\-1\}\(y\)\)to compute the control input to the plant\. The evolution of the resulting corrected closed\-loop systemS𝑀𝐽S\_\{\\mathit\{MJ\}\}is given by \(shown in Figure[3](https://arxiv.org/html/2609.22108#S4.F3)\):

xt\+1=f⁡\(xt,g⁡\(h∗​\(CJ​\(M−1​\(h⁡\(xt,e\)\)\)\)\)\)\.x\_\{t\+1\}=f\(x\_\{t\},g\(h^\{\*\}\(C\_\{J\}\(M^\{\-1\}\(h\(x\_\{t\},e\)\)\)\)\)\)\.\(6\)
We claim thatS𝑀𝐽S\_\{\\mathit\{MJ\}\}indeed preserved the safety invariantRRprovideshhconforms toMM, and therefore, solves the runtime perception correction problem\.

###### Theorem 1\.

Given a preimage of a perception contractM−1M^\{\-1\}for the actual perception functionhhsuch thathhconforms toMMand a risk heuristicJJforRR, the corrected systemS𝑀𝐽S\_\{\\mathit\{MJ\}\}described by Equation \([6](https://arxiv.org/html/2609.22108#S4.E6)\) preserves the invariantRRforℰ′∈ℰ\\mathcal\{E\}^\{\\prime\}\\in\\mathcal\{E\}\.

###### Proof\.

Consider anyxt∈Rx\_\{t\}\\in Rto be the input ofhh\. From Proposition[1](https://arxiv.org/html/2609.22108#Thmproposition1), we know that for anyxt∈𝒳,e∈ℰ′x\_\{t\}\\in\\mathcal\{X\},e\\in\\mathcal\{E\}^\{\\prime\}withh⁡\(xt,e\)=yh\(x\_\{t\},e\)=y, ifhhconforms to the perception contractMM, we have

xt∈M−1​\(h⁡\(xt,e\)\)x\_\{t\}\\in M^\{\-1\}\(h\(x\_\{t\},e\)\)Sincext∈Rx\_\{t\}\\in RthenM−1​\(h⁡\(xt,e\)\)∩R≠∅M^\{\-1\}\(h\(x\_\{t\},e\)\)\\cap R\\neq\\emptyset\. From Equation[5](https://arxiv.org/html/2609.22108#S4.E5), we have the output of the heuristic function, calling itx^\\hat\{x\}, satisfying

x^=CJ​\(M−1​\(h⁡\(xt,e\)\)\)∈\(M−1​\(h⁡\(xt,e\)\)∩R\)⊆R\.\\hat\{x\}=C\_\{J\}\(M^\{\-1\}\(h\(x\_\{t\},e\)\)\)\\in\(M^\{\-1\}\(h\(x\_\{t\},e\)\)\\cap R\)\\subseteq R\.From Assumption[1](https://arxiv.org/html/2609.22108#Thmassumption1), sincex^∈R\\hat\{x\}\\in R, we know that there existsggsuch that

f⁡\(x^,g⁡\(h∗​\(x^\)\)∈RCLOSE\.f\(\\hat\{x\},g\(h^\{\*\}\(\\hat\{x\}\)\)\\in R\.From Equation[5](https://arxiv.org/html/2609.22108#S4.E5), sincex^\\hat\{x\}is chosen to maximize the Risk FunctionJJwithin\(M−1​\(y\)∩R\)\(M^\{\-1\}\(y\)\\cap R\), thenJ⁡\(x^\)≥J⁡\(xt\)J\(\\hat\{x\}\)\\geq J\(x\_\{t\}\)\. From Definition[4](https://arxiv.org/html/2609.22108#Thmdefinition4), we hence have that

xt\+1=f\(xt,g\(h∗\(x^\)\)∈R⊆Safex\_\{t\+1\}=f\(x\_\{t\},g\(h^\{\*\}\(\\hat\{x\}\)\)\\in R\\subseteq Safethus concluding the proof\. ∎

## VAutonomous Cruising Control

In this section, we introduce the details of an autonomous cruise control system \(ACC\) which we will analyze in Section[VI](https://arxiv.org/html/2609.22108#S6)\.

### V\-AAutonomous Cruise Control Problem

The driver assistance feature we study is a combination of lane keeping and adaptive cruise control\. Similar autonomy features commercially go by other names such as AutoPilot, Travel Assist, AutoCruise, etc\. In typical operation, the ego vehicle moves at a set speed behind a lead vehicle\. Both vehicles follow \(possibly curving\) lanes\. If the lead vehicle slows down then the ego vehicle has to maintain safe separation\. The ego vehicle’s autonomy pipeline uses vision\-based perception\. We explore three lane configurations: Track 1, a lane with left curve; Track 2, a lane with right curve; Track 3, a straight lane\.

The state of the whole system includes \(pE,pF,vEp\_\{E\},p\_\{F\},v\_\{E\},vF,θ,dL,dFv\_\{F\},\\theta,d\_\{L\},d\_\{F\}\), wherepEp\_\{E\},pFp\_\{F\}are the pose \(position and heading\) of the ego vehicle and the leading vehicle respectively,vE,vFv\_\{E\},v\_\{F\}are the velocity of the ego vehicle and the leading vehicle respectively,θ\\thetais the angle between ego’s heading and the lane’s heading,dLd\_\{L\}is ego vehicle’s distance to lane center\(also known as cross track error\),dFd\_\{F\}is ego’s distance to the leading vehicle\. The unsafe set is defined as states where the ego vehicle is out of the lane boundaries or there is a collision, i\.e\.𝑈𝑛𝑠𝑎𝑓𝑒=\{\(pE,pF,vE,vF,θ,dL,dF\)\|dL≥L2∨dF≤W\}\\mathit\{Unsafe\}=\\\{\(p\_\{E\},p\_\{F\},v\_\{E\},v\_\{F\},\\theta,d\_\{L\},d\_\{F\}\)\|d\_\{L\}\\geq\\frac\{L\}\{2\}\\lor d\_\{F\}\\leq W\\\}, whereLLis the lane width andWWis the vehicle length\. The observations given by sensors and ML\-based perception will consist of\(θ,dL,dF\)\(\\theta,d\_\{L\},d\_\{F\}\), which have the same meaning as the state variables with the same names above\.

We use CARLA\[[30](https://arxiv.org/html/2609.22108#bib.bib30)\]to create and run the scenarios\. CARLA is an open\-source platform designed specifically to support the development and validation of autonomous driving systems\. For the ego vehicle and the leading vehicle, we use the Carla built\-in Tesla Model 3 vehicle’s dynamics\. We use a reachability tool\[[31](https://arxiv.org/html/2609.22108#bib.bib31)\]to approximate the invariantRR\.

A key advantage of CARLA lies in its ability to create realistic and diverse real\-world scenarios, as well as different weather conditions \(ranging from clear skies and rain to fog and snow\) that could affect the sensor readings\. During runtime testing, we consider six weather conditions ranging from demanding environments such as late night, heavy fog, and rain to clear skies \(optimal driving conditions\): Weather 1 to 5 represent decreasing levels of fog and rain, with Weather 6 characterized by clear skies\. We intentionally chose 5 extreme weather conditions to assess their impact on perceptionhh\.

##### Perceptionhh

We use two learning\-based perception module to detect the front vehicle and the lane: YOLO v8n\[[6](https://arxiv.org/html/2609.22108#bib.bib6)\]and LaneNet\[[7](https://arxiv.org/html/2609.22108#bib.bib7)\]\. YOLO v8n, an evolution of the ’You Only Look Once’ series, is utilized for its swift and accurate object detection capabilities, particularly for identifying front leading vehicles\. It’s known for offering high detection accuracy while ensuring minimal latency\. On the other hand, LaneNet is employed specifically for its prowess in lane detection\. This architecture combines semantic segmentation with instance segmentation to precisely distinguish between individual lane lines, even in challenging conditions\. Together, YOLO v8n and LaneNet form a routine perception backbone, ensuring our autonomous vehicle is consistently aware of its surroundings, which is also a commonly adopted by the research community for autonomous vehicle systems\[[32](https://arxiv.org/html/2609.22108#bib.bib32)\]\. The two modules will output location of leading vehicle and lanes in the camera frame\. Together with a depth camera and the known intrinsic and extrinsic matrix of the camera sensor, we can get the observationy:=\(θ,dL,dF\)y:=\(\\theta,d\_\{L\},d\_\{F\}\)\. We fine\-tuned the two models on a customized Carla image dataset\.

##### Controllergg

We experiment with 3 lateral and 1 longitudinal controller\. The controllers are implementations of racing controllers submitted by leading participants of the GRAIC competition\[[33](https://arxiv.org/html/2609.22108#bib.bib33)\]\. All controllers take the same observations, and produce the control values, namely throttle, brake and steering\.

The lateral controllers we have from GRAIC are a modified verison of Pure Pursuit\[[34](https://arxiv.org/html/2609.22108#bib.bib34)\], a modified version of Stanley\[[35](https://arxiv.org/html/2609.22108#bib.bib35)\]and a simplified kinematic steering control\. The Pure Pursuit algorithm computes the required steering angle based on the vehicle’s lookahead distance; the Stanley controller computes the steering based on the vehicle’s orientation relative to the path and cross\-track\-error; the simplified kinematic steering control uses simple geometric solution to the path\-following problem\.

For longitudinal control, we utilize a PID controller, designed to maintain a constant vehicle speed with high precision\. In scenarios demanding instant decisions, such as potential collisions, we incorporate the Responsibility Sensitive Safety \(RSS\) formula\. This ensures the vehicle brakes promptly and safely, taking into account both the vehicle’s dynamics and the surrounding environment\.

The vehicle controllerggis a combination of both lateral control and longitudinal control\. We name the combination of Pure Pursuit and PID ControllerC1C\_\{1\}, the combination of Stanley and PIDC2C\_\{2\}, the combination of kinematic control and PIDC3C\_\{3\}\.

The combination of three road geometries, six set of weather, and three controllers define 54 different ACCscenarios\. Each scenario can be modeled as a closed loop systemSSsatisfying Equation \([1](https://arxiv.org/html/2609.22108#S3.E1)\) if we are using perceptionhh\. Moreover, each scenario can also be modeled as a new closed loop systemSM​JS\_\{MJ\}satisfying Equation \([6](https://arxiv.org/html/2609.22108#S4.E6)\) if we use both perceptionhhand our runtime perception correction \(M−1,CJ,h∗M^\{\-1\},C\_\{J\},h^\{\*\}\)\.

## VIExperimental Evaluation

We apply runtime perception correction to the ACC scenarios described above and have following observations\.

### VI\-AConstruction of Preimage Perception ContractM−1M^\{\-1\}

To obtain training data for generating preimage perception contract, we run a safe controller across 20 sets of different weather conditions and 3 different lane configurations to collect pairs of ground truth statesxxand observationy=h⁡\(x,e\)y=h\(x,e\)\. We run the controller for 3 hours and collect 5k set of such pairs to make up the dataset𝒟=\{\(yi,\(xi,ei\)\)\}\\mathcal\{D\}=\\\{\(y\_\{i\},\(x\_\{i\},e\_\{i\}\)\)\\\}, whereyiy\_\{i\}is the input feature, and\(xi,ei\)\(x\_\{i\},e\_\{i\}\)is the output label\.

We divide the dataset into 80% training dataset, and the rest 20% for validation, as this is a common practice in neural network training\. We trained the data for 3000 epoches with batch size 32 on a BNN, discussed at Section[IV\-C](https://arxiv.org/html/2609.22108#S4.SS3)\. The BNN has 3 hidden layers with 32, 128, 16 neurons respectively\. We assume the prior distribution of each layer’s weights follow a Gaussian distribution𝒩⁡\(0,0\.3\)\\mathcal\{N\}\(0,0\.3\), we use learning rate 0\.01\. The layers, neurons and prior distributions are hyper\-parameters subject to tuning\. We find such hyper\-parameters after empirical tryouts\.

### VI\-BChoice of Risk Function

The high\-level idea behind the specific risk functionJ:X↦ℝ≥0J:X\\mapsto\\mathbb\{R\}\_\{\\geq 0\}we chose in this case study is that the closer the vehicle is to unsafe state, the more risk the state will have\. This function is monotonically increasing with respect to the inherent risk of the state\.

We define the risk as theL∞L\_\{\\infty\}norm of the weighted inverse of the distance to the unsafe region, taken over each dimension of the state space\.

J⁡\(x\)=‖\[w1x​\[1\]−xu​\[1\]w2x​\[2\]−xu​\[2\]wnx​\[n\]−xu​\[n\]\]‖∞J\(x\)=\\begin\{Vmatrix\}\\begin\{bmatrix\}\\frac\{w\_\{1\}\}\{x\[1\]\-x^\{u\}\[1\]\}\\\\ \\frac\{w\_\{2\}\}\{x\[2\]\-x^\{u\}\[2\]\}\\\\ \\vdots\\\\ \\frac\{w\_\{n\}\}\{x\[n\]\-x^\{u\}\[n\]\}\\\\ \\end\{bmatrix\}\\end\{Vmatrix\}\_\{\\infty\}\(7\)wherexu=\(0,0,0,0,π2,L2,W\)x^\{u\}=\(0,0,0,0,\\frac\{\\pi\}\{2\},\\frac\{L\}\{2\},W\)is the unsafe boundary for the state variables\(pE,pF,vE,vF,θ,dL,dF\)\(p\_\{E\},p\_\{F\},v\_\{E\},v\_\{F\},\\theta,d\_\{L\},d\_\{F\}\)and the corresponding weightw=\(0,0,0,0,0\.2,0\.4,0\.4\)w=\(0,0,0,0,0\.2,0\.4,0\.4\)\.wwis carefully chosen after empirically tryouts to satisfy Definition[4](https://arxiv.org/html/2609.22108#Thmdefinition4)\. The idea behind such choice of weight is because we want to assign high risks to vehicle states where it’s too close to the leading vehicle \(i\.e\.dF=Wd\_\{F\}=Wis where collision will happen\) or cross track error is too high \(i\.e\.dL=L2d\_\{L\}=\\frac\{L\}\{2\}is where out\-of\-lane will happen\) or heading error is too large\(i\.e\.θ=p​i2\\theta=\\frac\{pi\}\{2\}is where ego is almost perpendicular to the lanes\)\.

### VI\-CRuntime Perception Correction corrects 73% unsafe scenarios

We first ran ego with perfect observerh∗h^\{\*\}\(i\.e\., ground truth observation provided by Carla simulator\), and all 54 scenarios result in safe execution, which indicates that Assumption[1](https://arxiv.org/html/2609.22108#Thmassumption1)holds for the three controllers we have\. Next, we ran ego with perception modulehhon the same 54 scenarios\. We discovered that, ego safely finished 9 scenarios while the rest 45 scenarios resulted in an unsafe finish \(e\.g\., either a collision with the front vehicle or steering out of lanes\)\. Last, we ran the ego withhhcomplemented by our runtime perception correction module \(M−1,CJ,h∗M^\{\-1\},C\_\{J\},h^\{\*\}\), and we see that our method maintains safety in 9 scenarios where usinghhalone is safe; furthermore, it can recover 33 out of the 45 \(73 % recover rate\) unsafe scenarios in whichhhfailed\. We looked into the log of 12 scenarios where our approach cannot recover, and we noticed that it’s due to thath−1h^\{\-1\}does not fully conform to the constructed PPC from data\(i\.e\.x=h−1​\(y\)∉M−1​\(h⁡\(x,e\)\)x=h^\{\-1\}\(y\)\\notin M^\{\-1\}\(h\(x,e\)\)for somex∈𝒳,e∈ℰ′x\\in\\mathcal\{X\},e\\in\\mathcal\{E\}^\{\\prime\}in these 12 scenarios\) , which violated the conformance assumption of Theorem[1](https://arxiv.org/html/2609.22108#Thmtheorem1)and thus safety can not be guaranteed\. Detailed results are provided in Table[I](https://arxiv.org/html/2609.22108#S6.T1)\.

TABLE I:Safety evaluation under a variety of road conditions, weather and controllers\. ”X” indicates unsafe scenarios while ”✓” signifies ego can finish the scenario safely![Refer to caption](https://arxiv.org/html/2609.22108v1/figs/ppc-testing.png)\(a\)
![Refer to caption](https://arxiv.org/html/2609.22108v1/figs/ppc-testing-2.png)\(b\)

Fig\. 4:The two graphs show PPC’s prediction on one of the state dimension\(distance to front vehicledFd\_\{F\}\)\. Red dot indicates ground truth distance given byh∗h^\{\*\}, while green dots indicate observed distance given byhh\. Shaded area represented the constructed PPCM−1M^\{\-1\}\.

### VI\-DCorrection Intervention are minimally evasive

![Refer to caption](https://arxiv.org/html/2609.22108v1/figs/correction-comparison.png)Fig\. 5:Vehicle’s steering profile on one particular scenario\.While the runtime perception correction module helps to maintain safety, it can also be integrated without inducing overly unnecessary behaviors, such as frequent stops or excessive adjustments\. We look at the vehicle’s steering profile of one particular example\(Track 1, Weather 6, C3\) in Figure[5](https://arxiv.org/html/2609.22108#S6.F5)\. We noticed that most of the time, our runtime perception correction results in a similar steering value as ones produced by the perfect observerh∗h^\{\*\}\. Most of the time, runtime perception correction module does not result in unnecessary movement except for timestamp 270 to 280, where the curvature of the map slightly increase and our PPC captures a large uncertainty in perception errors, thus results in a large control value\.

Given the large number of experiments, analyzing each scenario by directly comparing control values can be both time\-consuming and potentially misleading due to temporal shifts in these values\. As such, we employ a more informative quantitative metric – time to finish the scenario, which helps in gauging whether the vehicle engages in unnecessary behaviors\. Due to the fact that each track has different length and potentially different time to finish, we compared the time to finish using perceptionhhand our runtime perception correction module \(M−1,CJ,h∗M^\{\-1\},C\_\{J\},h\*\) with time to finish with perfect observerh∗h^\{\*\}\. Then in Table[II](https://arxiv.org/html/2609.22108#S6.T2), we show the percentage of increase in time to finish using our runtime perception correction module\. As presented, the percentage increases in completion time are, for the most part, negligible\. The average percentage increase in time to finish the 33 scenarios is 2\.8%\. This shows that our approach is minimally invasive to the original closed loop system\.

TABLE II:Percentage of increase in time to finish by comparing system use runtime perception correction \(M−1,CJ,h∗M^\{\-1\},C\_\{J\},h\*\) with system that uses perfect observerh∗h^\{\*\}\. ”X” indicates our runtime perception correction module cannot finish that scenario safely
### VI\-EPPC can be empirically constructed by BNN

We evaluated whether the constructed PCC is effective by applying the trained BNN model on scenarios not in its training data, and we see that for 91\.2% of the testing data,h−1h^\{\-1\}conforms to the constructedM−1M^\{\-1\}\(i\.e\.x=h−1​\(y\)∈M−1​\(h⁡\(x,e\)\)x=h^\{\-1\}\(y\)\\in M^\{\-1\}\(h\(x,e\)\)forx,ex,ein the testing dataset\)\. We show an example of how PCC visualizes in Figure[4\(a\)](https://arxiv.org/html/2609.22108#S6.F4.sf1),[4\(b\)](https://arxiv.org/html/2609.22108#S6.F4.sf2)\. We see that, for most of the time, the constructed PCC through BNN always include the ground truth, which satisfies the conformance property ofM−1M^\{\-1\}\. For example, in Figure[4\(a\)](https://arxiv.org/html/2609.22108#S6.F4.sf1), between timestamp 200 and 250, although observed distance, generated by perceptionhh, slightly differ from ground truth distance, the PCC we constructed\(yellow shaded part\) through BNN always contain the ground truth\.

## VIIConclusions

We presented our method, which leverages the preimage perception contract and a risk heuristic, to correct learning\-based perception errors for safety during runtime, assuming perfect conformance\. Empirically, our approach demonstrated the capability to rectify 73% of unsafe Adaptive Cruise Control \(ACC\) scenarios stemming from perception errors, while minimizing unnecessary behavior\.

### VII\-ALimitation

Ideally, by theorem[1](https://arxiv.org/html/2609.22108#Thmtheorem1), we should be able to recover any unsafe scenarios caused by noisy perception module\. However, the empirical result only showed 73% success\. This is due to the fact that constructing the Preimage Perception ContractM−1M^\{\-1\}through BNN does not guarantee 100% conformance\. In other word, Proposition[1](https://arxiv.org/html/2609.22108#Thmproposition1)might not always hold; however, in the same time, constructingM−1M^\{\-1\}using any data\-driven method\(E\.g\. quantile regression\) will face the same issue\.

### VII\-BFuture Directions

In this paper, we extensively test multiple scenarios \(different curvature, weather, and road conditions\) to find particular five adversarial scenarios where perception module fails to ensure safety\. However, manually searching through the whole state space to find an adversarial example is time\-consuming and inefficient\. Moreover, the BNN\-based training method does not always guarantee conformance; therefore, alternate architecture or model to construct teh PPC could be explored\. Our next step is to use the preimage perception contract to infer potential environment variables that can might lead to unsafe scenarios\. This could help indicate the weakness of the controller\.

## References

- \[1\]R\. R\. Wiyatno, A\. Xu, O\. Dia, and A\. de Berker, “Adversarial examples in modern machine learning: A review,” 2019\.
- \[2\]S\. Mitra and D\. Liberzon, “Stability of hybrid automata with average dwell time: an invariant approach,” http://theory\.lcs\.mit\.edu/˜mitras/research/cdc04\-full\.ps\.gz\.
- \[3\]T\. Dreossi, D\. J\. Fremont, S\. Ghosh, E\. Kim, H\. Ravanbakhsh, M\. Vazquez\-Chanlatte, and S\. A\. Seshia, “VerifAI: A toolkit for the formal design and analysis of artificial intelligence\-based systems,” in*31st International Conference on Computer Aided Verification \(CAV\)*, Jul\. 2019\.
- \[4\]A\. Anta, R\. Majumdar, I\. Saha, and P\. Tabuada, “Automatic verification of control system implementations,” in*Proceedings of the Tenth ACM International Conference on Embedded Software*, ser\. EMSOFT ’10\. New York, NY, USA: ACM, 2010, pp\. 9–18\. \[Online\]\. Available: http://doi\.acm\.org/10\.1145/1879021\.1879024
- \[5\]N\. Chan and S\. Mitra, “Verifying safety of an autonomous spacecraft rendezvous mission,” in*ARCH17\. 4th International Workshop on Applied Verification of Continuous and Hybrid Systems, collocated with Cyber\-Physical Systems Week \(CPSWeek\) on April 17, 2017 in Pittsburgh, PA, USA*, 2017, pp\. 20–32\. \[Online\]\. Available: http://www\.easychair\.org/publications/paper/342723
- \[6\]D\. Reis, J\. Kupec, J\. Hong, and A\. Daoudi, “Real\-time flying object detection with yolov8,” 2023\.
- \[7\]D\. Neven, B\. D\. Brabandere, S\. Georgoulis, M\. Proesmans, and L\. V\. Gool, “Towards end\-to\-end lane detection: an instance segmentation approach,” in*2018 IEEE Intelligent Vehicles Symposium \(IV\)*\. IEEE Press, 2018, p\. 286–291\. \[Online\]\. Available: https://doi\.org/10\.1109/IVS\.2018\.8500547
- \[8\]C\. Hsieh, Y\. Li, D\. Sun, K\. Joshi, S\. Misailovic, and S\. Mitra, “Verifying controllers with vision\-based perception using safe approximate abstractions,”*IEEE Transactions on Computer\-Aided Design of Integrated Circuits and Systems*, vol\. 41, no\. 11, pp\. 4205–4216, 2022\.
- \[9\]A\. Angello, C\. Hsieh, P\. Madhusudan, and S\. Mitra, “Perception contracts for safety of ml\-enabled systems,” in*Proc\. of the ACM on Programming Languages \(PACMPL\), OOPSLA*, 2023\.
- \[10\]D\. Sun, B\. C\. Yang, and S\. Mitra, “Learning\-based perception contracts and applications,” 2023\.
- \[11\]C\. Hsieh, Y\. Koh, Y\. Li, and S\. Mitra, “Assuring safety of vision\-based swarm formation control,” 2023\.
- \[12\]C\. S\. Păsăreanu, R\. Mangal, D\. Gopinath, S\. Getir Yaman, C\. Imrie, R\. Calinescu, and H\. Yu, “Closed\-loop analysis of vision\-based autonomous systems: A case study,” in*Computer Aided Verification*, C\. Enea and A\. Lal, Eds\. Cham: Springer Nature Switzerland, 2023, pp\. 289–303\.
- \[13\]Z\. Xu, Y\. Sun, and M\. Liu, “icurb: Imitation learning\-based detection of road curbs using aerial images for autonomous driving,”*CoRR*, vol\. abs/2103\.17118, 2021\. \[Online\]\. Available: https://arxiv\.org/abs/2103\.17118
- \[14\]B\. Tan, N\. Xu, and B\. Kong, “Autonomous driving in reality with reinforcement learning and image translation,”*CoRR*, vol\. abs/1801\.05299, 2018\. \[Online\]\. Available: http://arxiv\.org/abs/1801\.05299
- \[15\]S\. Dean, N\. Matni, B\. Recht, and V\. Ye, “Robust guarantees for perception\-based control,” in*Learning for Dynamics and Control*\. PMLR, 2020, pp\. 350–360\.
- \[16\]S\. Dean, A\. Taylor, R\. Cosner, B\. Recht, and A\. Ames, “Guaranteeing safety of learned perception modules via measurement\-robust control barrier functions,” in*Conference on Robot Learning*\. PMLR, 2021, pp\. 654–670\.
- \[17\]C\. Dawson, B\. Lowenkamp, D\. Goff, and C\. Fan, “Learning safe, generalizable perception\-based hybrid control with certificates,”*IEEE Robotics and Automation Letters*, vol\. 7, no\. 2, pp\. 1904–1911, 2022\.
- \[18\]G\. Chou, N\. Ozay, and D\. Berenson, “Safe output feedback motion planning from images via learned perception modules and contraction theory,” in*International Workshop on the Algorithmic Foundations of Robotics*\. Springer, 2022, pp\. 349–367\.
- \[19\]T\. Chen, J\. Xu, and P\. Agrawal, “A system for general in\-hand object re\-orientation,” 2021\.
- \[20\]S\. Prajna and A\. Jadbabaie, “Safety verification of hybrid systems using barrier certificates,” in*Hybrid Systems: Computation and Control*, R\. Alur and G\. J\. Pappas, Eds\. Berlin, Heidelberg: Springer Berlin Heidelberg, 2004, pp\. 477–492\.
- \[21\]S\. Prajna and A\. Rantzer, “On the necessity of barrier certificates,”*IFAC Proceedings Volumes*, vol\. 38, no\. 1, pp\. 526–531, 2005, 16th IFAC World Congress\. \[Online\]\. Available: https://www\.sciencedirect\.com/science/article/pii/S1474667016367556
- \[22\]T\. Badings, L\. Romao, A\. Abate, and N\. Jansen, “Probabilities are not enough: Formal controller synthesis for stochastic dynamical models with epistemic uncertainty,” 2022\.
- \[23\]A\. D\. Ames, S\. Coogan, M\. Egerstedt, G\. Notomista, K\. Sreenath, and P\. Tabuada, “Control barrier functions: Theory and applications,”*CoRR*, vol\. abs/1903\.11199, 2019\. \[Online\]\. Available: http://arxiv\.org/abs/1903\.11199
- \[24\]C\. Dawson, S\. Gao, and C\. Fan, “Safe control with learned certificates: A survey of neural lyapunov, barrier, and contraction methods,” 2022\.
- \[25\]R\. McAllister, Y\. Gal, A\. Kendall, M\. van der Wilk, A\. Shah, R\. Cipolla, and A\. Weller, “Concrete problems for autonomous vehicle safety: Advantages of bayesian deep learning,” in*Proceedings of the Twenty\-Sixth International Joint Conference on Artificial Intelligence, IJCAI\-17*, 2017, pp\. 4745–4753\. \[Online\]\. Available: https://doi\.org/10\.24963/ijcai\.2017/661
- \[26\]A\. Graves, “Practical variational inference for neural networks,” in*Advances in Neural Information Processing Systems*, J\. Shawe\-Taylor, R\. Zemel, P\. Bartlett, F\. Pereira, and K\. Weinberger, Eds\., vol\. 24\. Curran Associates, Inc\., 2011\.
- \[27\]C\. Blundell, J\. Cornebise, K\. Kavukcuoglu, and D\. Wierstra, “Weight uncertainty in neural networks,” 2015\.
- \[28\]Y\. Gal and Z\. Ghahramani, “Bayesian convolutional neural networks with bernoulli approximate variational inference,” 2016\.
- \[29\]M\. Cleaveland, I\. Ruchkin, O\. Sokolsky, and I\. Lee, “Monotonic safety for scalable and data\-efficient probabilistic safety analysis,” in*2022 ACM/IEEE 13th International Conference on Cyber\-Physical Systems \(ICCPS\)*\. Los Alamitos, CA, USA: IEEE Computer Society, may 2022, pp\. 92–103\. \[Online\]\. Available: https://doi\.ieeecomputersociety\.org/10\.1109/ICCPS54341\.2022\.00015
- \[30\]A\. Dosovitskiy, G\. Ros, F\. Codevilla, A\. M\. López, and V\. Koltun, “CARLA: an open urban driving simulator,”*CoRR*, vol\. abs/1711\.03938, 2017\. \[Online\]\. Available: http://arxiv\.org/abs/1711\.03938
- \[31\]C\. Fan, B\. Qi, S\. Mitra, and M\. Viswanathan, “DRYVR: data\-driven verification and compositional reasoning for automotive systems,”*CoRR*, vol\. abs/1702\.06902, 2017\. \[Online\]\. Available: http://arxiv\.org/abs/1702\.06902
- \[32\]I\. Gog, S\. Kalra, P\. Schafhalter, M\. A\. Wright, J\. E\. Gonzalez, and I\. Stoica, “Pylot: A modular platform for exploring latency\-accuracy tradeoffs in autonomous vehicles,” in*2021 IEEE International Conference on Robotics and Automation \(ICRA\)*\. IEEE Press, 2021, p\. 8806–8813\. \[Online\]\. Available: https://doi\.org/10\.1109/ICRA48506\.2021\.9561747
- \[33\]M\. Jiang, K\. Miller, D\. Sun, Z\. Liu, Y\. Jia, A\. Datta, N\. Ozay, and S\. Mitra, “Continuous integration and testing for autonomous racing software: An experience report from graic,”*IEEE ICRA 2021, International Conference on Robotics and Automation, Workshop on OPPORTUNITIES AND CHALLENGES WITH AUTONOMOUS RACING*\. \[Online\]\. Available: https://par\.nsf\.gov/biblio/10296575
- \[34\]V\. Sukhil and M\. Behl, “Adaptive lookahead pure\-pursuit for autonomous racing,”*CoRR*, vol\. abs/2111\.08873, 2021\. \[Online\]\. Available: https://arxiv\.org/abs/2111\.08873
- \[35\]A\. AbdElmoniem, A\. Osama, M\. Abdelaziz, and S\. Maged, “A path\-tracking algorithm using predictive stanley lateral controller,”*International Journal of Advanced Robotic Systems*, vol\. 17, p\. 172988142097485, 11 2020\.

Similar Articles

Threat-guided Policy-aware Scene Perturbation for Safe Autonomous Driving with Online Reinforcement Learning

arXiv cs.AI

This paper proposes Threat-guided Policy-aware Scene Perturbation (TPSP), a method that augments online reinforcement learning for safe autonomous driving by perturbing scenes in a policy-aware, targeted manner to generate high-value safety-critical experiences. Experiments on NAVSIM v2 show improved safety learning efficiency with about 4 million kilometers of simulated driving data.