{'fraction_non_alphanumeric': 0.029965580076938652, 'fraction_numerical': 0.005331713572248094, 'mean_word_length': 4.81078431372549, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Safety in Augmented Importance Sampling: Performance Bounds for Robust MPPI

This work explores the nature of augmented importance sampling in safety-constrained model predictive control problems. When operating in a constrained environment, sampling based model predictive control and motion planning typically utilizes penalty functions or expensive optimization based control barrier algorithms to maintain feasibility of forward sampling. In contrast the presented algorithm utilizes discrete embedded barrier states in augmented importance sampling to apply feedback with respect to a nominal state when sampling. We will demonstrate that this approach of safety of discrete embedded barrier states in augmented importance sampling is more sample efficient by metric of collision free trajectories, is computationally feasible to perform per sample, and results in better safety performance on a cluttered navigation task with extreme un-modeled disturbances. In addition, we will utilize the theoretical properties of augmented importance sampling and safety control to derive a new bound on the free energy of the system.


I. INTRODUCTION
Safety-critical control is a fundamental problem in dynamical systems, with many problems in robotics, healthcare, and aviation requiring safe operation. In the field of terrestrial and aerial agility there is space to balance the effort between a controller which is safe and risk averse, versus a controller that can execute aggressive maneuvers and recover gracefully while maintaining safety. The latter controller is not risk seeking, but has a built-in recovery mechanism. In this work we will present Safe Augmented Importance Sampling (SAIS) to achieve this goal. SAIS is connected to model-based safecontrol, safe sampling, and safe reinforcement learning.
In the context of safe control, we review some candidate techniques for maintaining the safety of a known system model through feedback. This feedback forms the lynch pin of SAIS, as the feedback mechanism in question will be applied on each sample individually. Potential field methods utilize attractive forces for a given goal state and repulsive forces generated by obstacles. The difficulty in potential field methods lies in optimizing the ratio between the two forces, additionally, the method itself is subject to becoming trapped before narrow passages [13]. Singletary et al. [20] demonstrates that potential functions are a subset of Control Barrier Functions, whereas Control Barrier Functions can be utilized in a more general fashion as a safety filter. Control Barrier Functions (CBFs) have been widely successful in tasks such as bipedal walking [1,6] and automatic lane keeping [5], however for complex constraints, the control is the result of a optimization scheme that is computationally expensive to run in real-time on each sample. Additionally, a particular structure is required to handle systems with high relative degree [25] and in the context of discrete CBFs, even linear systems with linear constraints can result in a non-convex optimization problem [1]. Even in the realm of samplingbased control, CBFs can offer a useful method to improve sample efficiency, but is held back again due to computational complexity [21]. Embedded barrier state (BaS) methods developed by Almubarak et al. [2] append the state space with the state of a barrier function, then utilize a Lyapunov stability criterion, satisfied by an optimal controller, to ensure safety through stabilization of the appended model. Through similar arguments, Almubarak et al. [3] proposes using discrete time barrier states in trajectory optimization settings and shows that the safety embedding technique exhibits great performance improvements over penalty methods which, implicitly, result in similar cost functions. This method is applicable to general nonlinear systems, and can combine a variety of nonlinear constraints at the expense of sensitivity to gradients of the barrier state dynamics, time discretization, and model error. In the proposed work, we utilize discrete embedded barrier state control as a means of safety in sampling, due to relaxation in problem assumptions, computational complexity, and ability to combine a large number of disjoint unsafe regions.
Safety in sampling based model predictive control has received recent attention [12,26], due to the high performance capabilities of sampling-based MPC [24]. Additionally, sampling based trajectory optimization shares a close connection with safe model-based reinforcement learning, which can be loosely categorized into two categories: safety within the optimization metric, and safety in sample exploration [10]. Safety in importance sampling falls into the latter category, in the same vein as the work by Berkenkamp et al. [8] which utilizes Lyapunov-based stability metrics to explore the policy space, and Thananjeyan [22], who utilize sampling to iteratively improve the policy for a nonlinear system. In the attempt to unify the safety critical control and sampling-based MPC, current attempts fall short in terms of computational efficiency, sample efficiency, and theoretical guarantees. In this paper we present a novel method of incorporating safety into augmented importance sampling. Utilizing the framework presented in Gandhi et al. [9], we are able to incorporate a variety of safety-critical control techniques to enable sample efficiency, and improve the safety-task violation rate of each sample even with large unmodeled disturbances to the system. We show three key contributions in this work: 1) Demonstration of discrete embedded barrier states as a superior method for safety-critical control in augmented importance sampling.

2) Derivation of a new bound for Robust Model-Predictive
Path Integral Control (RMPPI) performance that can be localized and improved through safety-guarantees. 3) Application of safety-critical control in sampling for navigating through a cluttered environment.

A. Problem Formulation
Consider the discrete, nonlinear dynamical system in Equation (1): where, at a time step k ∈ R + , x ∈ D ⊂ R n , u ∈ R m , w ∈ R n , |w| < D, D > 0, and F : Within the domain D, we can define a safe set C ⊂ D.
The goal of the model predictive controller will be to achieve an objective in finite time while keeping the state trajectory, ., x T } inside the safe set C. Specifically, the model predictive control problem considers minimizing the cost functional subject to safety state constraints and control limits with u τ = {u 0 , u 1 , ..., u T −1 }. Here φ is a terminal cost, and q is a nonlinear, potentially time varying state cost with a quadratic control cost penalty. λ is known as the inverse temperature and Σ ∈ R m×m is a positive definite control penalty matrix. For the safety state constraints, we consider the superlevel set C ⊂ R n defined by a continuously differentiable real valued function h : D ⊂ R n → R such that the set C, its interior C • , and boundary ∂C are defined respectively as To ensure safety, the safe set C needs to be rendered controlled forward invariant. The notion of forward invariance of the safe set C with respect to the safety-critical dynamical system (1) can be formally defined as follows: Definition II.1. The set C ⊂ R n is said to be controlled forward invariant for the dynamical system x k+1 = f (k, x k , u k ), if, for all x 0 ∈ C, there exists a feedback control Notice that the definition of controlled forward invariance assumes that that the dynamics are evolving without the unknown disturbance w ∈ R n , this assumption is important when developing a safety mechanism to use in Augmented Importance Sampling (AIS), and the framework of RMPPI will allow us to address the disturbances caused by w. Next, we briefly review three methods for safety critical control and their applicability in sampling-based model predictive control.
B. Safety Critical Control 1) Control Barrier Functions: Motivated by barrier functions in optimization literature, barrier certificates [16,17] were developed as a viable method of model validation and set invariance certification. Influenced by the development of Control Lyapunov Functions (CLFs) for stability and forward invariance, Control Barrier Functions (CBFs) were proposed by Wieland and Allgöwer [23]. Classically, barrier certificates and CBFs in [19,4] use barrier functions similar to those popular in optimization. The fundamental idea is to render the decay rate of some barrier function, h, negative definite in duality to Lyapunov arguments. This enforces forward invariance of the safe set. Later, Zeroing Control Barrier Functions (ZCBF) were proposed which aim to directly ensure positive definiteness of the safety function by making its rate of change positive definite, then relaxing the constraint to allow a limited negative rate of change [5]. We formally define the Continuous Control Barrier Function in the following definition [6].
Definition II.2. For the control system:ẋ = f (x) + g(x)u, let C ⊂ D ⊂ R n be the super level set of a continuously differentiable function h : D → R. h is a control barrier function if there exists an extended class K ∞ function α such that sup u∈R m L f h(x) + L g h(x)u ≥ −α(h(x)). The set of control values that enforce the controlled forward invariance of C is the set: Given a barrier function h, continuous time CBFs can often be solved in a closed-form for simple linear constraints and solved with quadratic programs (QPs) for more complex constraints. Unfortunately, one of the difficulties of control barrier functions is the search for an appropriate h, along with solving and ensuring the feasibility of the accompanied optimization problem. Moreover, similar to CLFs, restrictions in the form of high relative degree appear. Under mild assumptions, these restrictions can be overcome with Exponential CBFs. Exponential CBFs define the dynamics of the safe set function h(x) as a linear system that is controlled such that the closed loop system matrix has strictly negative eigenvalues, and the initial condition satisfies Theorem 8 in Ames et al. [6]. This method can be combined with Control Lyapunov functions to simultaneously optimize task performance and manage safety. The algorithm comes at the cost of solving a QP at each timestep, which is computationally infeasible to perform in sampling-based control.
2) Embedded Barrier States: Almubarak et al. [2] proposed embedded barrier states (BaS) to transform the safety objective into a performance objective by embedding the state of the barrier into the model of the safety-critical system. The barrier function's rate of change is controlled along the system's state in lieu of enforcing this rate through an inequality hard constraint. In [2], the barrier state embedded model, referred to as the safety embedded model, is asymptotically stabilized, which implies safety due to boundedness of the barrier state. Next, discrete barrier states (DBaS) were proposed to perform trajectory optimization [3], which greatly simplified the problem formulation. Namely, for the undisturbed system in (1) and the safety constraint (3), the barrier function B : With this, a barrier function over x can be defined as β(x k ) := B h(vx k ) . In the discrete settings, the barrier state is simply constructed to be For multiple constraints, multiple barrier functions can be added to form a single barrier [3] or multiple barrier states. Then, the barrier state vector β ∈ B ⊂ R n β , where n β is the dimensionality of the barrier state vector, is appended to the dynamical model resulting in the safety embedded system: One of the benefits of a safety embedded model is the direct transmission of safety constraint information to the optimal controller. This prevents two separate algorithms from fighting one another for control bandwidth, i.e. the controller attempting to maximize performance and a safety filter attempting to maximize safety. This comes at a cost of the user having to specify the weighting between task performance and safety. For the model predictive control problem in this work, the following proposition [3] depicts the safety guarantees provided by the embedded barrier state method.
3) Constrained Trajectory Optimization: Trajectory optimization techniques have also been used in conjunction with penalty methods to enforce safety. Consider a minimization problem Since safety requires h > 0, this optimization can be viewed as optimization with safety constraints. A widely used method to solve this problem is to minimize the Powell-Hestens-Rockafellar (PHR) Augmented Lagrangian (AL) associated with penalty functions [15,18,11]: where µ > 0 and λ ≥ 0 are the penalty parameter and Lagrange multiplier, respectively, and ||t|| 2 + = max(0, t 2 ), with t ∈ R. This problem can be solved iteratively by repeating the following two steps. In the first step, L A is approximately minimized over x, and in the second step, λ and µ are updated. The update law of λ can be obtained by comparing first order optimality condition of Lagrangian, L = f 0 + λh 0 , and that of L A : ∂x , From these two equations the update law can be deduced as The penalty parameter µ is monotonically increased when improvement of constraint violation is not satisfactory. DDP and iLQG can be used to solve the first step of the problem of dynamical systems [14]. Comparison Example (Point Mass Omnidirectional Robot): In this example, we consider a point mass omnidirectional robot with actuation limits [−15, 15] m/s to track a given unsafe trajectory which emulates a potentially unsafe sample from MPPI. We add zero mean independent and identically distributed (i.i.d.) Gaussian noise with standard deviation of 10 in the control channel. This simulates the exploration noise utilized in sampling-based trajectory optimization. We aim to compare the aforementioned techniques in tracking the unsafe trajectory through a safe feedback control policy. We utilize Exponential CBFs as a safety filter around iLQG, barrier state embedded iLQG [3] and AL-iLQG [7] to this simple tracking problem. In the upcoming figures, the initial point and the target is shown with "x" and "star", respectively.
In Figure 1, the ECBF safety filter is able to track to the target in the nominal case, but is unable to maintain safety with large control deviations. In Figure 2, BaS-iLQG safely handles relatively high disturbances in the control, with 0 violations, and successfully reaches the target. Additionally, this method rapidly converges to track the given trajectory as soon as it avoids the obstacle. Finally, in Figure 3, the nominal trajectory is able to track the reference with minimal required deviation from the obstacle, but when perturbed with noise, this results in poor safety performance.
Discrete embedded barrier state control appears to be the least restrictive of the aforementioned algorithms in terms of both computational complexity and problem formulation, making it an ideal candidate for sampling based model predictive control and motion planning. Note that the inherent sensitivity of discrete barrier states to time discretization may cause it to jump the barrier. This can be partially remedied with indicator functions, i.e. crash costs, in sampling based methods to reject such violating trajectories during the optimization [3]. Utilizing crash costs to penalize unsafe trajectories is similar to penalty methods, which utilize an equivalent cost function, but as as discussed earlier, barrier states play a key role as part of the dynamics and are available directly feedback controller to perform feedback.

III. SAFETY IN SAMPLING BASED CONTROL A. Information Theoretic Model Predictive Control
We briefly review Free Energy, Relative Entropy, and the connection to model predictive control. Additional details can be found in Williams et al. [24]. First, we define free energy with the following expression: λ is the inverse temperature. S is the cost-to-go function, which takes in initial condition x 0 and set of random variables that generate a sequence of controls V = {v 0 , v 1 , ..., v T −1 }, which in turn generate a trajectory x τ evaluated with the terminal and state cost functions φ and q respectively. The probability measure P is utilized to sample the controls of the system when computing the free energy. We can upper bound the free energy using Jenson's Inequality, Equation (12) now represents an optimization problem. Assume Q * is the optimal control distribution, and when the free energy is computed with respect to S and Q * , the free energy is minimized. This optimal free energy is upper bounded by the free energy computed from another distribution Q, summed with the KL-divergence between Q * and Q * . In practice, MPPI assumes a form of the optimal distribution Q * , which cannot be directly sampled from. Instead the KL-divergence term is utilized as an information theoretic metric that is used to drive a controlled distribution Q closer to the optimal: The authors in Williams et al. [24] show that the solution to Equation (13) is equivalent to solving u * t = q * (V )v t dV , MPPI utilizes iterative importance sampling to approximate samples from the optimal distribution.

B. MPPI on Barrier State Embedded Dynamics
A first step to incorporating safety into MPPI is by directly solving the model predictive control problem for the safety embedded model (6). The constrained optimization problem is transformed to Given the initial conditionx 0 , initial control sequence u τ , we can write the optimal control update as: This formulation allows MPPI to combine the optimization of task performance with safety, however, as we will see in Section V, some limitations exist. In general, there are scenarios where we lose the ability to explore if the dynamics are too close to an obstacle or in an undesirable region of state space, demonstrated in Gandhi et al. [9]. Vanilla MPPI with discrete barrier state augmented dynamics is still subject to the same failure conditions as MPPI without barrier states. This motivates the next section: applying safety in the importance sampler.

IV. SAFETY IN AUGMENTED IMPORTANCE SAMPLING
In this section, we outline our primary approach to handling safety in importance sampling. We begin with the formulation of a safety embedded model, which includes an embedded barrier state, that, when bounded, ensures feasibility of the safety problem.
First we define our two systems, one real with state x, and one nominal with state x * , These dynamics are identical to Equation (1), with the addition of the nominal state and tracking controller and multivariate Gaussian noise ∈ N (0, Σ) acting directly on the control channel. Note that between these two systems, the same t is applied to both systems when simulating them forward. The difference between the Augmented Importance Sampling in the original work, and the one described here is the underlying tracking controller. Gandhi et al. [9] utilized a global exponentially stable tracking controller, which is difficult to design for some nonlinear systems. In this case, we will utilize a feedback controller that assures controlled forward invariance of the nominal trajectory within a specified safe region, i.e, x t ∈ C ⊂ D ⊂ R n , ∀t > 0. We will design this controller utilizing discrete embedded barrier states, with iLQG as the optimization scheme to compute feedback gains that can be applied on each sample.
Utilizing this novel scheme for enabling safety in sampling, we can provide a theorem that can be used to compute free energy growth in the system. Lemma 1. Let F M C (S, P, x 0 , λ) be the estimate of the free energy of the real system, F M C (S, P, x * 0 , λ) be the estimate of the free energy of the nominal system, and E V M be the upper bound on the uncertainty of the free energy estimates. Given a nominal control sequence u * τ , define B to be a tube of radius R defined around the nominal trajectory x τ . Define a new safeset C * = B ∪ C. Let L q be the Lipshitz constant of the state cost function q(x) in C * , and L φ let be the Lipshitz constant of the terminal cost function φ(x) in C * . Finally, , and assume that there exists a safe controller K safe such that Equation (16) is controlled forward invariant with respect to C * . Then, the growth of the free energy of the real system is bounded by: Proof: From the a given trajectory x τ , let us analyze the cost-to-go differential between the nominal trajectory x * τ and x τ : where e t is the difference in given state and nominal state at time t. Let us now take a first order Taylor expansion: Utilizing the safe controller K safe , the error dynamics can be bounded by the tube radius: ||e k || 2 < R. We can pull out the terms that represent the cost-to-go for the nominal and given trajectories, and set up an inequality by removing the higher order terms and inserting the bound on e k and our local Lipshitz constants L φ and L q : Analogous to the proof of lemma 3 in Gandhi et al. [9], we can use the bound on the cost-to-go of the real state to bound the free energy of the real system: The rest of the proof is identical to Gandhi et al. [9]. Lemma 1 implies that the last term in the inequality Equation (17) can be computed using local Lipshitz constants that are computed about each nominal trajectory. This is a key difference from the previous result, as large crash costs utilized in RMPPI forced the Lipshitz constants near obstacles to be very large. Since there was no guarantee on the domain around which each sample would explore, it was impossible to localize the bounds on a per trajectory basis, generating large upper bounds that were only meaningful near the obstacles. In contrast, this result allows us to compute local bounds at each iteration, to assess how close the real system is to task failure in other costs. Additionally, if the tube around the nominal trajectory intersects the unsafe set C, we have additional information regarding the performance of the vehicle.

A. Safety Augmented Robust Model Predictive Path Integral Control
In this section we present an algorithm for safety augmented importance sampling, which is then utilized in a framework we call Safety Augmented Robust Model Predictive Path Integral Control (SA-RMPPI).
Algorithm 1: Safety Augmented Importance Sampler (SAIS) Given: F, K safe , R: Dynamics, safe controller, tube radius; q, φ, Σ, T , N : Cost function and sampling parameters; λ, α: Temperature and cost threshold Input : x 0 , x * 0 , U , K: Real/nominal state, IS sequence, feedback; return S nom , S real , E; Safe Augmented Importance Sampling ?? 1, together with the nominal state propagation and safe tracking controller, is the next step in a framework that can now optimize safety constraints while dealing with out-of-distribution disturbances from w. Note that depending on the region of attraction of the safe controller, as well as the magnitude of out-of-distribution disturbances, the theoretical bound on free energy may be violated.

V. EXPERIMENTS
In this section we run a point mass omnidirectional robot with through a cluttered environment with large disturbances in the velocity term. All experiments were able to be run in real time on an Intel i5-4670K with a GTX 1080 graphics card. In these experiments, the control limitations are set to ±5 m/s, with instantaneous velocity disturbances pulling from a Gaussian distribution with variance up to 100 m/s. The aim of these comparisons is to demonstrate the capabilities of this framework to 1.) outperform MPPI simply augmenting the dynamics and optimizing the barrier state, 2.) perform safe sampling under extreme disturbance conditions that are outof-distribution for the controller parameters for a system that is further constrained by control limits.
The experiment consists of a navigation task through an obstacle field of 30 obstacles of varying radii, creating a map that has many local minima where the system can become stuck, as well as narrow passages that must be safely traversed. The metrics in Table I are safety percentage and root mean squared error (RMSE) in meters from the goal state. The safety percentage is defined as the number of samples in the Monte Carlo study that crashed into an obstacle. In all experiments, MPPI satisfaction of the safety constraint led to the controllers reaching the goal state within a one meter radius.

A. Barrier State MPPI (BaS-MPPI)
For this experiment, MPPI is directly optimizing the barrier state to enforce safety in MPC. We can see in Table I that the undisturbed case resulted in a near perfect success rate and low RMSE as expected. However, when the standard deviation of velocity disturbances were increased, the safety rate of the controller dropped considerably. Note, that since these are out-of-distribution disturbances effecting the state directly, the only response the controller is able to manage is through MPC, and the ability to quickly replan. Here we see a fatal flaw in BaS-MPPI, which is that in off-nominal conditions, safety guarantees quickly dissipate. In Figure 5, the left-most plots are each of the 100 samples of the navigation problem. We can clearly see that the narrow vertical passage in the center of the field was a common crash location, as the system did not have the ability to recover when accelerated too close to the obstacle. This issue is compounded in the higher variance example in the bottom left plot. Here, for some of the samples, the system is able to avoid the obstacles, but makes far less progress towards the goal, and ultimately crashes in the first few passageways. Figure 6 shows the mean and standard deviation of the state velocities of the robot. BaS-MPPI experienced larger velocities and larger variance of velocity throughout the experiments, which lead to faster reaching times, but less safe control.

B. Safety Augmented RMPPI (SA-RMPPI)
With SA-RMPPI, we can see the performance gains in terms of safety in Table I. Even as the variance increases to 100, the algorithm is able to maintain a 15-24% improvement in safety versus BaS-MPPI. This performance benefit comes a cost, one being higher computational complexity due to sampling a dual system, and two a relatively higher RMSE when approaching the goal state. This loss in performance could be due to the impact of the feedback controller in sampling, attempting to deviate samples away from obstacle even when the system is safe, or due to the conservativeness generated by SA-RMPPI for this task. Because the system is undergoing large disturbances, we noticed in our experiments that it would a longer time horizon to meet the target, but was able to maintain safety. Figure 6 demonstrates the lower velocity mean and tighter variance of velocity through the experiments. The velocity graph also helps explain the tighter distribution of trajectories when compared to BaS-MPPI. In Figure 4, we can see the effects of large state disturbances in SA-RMPPI. When the nominal state deviates from the real state, the feedback mechanism activates to attempt to maintain safety and return back to the nominal. In a cluttered environment, these tasks are often conflicting, and since the iLQG solution is solved about the nominal trajectory, the domain of attraction of the linear feedback gains may not be large enough to encompass all samples. We see that near the initial conditions, the feedback trajectories point away from obstacles and towards the nominal trajectory, but towards the end of the time horizon, the samples often collide with the obstacles. The safety mechanism provided by discrete barrier states relies on an accurate state linearization, and in practice this can be violated even for a simple system with highly nonlinear constraints. Note, that even though the dynamical system is a linear point mass, the barrier state dynamics are highly nonlinear. Since the barrier state utilizes an exponential barrier function, the solution is also highly sensitive to the gradients computed along the nominal trajectory. This example shows an extreme cause of disturbances and how the system attempts to recover via safe augmented importance sampling.

VI. CONCLUSIONS
In this work, we investigated the enforcement of safety within sampling based optimal control, namely Model Pre-   dictive Path Integral control (MPPI). We reviewed and compared three methods, namely control barrier functions (CBFs), embedded barrier states (BaS), and augmented Lagrangian optimization under moderate control disturbances to determine a suitable method for enforcing safety in sampling. As discrete barrier states showed promising performance and computational advantages over the other methods, we proposed implementing MPPI directly on the safety embedded model predictive control problem. Nonetheless, although naively optimizing with BaS provides improved performance over penalty methods with indicator functions as shown in [3], it is subject to the same failure conditions as vanilla MPPI and is not guaranteed to be robust against system disturbances. Therefore, using barrier states in augmented importance sampling to generate safe feedback control with respect to a nominal state when sampling was proposed. Moreover, we derived computing a new bound on the free energy growth of the augmented safety embedded system, which utilizes Simulation examples under various system disturbances were presented which showed a greatly improved performance in terms of achieving the target safely.