원시데이터 수집 시스템
선정목록으로

Sablas: Learning Safe Control for Black-Box Dynamical Systems

간접 관련 모빌리티 소재 · (3) 자동차 인테리어 소재 (4) 카시트 모듈

기본 정보

저자
  1. Zengyi Qin — Massachusetts Institute of Technology, Cambridge, MA, USA
  2. Dawei Sun — University of Illinois at Urbana-Champaign, Champaign, IL, USA
  3. Chuchu Fan — Massachusetts Institute of Technology, Cambridge, MA, USA
DOI
10.1109/lra.2022.3142743
저널
IEEE Robotics and Automation Letters
발행년도
2022
발행기관
Institute of Electrical and Electronics Engineers
피인용수
29
라이선스
cc-by
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1109/lra.2022.3142743
토픽
Fuel Cells and Related Materials
OpenAlex ID
W4205626291

평가 내용

관련도
간접 관련
사업분야
모빌리티 소재 · (3) 자동차 인테리어 소재
부 분야
(4) 카시트 모듈
R&D 측면
부품·응용 설계
확신도
0.70
근거 용어
safe control, black-box dynamical systems, autonomous robotic systems, self-driving cars, collision avoidance
판단 근거
본 논문은 블랙박스 동역학 시스템에서 안전한 제어 정책을 학습하는 알고리즘(SABLAS)을 다루며, 이는 자율주행차나 로봇의 충돌 방지 및 안전 제어 시스템 연구에 활용될 수 있습니다.
R&D 활용 포인트
자동차 인테리어 및 모빌리티 부품(카시트 모듈 등)이 포함된 자율주행 시스템의 안전 제어 로직 및 충돌 회피 알고리즘 고도화에 응용 가능합니다.
평가 입력
본문 51,648자 중 30,032자 발췌

초록

Control certificates based on barrier functions have been a powerful tool to generate probably safe control policies for dynamical systems. However, existing methods based on barrier certificates are normally for white-box systems with differentiable dynamics, which makes them inapplicable to many practical applications where the system is a black-box and cannot be accurately modeled. On the other side, model-free reinforcement learning (RL) methods for black-box systems suffer from lack of safety guarantees and low sampling efficiency. In this paper, we propose a novel method that can learn safe control policies and barrier certificates for black-box dynamical systems, without requiring for an accurate system model. Our method re-designs the loss function to back-propagate gradient to the control policy even when the black-box dynamical system is non-differentiable, and we show that the safety certificates hold on the black-box system. Empirical results in simulation show that our method can significantly improve the performance of the learned policies by achieving nearly 100% safety and goal reaching rates using much fewer training samples, compared to state-of-the-art black-box safe control methods. Our learned agents can also generalize to unseen scenarios while keeping the original performance. The source code can be found at <uri xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">https://github.com/Zengyi-Qin/bcbf</uri> .

본문 51,648자

본문 펼치기
## SABLAS: Learning Safe Control for Black-Box Dynamical Systems Zengyi Qin, Dawei Sun, and Chuchu Fan _Abstract_ —Control certificates based on barrier functions have been a powerful tool to generate probably safe control policies for dynamical systems. However, existing methods based on barrier certificates are normally for white-box systems with differentiable dynamics, which makes them inapplicable to many practical applications where the system is a black-box and cannot be accurately modeled. On the other side, model-free reinforcement learning (RL) methods for black-box systems suffer from lack of safety guarantees and low sampling efficiency. In this paper, we propose a novel method that can learn safe control policies and barrier certificates for black-box dynamical systems, without requiring for an accurate system model. Our method re-designs the loss function to back-propagate gradient to the control policy even when the black-box dynamical system is non-differentiable, and we show that the safety certificates hold on the black-box system. Empirical results in simulation show that our method can significantly improve the performance of the learned policies by achieving nearly 100% safety and goal reaching rates using much fewer training samples, compared to state-of-the-art black-box safe control methods. Our learned agents can also generalize to unseen scenarios while keeping the original performance. The source code [can be found at https://github.com/Zengyi-Qin/bcbf.](https://github.com/Zengyi-Qin/bcbf) _Index Terms_ —Robust/adaptive control, robot safety. I. INTRODUCTION UARANTEEING safety is an open challenge in designing control policies for many autonomous robotic systems, # G ranging from consumer electronics to self-driving cars and aircrafts. In recent years, the development of machine learning (ML) has created unprecedented opportunities to control modern autonomous systems with growing complexity. However, ML also poses great challenges for developing high-assurance autonomous systems that are provably dependable. While many learning-based approaches [1]–[4] have been proposed to train controllers to accomplish complex tasks with improved empirical performance, the lack of safety certificates for the learningenabled components has been a fundamental hurdle that blocks the massive deployment of the learned solutions. Manuscript received September 9, 2021; accepted January 5, 2022. Date of publication January 13, 2022; date of current version January 24, 2022. This letter was recommended for publication by Associate Editor Stephan Weiss and Editor Clement Gosselin upon evaluation of the reviewers’ comments. This work was supported by the Defense Science and Technology Agency in Singapore. _(Corresponding author: Chuchu Fan.)_ Zengyi Qin and Chuchu Fan are with the Massachusetts Institute of Technology, Cambridge, MA 02139 USA (e-mail: [qinzy@mit.edu;](mailto:qinzy@mit.edu) [chuchu-](mailto:chuchufan1990@gmail.com) [fan1990@gmail.com).](mailto:chuchufan1990@gmail.com) Dawei Sun is with the University of Illinois at Urbana-Champaign, Cham[paign, IL 61820 USA (e-mail: daweis2@illinois.edu).](mailto:daweis2@illinois.edu) This letter has supplementary downloadable material available at [https://doi.org/10.1109/LRA.2022.3142743, provided by the authors.](https://doi.org/10.1109/LRA.2022.3142743) Digital Object Identifier 10.1109/LRA.2022.3142743 For decades, mathematical control certificates has been used as proofs that the desired properties of the system are satisfied in closed-loop with certain control policies. For example, Control LyapunovFunction[5],[6]andControlContractionMetrics[7]– [10] ensure the existence of a controller under which the system converges to an equilibrium or a desired trajectory. Control Barrier Function [11]–[17] ensures the existence of a controller that keeps the system inside a safe invariant set. Classical control synthesis methods based on Sum-of-Squares [12], [18]–[20] and linear programs [21], [22] usually only work for systems with low-dimensional state space and simple dynamics. This is because they choose polynomials as the candidate certificate functions, where low-order polynomials may not be a valid certificate for complex dynamical systems and high-order polynomials will increase the number of decision variables exponentially in those optimization problems. Recent data-driven methods [9], [17], [23], [24] have shown significant progress in overcoming the limitations of the traditional synthesis methods. They can jointly learn the control certificates and policies as neural networks (NN). However, data-driven methods that can generate control certificates still require an explicit (or white-box) differentiable model of the system dynamics, as the derivatives of the dynamics are required in the learning process. Finally, many works study the use of control certificates such as CBF to provide safety guarantees during and after training the policies [16], [25], but they more or less requires an accurate model of the system dynamics or a reasonable modeling of the system uncertainties to build the certificates. Many dynamical systems in the real-world are black-box and lack accurate models. The most popular model-free approach to handle such black-box systems is safe reinforcement learning (RL). Safe RL methods enforce safety and performance by maximizing the expectation of the cumulative reward and constraining the expectation of the cost to be less or equal to a given threshold. The biggest disadvantage of safe RL methods is thelackofsystematicortheoreticallygroundedwayofdesigning cost function and reward functions, which heavily rely on empirical trials and errors. The lack of explainable safety guarantees and low sampling efficiency also make safe RL methods difficult to exhibit satisfactory performance. Instead of stressing about the trade-off between the strong guarantees from control certificates and the practicability of model-free methods, in this work, we propose SABLAS to achieve both. SABLAS is a general-purpose approach to learning sa fe control for bla ck-box dynamical s ystems. SABLAS enjoys the guarantees provided by the safety certificate from CBF This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ Q Fig. 1. (a) and (b) are two task environments we consider. In both CityEnv and ValleyEnv, the controller should control the ego vehicle to avoid collision with NPC vehicles. There are 1024 NPC drones in the city and 32 NPC ships in the valley. Each vehicle is assigned a random initial and goal location. (c) shows the average result for the two tasks, where the errorbars represent two times the standard deviation. SABLAS exhibits significant improvement in relative safety rate and task completion rate. theory without requiring for an accurate model for the dynamics. Instead, SABLAS only needs a nominal dynamics function that can be obtained through regressions over simulation data. There is no need to model the error between the nominal dynamics and the real dynamics since SABLAS essentially re-design the loss function in a novel way to back-propagate gradient to the controller even when the black-box dynamical system is non-differentiable. The resulting CBF (and the corresponding safety certificate) holds directly on the original black-box system if the training process converges. The proposed algorithm is easy-to-implement and follows almost the same procedure of learning CBF for white-box systems with minimal modification. SABLAS fundamentally solves the problem that control certificates cannot be learned directly on black-box systems, and opens up the next chapter use of CBF theory on synthesizing safe controllers for black-box dynamical systems. Experimental results demonstrates the superior advantages of SABLAS over leading learning-based safe control methods for black-box systems including CPO [26], PPO-Safe [3] and TRPO-Safe[27],[28].WeevaluateSABLASontwochallenging tasks in simulation: drone control in a city and ship control in a valley (as shown in Fig. 1). The dynamics of the drone and ship are assumed unknown. In both tasks, the controlled agent should avoid collision with uncontrolled agents and other obstacles, and reach its goal before the testing episode ends. We also examine the generalization capability of SABLAS on testing scenarios that are not seen in training. Fig. 1 shows that SABLAS can reach a near 1.0 relative safety rate and task completion rate while using only 1 _/_ 10 of the training data compared to existing safe RL methods, demonstrating a significant improvement. We also study the effect of model error (between the nominal model and actual dynamics) on the performance of the learned policy. It is shown that SABLAS is tolerant to large model errors while keeping a high safety rate. A detailed description of the results is presented in the experiment section. Video results can be found at supplementary materials. To summarize the strength of SABLAS: 1) SABLAS can jointly find a safety certificate (i.e. CBF) and the corresponding control policy on black-box dynamics; 2) Unlike RL-based methods that need tedious trial-and-error on designing the rewards, SABLAS provides a systematic way of learning certified control policy, without parameters (other than the standard hyper-parameters in NN training) that need fine-tuning. 3) Empirical results that SABLAS can achieve a nearly perfect performance in terms of guaranteeing safety and goal-reaching, using much less samples than state-of-the-art safe RL methods. II. RELATED WORK There is a rich literature on controlling black-box systems and safe RL. Due to the space limit, we only discuss a few directly related and commonly used techniques on black-box system control. We will also skip the literature review for the large body of works on model-based safe control and trajectory planning as the research problems we are solving are very different. _A._ _Controller Synthesis for Black-Box Systems_ Proportional–integral–derivative (PID) controller is widely used in controlling black-box systems. The advantage of PID controller is that it does not rely on a model of the system and only requires the measurement of the state. A drawback of PID controller is that it does not guarantee safety or stability, and the system may overshoot or oscillate about the control setpoint. If the underlying black-box system is linear time-invariant, existing work [29] has presented a polynomial-time control algorithm without relying on any knowledge of the environment. For non-linear black-box systems, the dynamics model can be approximated using system identification and controlled using model-based approaches [30], and PID can be used to handle the error part. The concept of practical relative degree [31] is also proposed to enhance the control performance on systems with heavy uncertainties. Recent advance in reinforcement learning [3], [4], [27], [32] also gives us insight into treating the system as a pure black-box and estimating the gradient for the black-box functions in order to optimize the control variables. However, in safety-critical systems, these black-box control methods still lack formal safety guarantee or certificate. Simulation-guided controller synthesis methods can also generate control certificates for black-box systems, and sometimes those certificates can indicate how policies should be constructed [20]–[22]. However, most of these techniques use polynomial templates for the certificates, which limits their use on high-dimensional and complex systems. Another line of work studies the use of [33], [34] data-driven reachability analysis, jointly with receding-horizon control to constructed optimal control policies. These methods rely on side information about the black-box systems (e.g. lipschitz constants of the dynamics, monotonicity of the states, decoupling in the states’ dynamics) to do the reachability, which is not needed in our method. _B._ _Safe Reinforcement Learning_ Safe RL [2], [26], [28], [35], [36] extends RL by adding constraints on the expectation of certain cost functions, which encode safety requirements or resource limits. CPO [26] derived a policy improvement step that increases the reward while satisfying the safety constraint. DCRL [2] imposes constraint on state density functions rather than cost value functions, and shows that density constraint has better expressiveness over cost value function-based constraints. RCPO [28] weights the cost using Lagrangian multipliers and add it to the reward. FISAR [36] uses a meta-optimizer to achieve forward invariance in the safe set. A disadvantage of safe RL is that it does not provide safety guarantee, or their safety guarantee cannot be realized in practice. The problem of sampling efficiency and sparsity of cost also increase the difficulty to synthesize safe controller through RL. _C._ _Safety Certificate and Control Barrier Functions_ Mathematical certificates can serve as proofs that the desired property of the system is satisfied under the corresponding planning [37], [38] and control components. Such certificate is able to guide the controller synthesis for dynamical systems in order to ensure safety. For example, Control Lyapunov Function [5], [6], [24] ensures the existence of a controller so that the system converges to desired behavior. Control Barrier Function[11]–[17],[39]ensurestheexistenceofacontrollerthat keep the system inside a safe invariant set. However, the existing controller synthesis with safety certificate heavily relies on a white-boxmodelofthesystemdynamics.Forblack-boxsystems or system with large model uncertainty, these methods are not applicable. While recent work [40] proposes to learn the model uncertainty effect on the CBF conditions, it still assumes that a handcrafted CBF is given, which is not always available for complex non-linear dynamical systems. Our approach represents a substantial improvement over the existing CBF-based safe controller synthesis strategy. TheproposedSABLASframework simultaneously enjoys the safety certificate from the CBF theory and the effectiveness on black-box dynamical systems. III. PRELIMINARIES _A._ _Safety of Black-Box Dynamical Systems_ _Definition_ _1_ _(Black-box_ _Dynamical_ _System):_ A black-box dynamical system is represented by tuple _⟨S, U_ _, f_ _⟩_, where _S_ _∈_ R <sup>_n_</sup> is the state space and _U_ _∈_ R <sup>_m_</sup> is the control input space. _f_ : _S × U_ _�→S_ is the system dynamics _s_ ˙ = _f_ ( _s, u_ ), which is unknown due to the black-box assumption. Let _S_ 0 _, Sg, Ss_ and _Sd_ denote the set of initial states, goal states, safe states and dangerous states respectively. The problem we aim to solve is formalized in Definition 2. _Definition_ _2_ _(Safe_ _Control_ _of_ _Black-box_ _Systems):_ Given a black-box dynamical system modeled as in Definition 1, the safe control problem aims to find a controller _π_ : _S_ _�→U_ such that under control input _u_ = _π_ ( _s_ ) and the unknown dynamics _s_ ˙ = _f_ ( _s, u_ ), the following is satisfied: _∃_ _t >_ 0 _, s_ ( _t_ ) _∈Sg_ s.t. _∀t_ _>_ 0 _, s_ ( _t_ ) _̸ ∈Sd_ and _s_ (0) _∈S_ 0 (1) The above definition requires that starting from the initial set _S_ 0, the system should never enter the dangerous set _Sd_ under controller _π_ . _B._ _Control Barrier Function as Safety Certificate_ A common approach for guaranteeing safety of dynamical systems is via control barrier functions (CBF) [11], which ensures that the state always stay in the safe invariant set. A control barrier function _h_ : _S_ _�→_ R satisfies: _h_ ( _s_ ) _≥_ 0 _,_ _∀s ∈S_ 0 _h_ ( _s_ ) _<_ 0 _,_ _∀s ∈Sd_ _h_ ˙ + _α_ ( _h_ ) = <sup>_<u>∂h</u>_</sup> _∂s_ <sup>_f_</sup> <sup>(</sup> <sup>_s, u_</sup> <sup>) +</sup> <sup>_α_</sup> <sup>(</sup> <sup>_h_</sup> <sup>)</sup> <sup>_≥_</sup> <sup>0</sup> <sup>_,_</sup> _∀s ∈Sp_ (2) where _Sp_ = _{s | h_ ( _s_ ) _≥_ 0 _}_, _u_ = _π_ ( _s_ ) and _α_ ( _·_ ) is a class- _K_ function that is strictly increasing and _α_ (0) = 0. It is proven [11] that if there exists a CBF _h_ for a given controller _π_, the system controlled by _π_ starting from _s_ (0) _∈S_ 0 will never enter the dangerous set _Sd_ . Besides the formal safety proof in [11], there is an informal but straightforward way to understand the safety guarantee. Whenever _h_ ( _s_ ) decreases to 0, we have _h_ ˙ + _α_ ( _h_ ) = _h_ ˙ _≥_ 0, which means _h_ ( _s_ ) no longer decreases and _h_ ( _s_ ) _<_ 0 will not occur. Thus _s_ will not enter the dangerous set _Sd_ where _h_ ( _s_ ) _<_ 0. _C._ _Co-Learning Controller and CBF for White-Box Systems_ For white-box dynamical systems where _f_ ( _s, u_ ) is known, we can jointly synthesize the controller _π_ and it safety certificate _h_ that satisfy CBF conditions (2) via a learning-based approach. We model _π_ and _h_ as neural networks with parameters Θ and Ω. Given a dataset _D_ of the state samples in _S_, the CBF conditions (2) can be translated into empirical loss functions: 1 _L_ 0(Ω) = _|S_ 0 _∩D|_ 1 _Ld_ (Ω) = _|Sd ∩D|_ _s∈S_ 0 _∩D_ _s∈Sd∩D_ max(0 _, −h_ ( _s_ ; Ω)) max(0 _, h_ ( _s_ ; Ω)) 1 _Lp_ (Ω _,_ Θ) = _|Sp ∩D|_ _s∈Sp∩D_ _._ (3) max 0 _, −_ <sup>_<u>∂h</u>_</sup> _∂s_ <sup>_f_</sup> <sup>(</sup> <sup>_s, π_</sup> <sup>(</sup> <sup>_s_</sup> <sup>; Θ))</sup> <sup>_−_</sup> <sup>_α_</sup> <sup>(</sup> <sup>_h_</sup> <sup>(</sup> <sup>_s,_</sup> <sup>Ω))</sup> Each of the loss functions in (3) corresponds to a CBF condition in (2). In addition to safety, we also consider goal-reaching by penalize the difference between the safe controller _π_ and the Q goal-reaching nominal controller _πnom_ in (4). The synthesis of _πnom_ is well-studied and is not the contribution of our work. 1 _Lg_ (Θ) = _|Sp ∩D|_ _s∈Sp∩D_ _||π_ ( _s_ ; Θ) _−_ _πnom_ ( _s_ ) _||_ <sup>2</sup> 2 <sup>_._</sup> (4) the gradient flow can successfully reach _π_ ( _s_ ) and update the controller parameter. However, this is not immediately possible because _f_ is unknown by the black-box assumption. A possible way to back-propagate gradient to _π_ is to use a differentiable nominal model _fnom_ . There are many methods to obtain _fnom_, such as fitting a neural network using sampled data from the real black-box system. We do not require _fnom_ to perfectly match the real dynamics _f_, because there will always exist an error between them. With _fnom_, we can approximate _Lp_ as: The total loss function is _L_ 0(Ω) + _Ld_ (Ω) + _Lp_ (Ω _,_ Θ) + _λLg_ (Θ), where _λ_ is a constant that balances the goal-reaching and safety objective. The total loss function is minimized via stochastic gradient descent to find the parameters Ω and Θ. The dataset _D_ is not fixed during training and will be periodically updated with new samples by running the current controller. When the loss _L_ 0 + _Ld_ + _Lp_ converges to 0, the resulting controller _π_ ( _s_ ; Θ) and CBF _h_ ( _s_ ; Ω) will satisfy (2) on unseen testing samples with a generalization bound as proven in [17]. Therefore, a safe controller and the corresponding CBF is found for the white-box system. However, for black-box dynamical systems where _f_ ( _s, u_ ) is unknown, the co-learning method for safe controller and CBF described above is no longer applicable. In Section IV, we propose an important and easy-to-implement modification to (3) such that we can leverage similar co-learning framework to jointly synthesize the safe controller and its corresponding CBF as safety certificate. IV. LEARNING CBF ON BLACK-BOX SYSTEMS In this section, we first elaborate on why it is difficult to learn the safe controller and its CBF for black-box dynamical systems. Then we will propose an important and easy-to-implement reformulation of the optimization objective, which makes learning safe controller in black-box systems as easy as in white-box systems. _A._ _Challenges in Black-Box Dynamical Systems_ Among the three loss functions _L_ 0 _, Ld_ and _Lp_ in (3), _Lp_ is the only one that can propagate gradient to the controller parameter Θ.ThemainchallengeoftrainingsafecontrollerwithitsCBFfor black-box dynamical systems is that the gradient can no longer be back-propagated to Θ when _f_ is unknown. Therefore, a safe controller cannot be trained by minimizing the loss functions in (3). Given state samples _s_ ( _t_ ) and _s_ ( _t_ + Δ _t_ ) from the black-box system where Δ _t_ is a sufficiently small time interval, we can approximate _h_ <sup>˙</sup> and compute _Lp_ as: which is differentiable w.r.t. _π_ ( _s_ ) because both _h_ and _fnom_ are differentiable. The gradient of _Lp_ 2 can be back-propagated to the controller to update its parameters. However, whatever way we get _fnom_, there still exists an error between the real dynamics _f_ and _fnom_, which means _h_ <sup>˙</sup> 2 is not a good approximation of _h_ <sup>˙</sup> and _Lp_ 2 is not the true value of _Lp_ . Using _Lp_ 2, it is not guaranteed that the third CBF condition in (2) will be satisfied. _B._ _Learning Safe Control for Black-Box Dynamics_ We present a novel re-formulation of _Lp_ that makes learning safe controller with CBF for black-box dynamical systems as easy as in white-box systems. The proposed formulation possesses two features: it enables the gradient to back-propagate to the controller in training, and offers an error-free approximation of _h_ <sup>˙</sup> . Given state samples _s_ ( _t_ ) and _s_ ( _t_ + Δ _t_ ) from the trajectories of the real black-box dynamical system, where Δ _t_ is a sufficiently small time interval, we define _snom_ ( _t_ + Δ _t_ ) as : _snom_ ( _t_ + Δ _t_ ) = _s_ ( _t_ ) + _fnom_ ( _s_ ( _t_ ) _, π_ ( _s_ ( _t_ )))Δ _t,_ then construct ¯ _s_ ( _t_ + Δ _t_ ) as: _s_ ¯( _t_ + Δ _t_ ) = _snom_ ( _t_ + Δ _t_ ) + _g_ ( _s_ ( _t_ + Δ _t_ ) _−_ _snom_ ( _t_ + Δ _t_ )) _,_ where _g_ ( _s_ ) = _s_ is an identity function but _without gradient_ . We need to pretend that _g_ ( _s_ ) is a constant and in back-propagation, the gradient on _g_ ( _s_ ) cannot propagate to its argument _s_ . In PyTorch [41], there is an off-the-shelf implementation of _g_ ( _s_ ) as _g_ ( _s_ ) = _s._ detach(), which cuts off the gradient from _g_ to _s_ in back-propagation. Then we approximate _Lp_ using: _h_ ˙ 2( _s_ ) = <sup>_<u>h</u>_</sup> <sup>(</sup> <sup>_<u>s</u>_</sup> <sup>+</sup> <sup>_<u>fnom</u>_</sup> <sup>(</sup> <sup>_<u>s, π</u>_</sup> <sup>(</sup> <sup>_<u>s</u>_</sup> <sup>))Δ</sup> <sup>_<u>t</u>_</sup> <sup>)</sup> <sup>_<u>−</u>_</sup> <sup>_<u>h</u>_</sup> <sup>(</sup> <sup>_<u>s</u>_</sup> <sup>)</sup> Δ _t_ 1 _Lp_ 2 = _|Sp ∩D|_ _s∈Sp∩D_ max - 0 _, −h_ <sup>˙</sup> 2( _s_ ) _−_ _α_ ( _h_ ( _s_ )) _,_ (6) _h_ ˙ 1( _s_ ) = <sup>_<u>h</u>_</sup> <sup>(</sup> <sup>_<u>s</u>_</sup> <sup>(</sup> <sup>_<u>t</u>_</sup> <sup>+ Δ</sup> <sup>_<u>t</u>_</sup> <sup>))</sup> <sup>_<u>−</u>_</sup> <sup>_<u>h</u>_</sup> <sup>(</sup> <sup>_<u>s</u>_</sup> <sup>(</sup> <sup>_<u>t</u>_</sup> <sup>))</sup> Δ _t_ _h_ ˙ 3( _s_ ) = <sup>_<u>h</u>_</sup> <sup>(¯</sup> <sup>_<u>s</u>_</sup> <sup>(</sup> <sup>_<u>t</u>_</sup> <sup>+ Δ</sup> <sup>_<u>t</u>_</sup> <sup>))</sup> <sup>_<u>−</u>_</sup> <sup>_<u>h</u>_</sup> <sup>(</sup> <sup>_<u>s</u>_</sup> <sup>(</sup> <sup>_<u>t</u>_</sup> <sup>))</sup> 1 _Lp_ 3 = _|Sp ∩D|_ 1 _Lp_ 1 = _|Sp ∩D|_ _s∈Sp∩D_ max max - 0 _, −h_ <sup>˙</sup> 1( _s_ ) _−_ _α_ ( _h_ ( _s_ )) _._ (5) Δ _t_ _s∈Sp∩D_ - 0 _, −h_ <sup>˙</sup> 3( _s_ ) _−_ _α_ ( _h_ ( _s_ )) _._ (7) _Lp_ 1 does give the value of _Lp_, but its backward gradient flow to the controller is cut off by the black-box system that is non-differentiable. (5) can only be used to train CBF _h_ but not the safe controller _π_ . Even worse, the _h_ obtained by minimizing (5) does not guarantee that a corresponding safe controller _π_ exists. If we have an differential expression of dynamics _f_ and replace _h_ ( _s_ ( _t_ + Δ _t_ )) with _h_ ( _s_ ( _t_ ) + _f_ ( _s_ ( _t_ ) _, π_ ( _s_ ( _t_ )))Δ _t_ ), _Theorem 1:_ _∇_ Θ _Lp_ 3 exists and limΔ _t→_ 0 _Lp_ 3 = _Lp_ . Namely, _Lp_ 3 is differentiable w.r.t. the controller parameter Θ, and _Lp_ 3 is an error-free approximation of _Lp_ as Δ _t →_ 0. _Proof:_ Since _fnom_ is differentiable, _snom_ and ¯ _s_ ( _t_ + Δ _t_ ) are differentiable w.r.t. _π_, _h_ <sup>˙</sup> 3 and _Lp_ 3 are also differentiable w.r.t. _π_ and its parameter Θ. Thus, _∇_ Θ _Lp_ 3 exists. Furthermore, since Fig. 2. Computational graph of _Lp_ 3. The blue lines show how the gradient from _Lp_ 3 is back-propagated to the controller _π_ despite that the black-box system itself is non-differentiable. _s_ ¯( _t_ + Δ _t_ ) = _s_ ( _t_ + Δ _t_ ), _h_ <sup>˙</sup> 3 is an error-free approximation of the real _h_ <sup>˙</sup> when Δ _t →_ 0. Thus _Lp_ 3 is also an error-free approximation of _Lp_ when Δ _t →_ 0. Note that Theorem 1 reveals the reason why the proposed SABLAS method can jointly learn the CBF and the safe controller for black-box dynamical system. First, since _∇_ Θ _Lp_ 3 exists, the gradient from _Lp_ 3 can be back-propagated to the controller parameters to learn a safe controller. On the contrary, _h_ ˙ 1 is not differentiable w.r.t. _π_ so _Lp_ 1 cannot be used to train the controller. Second, since _Lp_ 3 is a good approximation of _Lp_, minimizing _Lp_ 3 contributes to the minimization of _Lp_ and the satisfaction of the third CBF condition in (2). On the contrary, _h_ ˙ 2 is an inaccurate approximation of _h_ ˙ as we elaborated in Section IV-A. The construction of _Lp_ 3 incorporates the advantages of _Lp_ 1 and _Lp_ 2, and avoids the disadvantages of _Lp_ 1 and _Lp_ 2 at the same time. The computational graph of _Lp_ 3 is illustrated in Fig. 2, which shows the forward pass and the backward gradient propagation from _Lp_ 3 to controller _π_ . _Remark 1:_ One may argue that the gradient received by _π_ via minimizing _Lp_ 3 is not exactly the gradient it should receive if we had a perfect differentiable model of the black-box system. Despite this, minimizing _Lp_ 3 directly contributes to the satisfaction of the third CBF condition in (2). A safe controller and its CBF can be found to keep the system within safe set. _Remark_ _2:_ Although the current formulation of _Lp_ 3 leads to promising performance in simulation as we will show in experiments, _Lp_ 3 requires further consideration in hardware experiments. Directly using the future state _s_ ( _t_ + Δ _t_ ) to calculate the time derivative of _h_ or _s_ is not always desirable because noise will possibly dominate the numerical differentiation. When the noise dominates the time derivative of _s_ or _h_, the training will have convergence issues. But a moderate noise is actually beneficial to training, because our optimization objective makes the CBF conditions hold even under noise disturbance, which increases the robustness of the trained CBF and controller. On physical robots where noise dominates the numerical differentiation, one can incoperate filtering techniques to mitigate the noise. Combining with the loss functions _L_ 0 _, Ld_ and _Lg_ in (3) and (4), the total loss function can be formulated as: _L_ (Ω _,_ Θ) = _L_ 0(Ω) + _Ld_ (Ω) + _Lp_ 3(Ω _,_ Θ) + _λLg_ (Θ) _,_ (8) where _λ_ is a constant balancing the safety and goal-reaching objective. _L_ is minimized via stochastic gradient descent. Algorithm 1 summarizes the learning process of the safe controller and the corresponding safety certificate (CBF) for black-box Algorithm 1: Learning Safe Controller With CBF for Black<u>Box Dynamical Systems.</u> 1: Input: The set of initial condition _S_ 0, the set of dangerous state _Sd_, controller _π_ and CBF _h_ with randomly initialized parameters Θ and Ω, nominal dynamics _fnom_, loss function _L_ (Ω _,_ Θ), the number of episodes _K_ in data collection, the number of training iterations _N_ . 2: for _i_ = 1 _,_ 2 _, . . ., N_ do 3: Initialize state samples dataset _D_ _←∅_ 4: for _j_ = 1 _,_ 2 _, . . ., K_ do 5: _s_ (0) _←_ SAMPLE( _S_ 0) 6: _Dj_ _←_ RUN( _π_ ( _·_ ; Θ) _, s_ (0)), _D_ _←D ∪Dj_ 7: end for 8: Ω _,_ Θ _←_ UPDATE(Ω _,_ Θ _, D, L_ ) 9: end for <u>10:</u> return <u>CBF parameter Ω and controller parameter Θ</u> dynamical systems. The RUN function runs the black-box system using the controller _π_ under initial condition _s_ (0), and returns the trajectory data. The UPDATE function updates parameters Ω _,_ Θ by minimizing _L_ (Ω _,_ Θ) using the state samples in _D_ via gradient descent. V. EXPERIMENT The primary objective of our experiment is to examine the effectiveness of the proposed method in terms of safety and goal-reaching when controlling black-box dynamical systems. We will conduct comprehensive experiments on two simulation environments illustrated in Fig. 1(a) and (b), and compare with state-of-the-art learning-based control methods for black-box systems. _A._ _Task Environment Description_ _a)_ _Drone_ _control_ _in_ _a_ _city_ _(CityEnv):_ In our first case study, we consider the package delivery task in a city using drones, as is illustrated in Fig. 1(a). There is one controlled drone and 1024 non-player character (NPC) drones that are not controlled by our controller. In each simulation episode, each drone is assigned a sequence of randomly selected goals to visit. The aim of our controller is to make sure the controlled drone reach its goals while avoiding collision with NPC drones at any time. A reference trajectory _sref_ ( _t_ ) _, t ∈_ [0 _, T_ ] will be given, which sequentially connects the goals and avoid collision with buildings. The reference trajectory can be generated by any off-the-shelf single-agent path planning algorithm. We use FACTEST [42] in our implementation, and other options such as RRT [43] are also suitable. The reference path planner does not need to consider the dynamic obstacles, such as the moving NPCs in our experiment. A nominal controller _πnorm_ will also be given, which outputs control commands that drive the drone to follow the reference trajectory. However, _πnorm_ is purely for goal-reaching and does not consider safety. The CityEnv has two modes: with static NPCs and moving NPCs. If the NPCs Q are static, they will constantly stay at their initial locations. If the NPCs are moving, they will follow pre-planned trajectories to sequentially visit their goals. The drone model is with state space [ _x, y, z, vx, vy, vz, θx, θy_ ], where _θx_ and _θy_ are row and pitch angles. The control inputs are the angular acceleration of _θx, θy_ and the vertical thrust. The underlying model dynamics is from [17] and assumed unknown to the controller and CBF in our experiment. _b)_ _Ship_ _control_ _in_ _a_ _valley_ _(ValleyEnv):_ In our second case study, we consider task of controlling a ship in valley illustrated in Fig. 1(b). There are one controlled ship and 32 NPC ships. The number of NPCs in ValleyEnv is less than CityEnv because ships are large in size and inertia, and hard to maneuver in dense traffic. Also, different from the 3D CityEnv, ValleyEnv is in 2D, which means the agents have fewer degrees of freedom to avoid collision. The initial location and goal location of each ship is randomly initialized at the beginning of each episode. The aim of our controller is to ensure the controlled ship reach its goal and avoid collision with NPC ships. Similar to CityEnv, a reference trajectory and nominal controller will be provided. There are also two modes in ValleyEnv, including the static and moving NPC mode, as is in CityEnv. The ship model is with state space [ _x, y, θ, u, v, ω_ ], where _θ_ is the heading angle, _u, v_ are speed in the ship body coordinates, and _ω_ is the angular velocity of the heading angle. The ship model is from Section IV-B of [44] and is unknown to the controller and CBF. _B._ _Evaluation Criteria_ Three evaluation criteria are considered. Relative safety rate measures the improvement of safety comparing to a nominal controller that only targets at goal-reaching but not safety. To formallydefinetherelativesafetyrate, wefirstconsidertheabsolute - _T_ safety rate _α_ as _α_ = _T_ <sup><u>1</u></sup> 0 <sup>I(</sup> <sup>_s_</sup> <sup>(</sup> <sup>_t_</sup> <sup>)</sup> <sup>_̸ ∈Sd_</sup> <sup>)</sup> <sup>_dt_</sup> <sup>, which measures the</sup> mallydefinetherelativesafetyrate, wefirstconsidertheabsolute - _T_ safety rate _α_ as _α_ = _T_ <sup><u>1</u></sup> 0 <sup>I(</sup> <sup>_s_</sup> <sup>(</sup> <sup>_t_</sup> <sup>)</sup> <sup>_̸ ∈Sd_</sup> <sup>)</sup> <sup>_dt_</sup> <sup>, which measures the</sup> proportion of time that the system stays outside the dangerous set. Given two control policies _π_ 1 and _π_ 2 with absolute safety rate _α_ 1 and _α_ 2, the relative safety rate of _π_ 1 w.r.t. _π_ 2 is defined as _β_ 12 = <sup>_<u>α</u>_</sup> 1 <sup><u>1</u></sup> _−_ <sup>_<u>−</u>_</sup> _α_ <sup>_<u>α</u>_</sup> 2 <sup><u>2</u></sup> <sup>_∈_</sup> <sup>(</sup> <sup>_−∞,_</sup> <sup>1]</sup> <sup>_._</sup> <sup>If</sup> <sup>_β_</sup> <sup>12</sup> <sup>= 0, then control policy</sup> <sup>_π_</sup> <sup>1</sup> _T_ as _β_ 12 = <sup>_<u>α</u>_</sup> 1 <sup><u>1</u></sup> _−_ <sup>_<u>−</u>_</sup> _α_ <sup>_<u>α</u>_</sup> 2 <sup><u>2</u></sup> <sup>_∈_</sup> <sup>(</sup> <sup>_−∞,_</sup> <sup>1]</sup> <sup>_._</sup> <sup>If</sup> <sup>_β_</sup> <sup>12</sup> <sup>= 0, then control policy</sup> <sup>_π_</sup> <sup>1</sup> does not have any improvement over _π_ 2 in terms of safety. If _β_ 12 = 1, then _π_ 1 completely guarantees safety of the system in _t ∈_ [0 _, T_ ]. In our experiment, _π_ 1 is the controller to be evaluated, and _π_ 2 is the nominal controller _πnorm_ that only accounts for goal-reaching without considering safety. Task completion rate is defined as the success rate of reaching the goal state before timeout. Tracking error is the average deviation of the system’s state trajectory comparing to a pre-planned reference trajectory - _T_ _sref_ ( _t_ ) _, t ∈_ [0 _, T_ ] as _γ_ = _T_ <sup><u>1</u></sup> 0 <sup>_||s_</sup> <sup>(</sup> <sup>_t_</sup> <sup>)</sup> <sup>_−_</sup> <sup>_sref_</sup> <sup>(</sup> <sup>_t_</sup> <sup>)</sup> <sup>_||_</sup> 2 <sup>2</sup> <sup>_dt._</sup> <sup>Note that</sup> state trajectory comparing to a pre-planned reference trajectory - _T_ _sref_ ( _t_ ) _, t ∈_ [0 _, T_ ] as _γ_ = _T_ <sup><u>1</u></sup> 0 <sup>_||s_</sup> <sup>(</sup> <sup>_t_</sup> <sup>)</sup> <sup>_−_</sup> <sup>_sref_</sup> <sup>(</sup> <sup>_t_</sup> <sup>)</sup> <sup>_||_</sup> 2 <sup>2</sup> <sup>_dt._</sup> <sup>Note that</sup> we do not assume _sref_ always stay outside the dangerous set. _T_ _C._ _Baseline Approaches_ In terms of safe control for black-box systems, the most recent state-of-the-art approaches are safe reinforcement learning (safe RL) algorithms. We choose three safe RL algorithms for comparison: CPO [26] is a general-purpose policy optimization algorithm for black-box systems that maximizes the expected reward while satisfying the safety constraints. PPO-Safe is a combination of PPO [3] and RCPO [28]. It uses PPO to maximize the expected cumulative reward while leveraging the Lagrangian multiplier update rule in RCPO to enforce the safety constraint. TRPO-Safe is a combination of TRPO [27] and RCPO [28]. The expected reward is maximized via TRPO and the safety constraints are imposed using the Lagrangian multiplier in RCPO. _D._ _Implementation and Training_ Both the controller _π_ and CBF _h_ are multi-layer perceptrons (MLP) with architecture adopted from Section IV-B of [17]. _π_ and _h_ not only take the state of the controlled agent as input, but also the states of 8 nearest NPCs that the controlled agent can observe. In Algorithm 1, we choose _K_ = 1 _, N_ = 2000. The total number of state samples collected during training is 10 <sup>6</sup> . In UPDATE of the algorithm, we use the Adam [45] optimizer with learning rate 10 <sup>_−_</sup> <sup>4</sup> and batch size 1024. The gradient descent runs for 100 iterations in UPDATE. The nominal model dynamics are fitted from trajectory data in simulation. We used 10 <sup>4</sup> state samples to fit a linear approximation of the drone dynamics, and 10 <sup>5</sup> samples to fit a non-linear 3-layer MLP as the ship dynamics. In training the safe RL methods, the reward in every step is the negative distance between the system’s current state and the goal state, and the cost is 1 if the system is within the dangerous set _Sd_ and 0 otherwise. The threshold for expected cost is set to 0, which means we wish the system never enter the dangerous set (never reach a state with a positive cost). During training, the agent runs the system for 10 <sup>7</sup> timesteps in total and performs 2000 policy updates. In each policy update, 100 iterations of gradient descent are performed. The implementation of the safe RL methods is based on [46]. All the methods are trained with static NPCs and tested on both static and moving NPCs. We believe this can make the testing more challenging and examine the generalization capability of the tested methods in different scenarios. All the agents are assigned random initial and goal locations in every simulation episode, which prevents the learned controller from overfitting a single configuration. _E._ _Experimental Results_ _a) Safety and goal-reaching performance:_ Results are shown in Fig. 3. Among the compared methods, our method is the only one that can reach a high task completion rate and relative safety rate at the same time. For other methods such as TRPO-Safe, when the controlled drone or ship is about to hit the NPCs, the learned controller tend to brake and decelerate. Thus, the agent is less likely to reach its goal when a simulation episode ends. The task completion rate and safety rate are opposite to each other for CPO, PPO-Safe and TRPO-Safe. On the contrary, the controller obtained by our method can maneuver smoothly among NPCs without severe deceleration. This enables the controlled agent to reach the goal location on time. Our method can also keep a relatively low tracking error, which means the difference between actual trajectories and reference trajectories is small. _b) Generalization capability to unseen scenarios:_ As is stated in Section V-D, the NPCs are static in training and can be either Fig. 3. Quantitative results of relative safety rate, task completion rate and tracking error. The center points are mean and error bars represent standard deviations. Results are collected over 50 random runs on each method. The first row is for drone control in CityEnv and the second row is for ship control in ValleyEnv. Our method reaches a high task completion rate and relative rate at the same time, while keeping a low tracking error. empirical error _e ≤_ 0 _._ 2. The orange curve in Fig. 4(b) shows that if we use _Lp_ 2 in (6), the trained controller will have a worse performance in terms of safety rate. This is because _Lp_ 2 only uses the nominal dynamics to calculate the loss, without leveraging the real black-box dynamics. _F._ _Discussion on Limitation_ Fig. 4. (a) Comparison of sampling efficiency. With only 1 _/_ 10 samples, SABLAS achieves a nearly perfect relative safety rate. (b) Influence of model error on safety performance. SABLAS- _Lp_ 2 uses (6) instead of the proposed (7) as loss function. SABLAS is tolerant to large error between nominal and real models while keeping a high safety rate. static or moving in testing. Fig. 3 also demonstrates that our method has promising generalization capability across different training and testing scenarios. _c)_ _Sampling_ _efficiency:_ In Fig. 4(a), we show the safety performance under different sizes of the training set. The results are averaged over the drone and ship control tasks. SABLAS only needs around 1 _/_ 10 of the samples required by the compared methods to achieve a nearly perfect relative safety rate. Note that SABLAS requires an extra 10 <sup>4</sup> to 10 <sup>5</sup> samples to fit the nominal dynamics, but this does not change the fact that the total number ofsamplesneededbySABLASismuchfewerthanthebaselines. _d)_ _Effect_ _of_ _model_ _error:_ We investigate the influence of the model error _||_ ˙ _s −_ _s_ ˙ _nom||_ between the real dynamics and the nominal dynamics on the safety performance. We change the modeling error of the drone model and test the learning controller on CityEnv with static NPCs. We also perform an ablation study where we use _Lp_ 2 in (6) instead of _Lp_ 3 in (7) as loss function. The red curve in Fig. 4(b) show that SABLAS is tolerant to large model errors while exhibiting a promising safety rate. In our previous experiments, the model error _e_ = E [ _||_ ˙ _s −_ _s_ ˙ _nom||_ ] _/_ E [ _||_ ˙ _s||_ ] is always less than 0.2. We did not encounter any difficulty fitting a nominal model with The main limitation of the proposed approach is that it cannot guarantee the satisfaction of the CBF conditions in (2) in the entire state space. Even if we minimize _L_ 0 _, Ld_ and _Lp_ 3 to 0 during training, the CBF conditions may still be occasionally violated during testing. After all, the training samples are finite and cannot cover the continuous state space. If the testing distribution and training distribution are the same, one can leverage the Rademacher complexity to give an error bound that the CBF conditions are violated, as is in Appendix B of [17]. But if the testing distribution is different from training, it is still unclear to derive the generalization error of the CBF conditions. To train CBF and controller that provably satisfy the CBF conditions, one can also use verification tools to find the counterexamples in the state space that violates the CBF conditions and add those counterexamples to the training set [23], [24]. The process is finished when no more counterexample can be found. However, the time complexity of the verification makes it not applicable for large and expressive neural networks. Also, the error between the nominal and real dynamics will have a negative impact on the safety performance. These limitations are left for future work. VI. CONCLUSION AND FUTURE WORKS We presented SABLAS, a general-purpose safe controller learning approach for black-box systems, which is supported by the theoretical guarantees from control barrier function theory, and at the same time is strengthened using a novel learning structure so it can directly learn the policies and barrier certificates for black-box dynamical systems. Simulation results show that SABLAS indeed provides a systematic way of learning safe Q control policies with a great improvement over safe RL methods. For future works, we plan to study SABLAS on multi-agent systems, especially with adversarial players. ACKNOWLEDGMENT This letter solely reflects the opinions and conclusions of its authors and not DSTA Singapore or the Singapore Government. REFERENCES [1] Z. Qin, K. Fang, Y. Zhu, L. Fei-Fei, and S. Savarese, “KETO: Learning keypoint representations for tool manipulation,” in _Proc. IEEE Int. Conf._ _Robot. Automat._, 2020, pp. 7278–7285. [2] Z. Qin, Y. Chen, and C. Fan, “Density constrained reinforcement learning,” in _Proc. Int. Conf. Mach. Learn._, 2021, pp. 8682–8692. [3] J. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov, “Prox imal policy optimization algorithms,” _Comput._ _Res._ _Repository_ _(CoRR)_, vol. abs/1707.06347, 2017. [4] T. P. Lillicrap _et al._, “Continuous control with deep reinforcement learn ing,” in _Proc. 4th Int. Conf. Learn. Representations_, 2016. [5] R. Freeman and P. V. Kokotovic, _Robust Nonlinear Control Design: State-_ _Space and Lyapunov Techniques_ . Berlin, Germany: Springer, 2008. [6] A. Isidori, E. Sontag, and M. Thoma, _Nonlinear Control Systems_, vol. 3. Berlin, Germany: Springer, 1995. [7] W. Lohmiller and J.-J. E. Slotine, “On contraction analysis for non-linear systems,” _Automatica_, vol. 34, no. 6, pp. 683–696, 1998. [8] I. R. Manchester and J.-J. E. Slotine, “Control contraction metrics: Convex and intrinsic criteria for nonlinear feedback design,” _IEEE Trans. Autom._ _Control_, vol. 62, no. 6, pp. 3046–3053, Jun. 2017. [9] D. Sun, S. Jha, and C. Fan, “Learning certified control using contraction metric,” in _Proc. Conf. Robot Learn._, 2020. [10] H. Tsukamoto and S.-J. Chung, “Neural contraction metrics for robust estimation and control: A convex optimization approach,” _IEEE Control_ _Sys. Letters (L-CSS)_, vol. 5, no. 1, pp. 211–216, 2021. [11] A. D. Ames, J. W. Grizzle, and P. Tabuada, “Control barrier function based quadratic programs with application to adaptive cruise control,” in _Proc._ _IEEE 53rd Annu. Conf. Decis. Control_, 2014, pp. 6271–6278. [12] A. D. Ames, S. Coogan, M. Egerstedt, G. Notomista, K. Sreenath, and P. Tabuada, “Control barrier functions: Theory and applications,” in _Proc._ _18th Eur. Control Conf._, 2019, pp. 3420–3431. [13] U. Borrmann, L. Wang, A. D. Ames, and M. Egerstedt, “Control barrier certificatesfor safe swarm behavior,” _IFAC-Papers-OnLine_,vol.48,no.27, pp. 68–73, 2015. [14] Y. Chen, A. Singletary, and A. D. Ames, “Guaranteed obstacle avoid ance for multi-robot operations with limited actuation: A control barrier function approach,” _IEEE_ _Contr._ _Syst._ _Lett._, vol. 5, no. 1, pp. 127–132, Jan. 2021. [15] R. Cheng, G. Orosz, R. M. Murray, and J. W. Burdick, “End-to-end safe reinforcement learning through barrier functions for safety-critical continuous control tasks,” in _Proc. AAAI Conf. Artif. Intell._, 2019, vol. 33, pp. 3387–3395. [16] R. Cheng, M. J. Khojasteh, A. D. Ames, and J. W. Burdick, “Safe multi agent interaction through robust control barrier functions with learned uncertainties,” in _Proc. 59th IEEE Conf. Decision Control (CDC)_, 2020, pp. 777–783. [17] Z. Qin, K. Zhang, Y. Chen, J. Chen, and C. Fan, “Learning safe multi-agent control with decentralized neural barrier certificates,” in _Proc. Int. Conf._ _Learn. Representations_, 2021. [18] A. D. Ames, X. Xu, J. W. Grizzle, and P. Tabuada, “Control barrier function based quadratic programs for safety critical systems,” _IEEE_ _Trans._ _Autom._ _Control_, vol. 62, no. 8, pp. 3861–3876, Aug. 2017. [19] A. Papachristodoulou and S. Prajna, “A tutorial on sum of squares techniques for systems analysis,” in _Proc._ _Amer._ _Control_ _Conf._, 2005, pp. 2686–2700. [20] U. Topcu, A. Packard, and P. Seiler, “Local stability analysis using sim ulations and sum-of-squares programming,” _Automatica_, vol. 44, no. 10, pp. 2669–2675, 2008. [21] J. Kapinski, J. V. Deshmukh, S. Sankaranarayanan, and N. Aréchiga, “Simulation-guided lyapunov analysis for hybrid dynamical systems,” in _Proc. 17th Int. Conf. Hybrid Syst., Comput. Control_, 2014, pp. 133–142. [22] H. Ravanbakhsh and S. Sankaranarayanan, “Learning control lyapunov functions from counterexamples and demonstrations,” _Auton._ _Robots_, vol. 43, no. 2, pp. 275–307, 2019. [23] Y.-C. Chang, N. Roohi, and S. Gao, “Neural lyapunov control,” in _Proc._ _Adv. Neural Inf. Process. Syst._, 2019, pp. 3245–3254. [24] H. Dai, B. Landry, L. Yang, M. Pavone, and R. Tedrake, “Lyapunov-stable neural-network control,” _Robot. Sci. Syst._, 2021. [25] S. Dean, A. J. Taylor, R. K. Cosner, B. Recht, and A. D. Ames, “Guarantee ing safety of learned perception modules via measurement-robust control barrier functions,” in _Proc. Conf. Robot. Learn._, 2020. [26] J. Achiam, D. Held, A. Tamar, and P. Abbeel, “Constrained policy opti mization,” in _Proc. Int. Conf. Mach. Learn._, 2017, pp. 22–31. [27] J. Schulman, S. Levine, P. Abbeel, M. Jordan, and P. Moritz, “Trust region policy optimization,” in _Proc._ _Int._ _Conf._ _Mach._ _Learn._, 2015, pp. 1889– 1897. [28] C. Tessler, D. J. Mankowitz, and S. Mannor, “Reward constrained policy optimization,” in _Proc. 7th Int. Conf. Learn. Representations_, 2019. [29] X. Chen and E. Hazan, “Black-box control for linear dynamical systems,” in _Proc. 34th Conf. Learn. Theory_, 2021, pp. 1114–1143. [30] M. Fliess, C. Join, and H. Sira-Ramirez, “Complex continuous nonlinear systems: Their black box identification and their control,” _IFAC Proceed-_ _ings Volumes_, vol. 39, no. 1, pp. 416–421, 2006. [31] A. Levant, “Practical relative degree in black-box control,” in _Proc. IEEE_ _51st IEEE Conf. Decis. Control_, 2012, pp. 7101–7106. [32] W. Grathwohl, D. Choi, Y. Wu, G. Roeder, and D. Duvenaud, “Back propagation through the void: Optimizing control variates for black-box gradient estimation,” in _Proc. 6th Int. Conf. Learn. Representations_, 2018. [33] F. Djeumou, A. P. Vinod, E. Goubault, S. Putot, and U. Topcu, “On-the-fly control of unknown smooth systems from limited data,” in _Proc._ _Amer._ _Control Conf._, 2021, pp. 3656–3663. [34] F. Djeumou, A. Zutshi, and U. Topcu, “On-the-fly, data-driven reachability analysis and control of unknown systems: An F-16 aircraft case study,” in _Proc. 24th Int. Conf. Hybrid Syst., Comput. Control_, 2021, pp. 1–2. [35] T.-Y. Yang, J. Rosca, K. Narasimhan, and P. J. Ramadge, “Projection-based constrained policy optimization,” in _Proc. 8th Int. Conf. Learn. Represen-_ _tations_, 2020. [36] C. Sun, D.-K. Kim, and J. P. How, “FISAR: Forward invariant safe reinforcement learning with a deep neural network-based optimizer,” in _Proc. IEEE Int. Conf. Robot. Autom._, 2021, pp. 10617–10624. [37] J. Tordesillas, B. T. Lopez, and J. P. How, “FASTER: Fast and safe trajectoryplannerforflightsinunknownenvironments,”in _Proc.IEEE/RSJ_ _Int. Conf. Intell. Robots Syst._, 2019, pp. 1934–1940. [38] J. Tordesillas and J. P. How, “MADER: Trajectory planner in multia gent and dynamic environments,” _IEEE_ _Trans._ _Robot._, to be published, [doi: 10.1109/TRO.2021.3080235.](https://dx.doi.org/10.1109/TRO.2021.3080235) [39] J. J. Choi, D. Lee, K. Sreenath, C. J. Tomlin, and S. L. Herbert, “Robust control barrier-value functions for safety-critical control,” _Comput._ _Res._ _Repository (CoRR)_, vol. abs/2104.02808, 2021. [40] F. Castañeda, J. J. Choi, B. Zhang, C. J. Tomlin, and K. Sreenath, “Pointwise feasibility of Gaussian process-based safety-critical control under model uncertainty,” _Comput._ _Res._ _Repository_ _(CoRR)_, vol. abs/2106.07108, 2021. [41] A. Paszke _et_ _al._, “PyTorch: An imperative style, high-performance deep learning library,” in _Proc._ _Adv._ _Neural_ _Inf._ _Process._ _Syst._, 2019, vol. 32, pp. 8026–8037. [42] C. Fan, K. Miller, and S. Mitra, “Fast and guaranteed safe controller synthesis for nonlinear vehicle models,” in _Computer Aided Verification_, S. K. Lahiri and C. Wang, Eds., Cham, Switzerland: Springer, 2020, pp. 629–652. [43] S. M. LaValle _et_ _al._, “Rapidly-exploring random trees: Progress and prospects,” _Algorithmic_ _Comput._ _Robot.,_ _New_ _Directions_, vol. 5, pp. 293–308, 2001. [44] T. I. Fossen, “A survey on nonlinear ship control: From theory to practice,” _IFAC Proceedings Volumes_, vol. 33, no. 21, pp. 1–16, 2000. [45] D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” in _Proc. 3rd Int. Conf. Learn. Representations (ICLR)_, 2015. [46] A. Ray, J. Achiam, and D. Amodei, “Benchmarking safe exploration in deep reinforcement learning,” in _Proc._ _Deep_ _Reinforcement_ _Learn._ _Workshop, Conf. Neural Inf. Process. Sys. (NeurIPS)_, vol. 7, 2019.

섹션 본문 49문단 · 34,740자

(제목 없음)

1Control certificates based on barrier functions have been a powerful tool to generate probably safe control policies for dynamical systems. However, existing methods based on barrier certificates are normally for white-box systems with differentiable dynamics, which makes them inapplicable to many practical applications where the system is a black-box and cannot be accurately modeled. On the other side, model-free reinforcement learning (RL) methods for black-box systems suffer from lack of safety guarantees and low sampling efficiency. In this paper, we propose a novel method that can learn safe control policies and barrier certificates for black-box dynamical systems, without requiring for an accurate system model. Our method re-designs the loss function to back-propagate gradient to the control policy even when the black-box dynamical system is non-differentiable, and we show that the safety certificates hold on the black-box system. Empirical results in simulation show that our method can significantly improve the performance of the learned policies by achieving nearly 100% safety and goal reaching rates using much fewer training samples, compared to state-of-the-art blackbox safe control methods. Our learned agents can also generalize to unseen scenarios while keeping the original performance. The source code can be found at https://github.com/Zengyi-Qin/bcbf.

I. INTRODUCTION

2G UARANTEEING safety is an open challenge in designing control policies for many autonomous robotic systems, ranging from consumer electronics to self-driving cars and aircrafts. In recent years, the development of machine learning (ML) has created unprecedented opportunities to control modern autonomous systems with growing complexity. However, ML also poses great challenges for developing highassurance autonomous systems that are provably dependable. While many learning-based approaches [1], [2], [3], [4] have been proposed to train controllers to accomplish complex tasks with improved empirical performance, the lack of safety certificates for the learning-enabled components has been a fundamental hurdle that blocks the massive deployment of the learned solutions.

3For decades, mathematical control certificates has been used as proofs that the desired properties of the system are satisfied Manuscript received: September 9, 2021; Revised December 11, 2021; Accepted January 5, 2022.

4This paper was recommended for publication by Editor Clement Gosselin upon evaluation of the Associate Editor and Reviewers' comments. This work was supported by the Defense Science and Technology Agency in Singapore, but this article solely reflects the opinions and conclusions of its authors and not DSTA Singapore or the Singapore Government. shows the average result for the two tasks, where the errorbars represent two times the standard deviation. SABLAS exhibits significant improvement in relative safety rate and task completion rate.

5in closed-loop with certain control policies. For example, Control Lyapunov Function [5], [6] and Control Contraction Metrics [7], [8], [9], [10] ensure the existence of a controller under which the system converges to an equilibrium or a desired trajectory. Control Barrier Function [11], [12], [13], [14], [15], [16], [17] ensures the existence of a controller that keeps the system inside a safe invariant set. Classical control synthesis methods based on Sum-of-Squares [18], [12], [19], [20] and linear programs [21], [22] usually only work for systems with low-dimensional state space and simple dynamics. This is because they choose polynomials as the candidate certificate functions, where low-order polynomials may not be a valid certificate for complex dynamical systems and high-order polynomials will increase the number of decision variables exponentially in those optimization problems. Recent data-driven methods [17], [23], [9], [24] have shown significant progress in overcoming the limitations of the traditional synthesis methods. They can jointly learn the control certificates and policies as neural networks (NN). However, data-driven methods that can generate control certificates still require an explicit (or white-box) differentiable model of the system dynamics, as the derivatives of the dynamics are required in the learning process. Finally, many works study the use of control certificates such as CBF to provide safety guarantees during and after training the policies [16], [25], but they more or less requires an accurate model of the system dynamics or a reasonable modeling of the system uncertainties to build the certificates. Many dynamical systems in the real-world are black-box and lack accurate models. The most popular model-free approach to handle such black-box systems is safe reinforcement learning (RL). Safe RL methods enforce safety and performance by maximizing the expectation of the cumulative reward and constraining the expectation of the cost to be less or equal to a given threshold. The biggest disadvantage of safe RL methods is the lack of systematic or theoretically grounded way of designing cost function and reward functions, which heavily rely on empirical trials and errors. The lack of explainable safety guarantees and low sampling efficiency also make safe RL methods difficult to exhibit satisfactory performance.

6Instead of stressing about the trade-off between the strong guarantees from control certificates and the practicability of model-free methods, in this work, we propose SABLAS to achieve both. SABLAS is a general-purpose approach to learning safe control for black-box dynamical systems. SABLAS enjoys the guarantees provided by the safety certificate from CBF theory without requiring for an accurate model for the dynamics. Instead, SABLAS only needs a nominal dynamics function that can be obtained through regressions over simulation data. There is no need to model the error between the nominal dynamics and the real dynamics since SABLAS essentially re-design the loss function in a novel way to backpropagate gradient to the controller even when the black-box dynamical system is non-differentiable. The resulting CBF (and the corresponding safety certificate) holds directly on the original black-box system if the training process converges. The proposed algorithm is easy-to-implement and follows almost the same procedure of learning CBF for white-box systems with minimal modification. SABLAS fundamentally solves the problem that control certificates cannot be learned directly on black-box systems, and opens up the next chapter use of CBF theory on synthesizing safe controllers for blackbox dynamical systems.

7Experimental results demonstrates the superior advantages of SABLAS over leading learning-based safe control methods for black-box systems including CPO [26], PPO-Safe [3] and TRPO-Safe [27], [28]. We evaluate SABLAS on two challenging tasks in simulation: drone control in a city and ship control in a valley (as shown in Fig. 1). The dynamics of the drone and ship are assumed unknown. In both tasks, the controlled agent should avoid collision with uncontrolled agents and other obstacles, and reach its goal before the testing episode ends. We also examine the generalization capability of SABLAS on testing scenarios that are not seen in training. Fig. 1 shows that SABLAS can reach a near 1.0 relative safety rate and task completion rate while using only 1/10 of the training data compared to existing safe RL methods, demonstrating a significant improvement. We also study the effect of model error (between the nominal model and actual dynamics) on the performance of the learned policy. It is shown that SABLAS is tolerant to large model errors while keeping a high safety rate. A detailed description of the results is presented in the experiment section. Video results can be found at supplementary materials.

8To summarize the strength of SABLAS: 1) SABLAS can jointly find a safety certificate (i.e. CBF) and the corresponding control policy on black-box dynamics; 2) Unlike RL-based methods that need tedious trial-and-error on designing the rewards, SABLAS provides a systematic way of learning certified control policy, without parameters (other than the standard hyper-parameters in NN training) that need finetuning. 3) Empirical results that SABLAS can achieve a nearly perfect performance in terms of guaranteeing safety and goalreaching, using much less samples than state-of-the-art safe RL methods.

II. RELATED WORK

9There is a rich literature on controlling black-box systems and safe RL. Due to the space limit, we only discuss a few directly related and commonly used techniques on black-box system control. We will also skip the literature review for the large body of works on model-based safe control and trajectory planning as the research problems we are solving are very different.

A. Controller Synthesis for Black-box Systems

10Proportional-integral-derivative (PID) controller is widely used in controlling black-box systems. The advantage of PID controller is that it does not rely on a model of the system and only requires the measurement of the state. A drawback of PID controller is that it does not guarantee safety or stability, and the system may overshoot or oscillate about the control setpoint. If the underlying black-box system is linear timeinvariant, existing work [29] has presented a polynomial-time control algorithm without relying on any knowledge of the environment. For non-linear black-box systems, the dynamics model can be approximated using system identification and controlled using model-based approaches [30], and PID can be used to handle the error part. The concept of practical relative degree [31] is also proposed to enhance the control performance on systems with heavy uncertainties. Recent advance in reinforcement learning [4], [3], [27], [32] also gives us insight into treating the system as a pure black-box and estimating the gradient for the black-box functions in order to optimize the control variables. However, in safety-critical systems, these black-box control methods still lack formal safety guarantee or certificate.

11Simulation-guided controller synthesis methods can also generate control certificates for black-box systems, and sometimes those certificates can indicate how policies should be constructed [21], [20], [22]. However, most of these techniques use polynomial templates for the certificates, which limits their use on high-dimensional and complex systems. Another line of work studies the use of [33], [34] data-driven reachability analysis, jointly with receding-horizon control to constructed optimal control policies. These methods rely on side information about the black-box systems (e.g. lipschitz constants of the dynamics, monotonicity of the states, decoupling in the states' dynamics) to do the reachability, which is not needed in our method.

B. Safe Reinforcement Learning

12Safe RL [26], [28], [2], [35], [36] extends RL by adding constraints on the expectation of certain cost functions, which encode safety requirements or resource limits. CPO [26] derived a policy improvement step that increases the reward while satisfying the safety constraint. DCRL [2] imposes constraint on state density functions rather than cost value functions, and shows that density constraint has better expressiveness over cost value function-based constraints. RCPO [28] weights the cost using Lagrangian multipliers and add it to the reward. FISAR [36] uses a meta-optimizer to achieve forward invariance in the safe set. A disadvantage of safe RL is that it does not provide safety guarantee, or their safety guarantee cannot be realized in practice. The problem of sampling efficiency and sparsity of cost also increase the difficulty to synthesize safe controller through RL.

C. Safety Certificate and Control Barrier Functions

13Mathematical certificates can serve as proofs that the desired property of the system is satisfied under the corresponding planning [37], [38] and control components. Such certificate is able to guide the controller synthesis for dynamical systems in order to ensure safety. For example, Control Lyapunov Function [5], [6], [24] ensures the existence of a controller so that the system converges to desired behavior. Control Barrier Function [11], [12], [13], [14], [15], [16], [17], [39] ensures the existence of a controller that keep the system inside a safe invariant set. However, the existing controller synthesis with safety certificate heavily relies on a whitebox model of the system dynamics. For black-box systems or system with large model uncertainty, these methods are not applicable. While recent work [40] proposes to learn the model uncertainty effect on the CBF conditions, it still assumes that a handcrafted CBF is given, which is not always available for complex non-linear dynamical systems. Our approach represents a substantial improvement over the existing CBF-based safe controller synthesis strategy. The proposed SABLAS framework simultaneously enjoys the safety certificate from the CBF theory and the effectiveness on black-box dynamical systems.

A. Safety of Black-box Dynamical Systems

14Definition 1 (Black-box Dynamical System). A black-box dynamical system is represented by tuple S, U, f , where S ∈ R n is the state space and U ∈ R m is the control input space. f : S × U → S is the system dynamicsṡ = f (s, u), which is unknown due to the black-box assumption.

15Let S 0 , S g , S s and S d denote the set of initial states, goal states, safe states and dangerous states respectively. The problem we aim to solve is formalized in Definition 2.

16Definition 2 (Safe Control of Black-box Systems). Given a black-box dynamical system modeled as in Definition 1, the safe control problem aims to find a controller π : S → U such that under control input u = π(s) and the unknown dynamicṡ s = f (s, u), the following is satisfied:

17The above definition requires that starting from the initial set S 0 , the system should never enter the dangerous set S d under controller π.

B. Control Barrier Function as Safety Certificate

18A common approach for guaranteeing safety of dynamical systems is via control barrier functions (CBF) [11], which ensures that the state always stay in the safe invariant set. A control barrier function h : S → R satisfies:

19where S p = {s | h(s) ≥ 0}, u = π(s) and α(·) is a class-K function that is strictly increasing and α(0) = 0. It is proven [11] that if there exists a CBF h for a given controller π, the system controlled by π starting from s(0) ∈ S 0 will never enter the dangerous set S d . Besides the formal safety proof in [11], there is an informal but straightforward way to understand the safety guarantee. Whenever h(s) decreases to 0, we haveḣ + α(h) =ḣ ≥ 0, which means h(s) no longer decreases and h(s) < 0 will not occur. Thus s will not enter the dangerous set S d where h(s) < 0.

C. Co-learning Controller and CBF for White-box Systems

20For white-box dynamical systems where f (s, u) is known, we can jointly synthesize the controller π and it safety certificate h that satisfy CBF conditions (2) via a learningbased approach. We model π and h as neural networks with parameters Θ and Ω. Given a dataset D of the state samples in S, the CBF conditions (2) can be translated into empirical loss functions:

21Each of the loss functions in (3) corresponds to a CBF condition in (2). In addition to safety, we also consider goalreaching by penalize the difference between the safe controller π and the goal-reaching nominal controller π nom in (4). The synthesis of π nom is well-studied and is not the contribution of our work.

22The total loss function is L 0 (Ω)+L d (Ω)+L p (Ω, Θ)+λL g (Θ), where λ is a constant that balances the goal-reaching and safety objective. The total loss function is minimized via stochastic gradient descent to find the parameters Ω and Θ. The dataset D is not fixed during training and will be periodically updated with new samples by running the current controller. When the loss L 0 + L d + L p converges to 0, the resulting controller π(s; Θ) and CBF h(s; Ω) will satisfy (2) on unseen testing samples with a generalization bound as proven in [17]. Therefore, a safe controller and the corresponding CBF is found for the white-box system. However, for black-box dynamical systems where f (s, u) is unknown, the co-learning method for safe controller and CBF described above is no longer applicable. In Section IV, we propose an important and easy-to-implement modification to (3) such that we can leverage similar co-learning framework to jointly synthesize the safe controller and its corresponding CBF as safety certificate.

IV. LEARNING CBF ON BLACK-BOX SYSTEMS

23In this section, we first elaborate on why it is difficult to learn the safe controller and its CBF for black-box dynamical systems. Then we will propose an important and easy-toimplement re-formulation of the optimization objective, which makes learning safe controller in black-box systems as easy as in white-box systems.

A. Challenges in Black-box Dynamical Systems

24Among the three loss functions L 0 , L d and L p in (3), L p is the only one that can propagate gradient to the controller parameter Θ. The main challenge of training safe controller with its CBF for black-box dynamical systems is that the gradient can no longer be back-propagated to Θ when f is unknown. Therefore, a safe controller cannot be trained by minimizing the loss functions in (3).

25Given state samples s(t) and s(t + ∆t) from the black-box system where ∆t is a sufficiently small time interval, we can approximateḣ and compute L p as:

26L p1 does give the value of L p , but its backward gradient flow to the controller is cut off by the black-box system that is nondifferentiable. (5) can only be used to train CBF h but not the safe controller π. Even worse, the h obtained by minimizing (5) does not guarantee that a corresponding safe controller π exists. If we have an differential expression of dynamics f and replace h(s(t + ∆t)) with h(s(t) + f (s(t), π(s(t)))∆t), the gradient flow can successfully reach π(s) and update the controller parameter. However, this is not immediately possible because f is unknown by the black-box assumption.

27A possible way to back-propagate gradient to π is to use a differentiable nominal model f nom . There are many methods to obtain f nom , such as fitting a neural network using sampled data from the real black-box system. We do not require f nom to perfectly match the real dynamics f , because there will always exist an error between them. With f nom , we can approximate L p as:

28which is differentiable w.r.t. π(s) because both h and f nom are differentiable. The gradient of L p2 can be back-propagated to the controller to update its parameters. However, whatever way we get f nom , there still exists an error between the real dynamics f and f nom , which meansḣ 2 is not a good approximation ofḣ and L p2 is not the true value of L p . Using L p2 , it is not guaranteed that the third CBF condition in (2) will be satisfied.

B. Learning Safe Control for Black-box Dynamics

29We present a novel re-formulation of L p that makes learning safe controller with CBF for black-box dynamical systems as easy as in white-box systems. The proposed formulation possesses two features: it enables the gradient to backpropagate to the controller in training, and offers an error-free approximation ofḣ.

30Given state samples s(t) and s(t + ∆t) from the trajectories of the real black-box dynamical system, where ∆t is a sufficiently small time interval, we define s nom (t + ∆t) as : s nom (t + ∆t) = s(t) + f nom (s(t), π(s(t)))∆t, then constructs(t + ∆t) as: s(t + ∆t) = s nom (t + ∆t) + g(s(t + ∆t) − s nom (t + ∆t)),

31where g(s) = s is an identity function but without gradient. We need to pretend that g(s) is a constant and in back-propagation, the gradient on g(s) cannot propagate to its argument s. In PyTorch [41], there is an off-the-shelf implementation of g(s) as g(s) = s.detach(), which cuts off the gradient from g to s in back-propagation. Then we approximate L p using:

32Theorem 1. ∇ Θ L p3 exists and lim ∆t→0 L p3 = L p . Namely, L p3 is differentiable w.r.t. the controller parameter Θ, and L p3 is an error-free approximation of L p as ∆t → 0.

33Proof. Since f nom is differentiable, s nom ands(t + ∆t) are differentiable w.r.t. π,ḣ 3 and L p3 are also differentiable w.r.t. π and its parameter Θ. Thus, ∇ Θ L p3 exists. Furthermore, sinces(t + ∆t) = s(t + ∆t),ḣ 3 is an error-free approximation of the realḣ when ∆t → 0. Thus L p3 is also an error-free approximation of L p when ∆t → 0.

34Note that Theorem 1 reveals the reason why the proposed SABLAS method can jointly learn the CBF and the safe controller for black-box dynamical system. First, since ∇ Θ L p3 exists, the gradient from L p3 can be back-propagated to the controller parameters to learn a safe controller. On the contrary,ḣ 1 is not differentiable w.r.t. π so L p1 cannot be used to train the controller. Second, since L p3 is a good approximation of L p , minimizing L p3 contributes to the minimization of L p and the satisfaction of the third CBF condition in (2). On the contrary,ḣ 2 is an inaccurate approximation ofḣ as we elaborated in Section IV-A. The construction of L p3 incorporates the advantages of L p1 and L p2 , and avoids the disadvantages of L p1 and L p2 at the same time. The computational graph of L p3 is illustrated in Fig. 2, which shows the forward pass and the backward gradient propagation from L p3 to controller π. Remark 1. One may argue that the gradient received by π via minimizing L p3 is not exactly the gradient it should receive if we had a perfect differentiable model of the blackbox system. Despite this, minimizing L p3 directly contributes to the satisfaction of the third CBF condition in (2). A safe controller and its CBF can be found to keep the system within safe set.

35Remark 2. Although the current formulation of L p3 leads to promising performance in simulation as we will show in experiments, L p3 requires further consideration in hardware experiments. Directly using the future state s(t + ∆t) to calculate the time derivative of h or s is not always desirable because noise will possibly dominate the numerical differentiation. When the noise dominates the time derivative of s or h, the training will have convergence issues. But a moderate noise is actually beneficial to training, because our optimization objective makes the CBF conditions hold even under noise disturbance, which increases the robustness of the trained CBF and controller. On physical robots where noise dominates the numerical differentiation, one can incoperate filtering techniques to mitigate the noise.

36Combining with the loss functions L 0 , L d and L g in (3) and (4), the total loss function can be formulated as: for j = 1, 2, · · · , K do where λ is a constant balancing the safety and goal-reaching objective. L is minimized via stochastic gradient descent. Algorithm 1 summarizes the learning process of the safe controller and the corresponding safety certificate (CBF) for black-box dynamical systems. The RUN function runs the black-box system using the controller π under initial condition s(0), and returns the trajectory data. The UPDATE function updates parameters Ω, Θ by minimizing L(Ω, Θ) using the state samples in D via gradient descent.

V. EXPERIMENT

37The primary objective of our experiment is to examine the effectiveness of the proposed method in terms of safety and goal-reaching when controlling black-box dynamical systems. We will conduct comprehensive experiments on two simulation environments illustrated in Fig.1 (a) and (b), and compare with state-of-the-art learning-based control methods for blackbox systems.

38A. Task Environment Description a) Drone control in a city (CityEnv): In our first case study, we consider the package delivery task in a city using drones, as is illustrated in Fig. 1 (a). There is one controlled drone and 1024 non-player character (NPC) drones that are not controlled by our controller. In each simulation episode, each drone is assigned a sequence of randomly selected goals to visit. The aim of our controller is to make sure the controlled drone reach its goals while avoiding collision with NPC drones at any time. A reference trajectory s ref (t), t ∈ [0, T ] will be given, which sequentially connects the goals and avoid collision with buildings. The reference trajectory can be generated by any off-the-shelf single-agent path planning algorithm. We use FACTEST [42] in our implementation, and other options such as RRT [43] are also suitable. The reference path planner does not need to consider the dynamic obstacles, such as the moving NPCs in our experiment. A nominal controller π norm will also be given, which outputs control commands that drive the drone to follow the reference trajectory. However, π norm is purely for goal-reaching and does not consider safety. Fig. 3. Quantitative results of relative safety rate, task completion rate and tracking error. The center points are mean and error bars represent standard deviations. Results are collected over 50 random runs on each method. The first row is for drone control in CityEnv and the second row is for ship control in ValleyEnv. Our method reaches a high task completion rate and relative rate at the same time, while keeping a low tracking error.

39The CityEnv has two modes: with static NPCs and moving NPCs. If the NPCs are static, they will constantly stay at their initial locations. If the NPCs are moving, they will follow pre-planned trajectories to sequentially visit their goals.

40where θ x and θ y are row and pitch angles. The control inputs are the angular acceleration of θ x , θ y and the vertical thrust. The underlying model dynamics is from [17] and assumed unknown to the controller and CBF in our experiment. b) Ship control in a valley (ValleyEnv): In our second case study, we consider task of controlling a ship in valley illustrated in Fig. 1 (b). There are one controlled ship and 32 NPC ships. The number of NPCs in ValleyEnv is less than CityEnv because ships are large in size and inertia, and hard to maneuver in dense traffic. Also, different from the 3D CityEnv, ValleyEnv is in 2D, which means the agents have fewer degrees of freedom to avoid collision. The initial location and goal location of each ship is randomly initialized at the beginning of each episode. The aim of our controller is to ensure the controlled ship reach its goal and avoid collision with NPC ships. Similar to CityEnv, a reference trajectory and nominal controller will be provided. There are also two modes in ValleyEnv, including the static and moving NPC mode, as is in CityEnv. The ship model is with state space [x, y, θ, u, v, ω], where θ is the heading angle, u, v are speed in the ship body coordinates, and ω is the angular velocity of the heading angle. The ship model is from Sec. 4.2 of [44] and is unknown to the controller and CBF.

B. Evaluation Criteria

41Three evaluation criteria are considered. Relative safety rate measures the improvement of safety comparing to a nominal controller that only targets at goal-reaching but not safety. To formally define the relative safety rate, we first consider the absolute safety rate α as α = 1 T T 0 I(s(t) ∈ S d ) dt, which measures the proportion of time that the system stays outside the dangerous set. Given two control policies π 1 and π 2 with absolute safety rate α 1 and α 2 , the relative safety rate of π 1 w.r.t. π 2 is defined as β 12 = α1−α2 1−α2 ∈ (−∞, 1]. If β 12 = 0, then control policy π 1 does not have any improvement over π 2 in terms of safety. If β 12 = 1, then π 1 completely guarantees safety of the system in t ∈ [0, T ]. In our experiment, π 1 is the controller to be evaluated, and π 2 is the nominal controller π norm that only accounts for goal-reaching without considering safety. Task completion rate is defined as the success rate of reaching the goal state before timeout. Tracking error is the average deviation of the system's state trajectory comparing to a pre-planned reference trajectory s ref (t), t ∈ [0, T ] as γ = 1

C. Baseline Approaches

42In terms of safe control for black-box systems, the most recent state-of-the-art approaches are safe reinforcement learning (safe RL) algorithms. We choose three safe RL algorithms for comparison: CPO [26] is a general-purpose policy optimization algorithm for black-box systems that maximizes the expected reward while satisfying the safety constraints. PPO-Safe is a combination of PPO [3] and RCPO [28]. It uses PPO to maximize the expected cumulative reward while leveraging the Lagrangian multiplier update rule in RCPO to enforce the safety constraint. TRPO-Safe is a combination of TRPO [27] and RCPO [28]. The expected reward is maximized via TRPO and the safety constraints are imposed using the Lagrangian multiplier in RCPO.

D. Implementation and Training

43Both the controller π and CBF h are multi-layer perceptrons (MLP) with architecture adopted from Sec. 4.2 of [17]. π and h not only take the state of the controlled agent as input, but also the states of 8 nearest NPCs that the controlled agent can observe. In Algorithm 1, we choose K = 1, N = 2000. The total number of state samples collected during training is 10 6 . In UPDATE of the algorithm, we use the Adam [45] optimizer with learning rate 10 −4 and batch size 1024. The gradient descent runs for 100 iterations in UPDATE. The nominal model dynamics are fitted from trajectory data in simulation. We used 10 4 state samples to fit a linear approximation of the drone dynamics, and 10 5 samples to fit a non-linear 3-layer MLP as the ship dynamics.

44In training the safe RL methods, the reward in every step is the negative distance between the system's current state and the goal state, and the cost is 1 if the system is within the dangerous set S d and 0 otherwise. The threshold for expected cost is set to 0, which means we wish the system never enter the dangerous set (never reach a state with a positive cost). During training, the agent runs the system for 10 7 timesteps in total and performs 2000 policy updates. In each policy update, 100 iterations of gradient descent are performed. The implementation of the safe RL methods is based on [46].

45All the methods are trained with static NPCs and tested on both static and moving NPCs. We believe this can make the testing more challenging and examine the generalization capability of the tested methods in different scenarios. All the agents are assigned random initial and goal locations in every simulation episode, which prevents the learned controller from overfitting a single configuration.

E. Experimental Results

46a) Safety and goal-reaching performance: Results are shown in Fig. 3. Among the compared methods, our method is the only one that can reach a high task completion rate and relative safety rate at the same time. For other methods such as TRPO-Safe, when the controlled drone or ship is about to hit the NPCs, the learned controller tend to brake and decelerate. Thus, the agent is less likely to reach its goal when a simulation episode ends. The task completion rate and safety rate are opposite to each other for CPO, PPO-Safe and TRPO-Safe. On the contrary, the controller obtained by our method can maneuver smoothly among NPCs without severe deceleration. This enables the controlled agent to reach the goal location on time. Our method can also keep a relatively low tracking error, which means the difference between actual trajectories and reference trajectories is small. b) Generalization capability to unseen scenarios: As is stated in Sec. V-D, the NPCs are static in training and can be either static or moving in testing. Fig. 3 also demonstrates that our method has promising generalization capability across different training and testing scenarios. c) Sampling efficiency: In Fig. 4 (a), we show the safety performance under different sizes of the training set. The results are averaged over the drone and ship control tasks. SABLAS only needs around 1/10 of the samples required by the compared methods to achieve a nearly perfect relative safety rate. Note that SABLAS requires an extra 10 4 to 10 5 samples to fit the nominal dynamics, but this does not change the fact that the total number of samples needed by SABLAS is much fewer than the baselines.

47d) Effect of model error: We investigate the influence of the model error ||ṡ −ṡ nom || between the real dynamics and the nominal dynamics on the safety performance. We change the modeling error of the drone model and test the learning controller on CityEnv with static NPCs. We also perform an ablation study where we use L p2 in Eqn. 6 instead of L p3 in Eqn. 7 as loss function. The red curve in Fig. 4 (b) show that SABLAS is tolerant to large model errors while exhibiting a promising safety rate. In our previous experiments, the model error e = E[||ṡ −ṡ nom ||]/E[||ṡ||] is always less than 0.2. We did not encounter any difficulty fitting a nominal model with empirical error e ≤ 0.2. The orange curve in Fig. 4 (b) shows that if we use L p2 in Eqn. 6, the trained controller will have a worse performance in terms of safety rate. This is because L p2 only uses the nominal dynamics to calculate the loss, without leveraging the real black-box dynamics.

F. Discussion on Limitation

48The main limitation of the proposed approach is that it cannot guarantee the satisfaction of the CBF conditions in (2) in the entire state space. Even if we minimize L 0 , L d and L p3 to 0 during training, the CBF conditions may still be occasionally violated during testing. After all, the training samples are finite and cannot cover the continuous state space. If the testing distribution and training distribution are the same, one can leverage the Rademacher complexity to give an error bound that the CBF conditions are violated, as is in Appendix B of [17]. But if the testing distribution is different from training, it is still unclear to derive the generalization error of the CBF conditions. To train CBF and controller that provably satisfy the CBF conditions, one can also use verification tools to find the counterexamples in the state space that violates the CBF conditions and add those counterexamples to the training set [24], [23]. The process is finished when no more counterexample can be found. However, the time complexity of the verification makes it not applicable for large and expressive neural networks. Also, the error between the nominal and real dynamics will have a negative impact on the safety performance. These limitations are left for future work.

VI. CONCLUSION AND FUTURE WORKS

49We presented SABLAS, a general-purpose safe controller learning approach for black-box systems, which is supported by the theoretical guarantees from control barrier function theory, and at the same time is strengthened using a novel learning structure so it can directly learn the policies and barrier certificates for black-box dynamical systems. Simulation results show that SABLAS indeed provides a systematic way of learning safe control policies with a great improvement over safe RL methods. For future works, we plan to study SABLAS on multi-agent systems, especially with adversarial players.

참고문헌 30건

  1. Robust Nonlinear Control Design Birkhäuser Boston eBooks · Birkhäuser Boston · 1996 10.1007/978-0-8176-4759-9
  2. Control barrier function based quadratic programs with application to adaptive cruise control 2014 10.1109/cdc.2014.7040372
  3. Simulation-guided lyapunov analysis for hybrid dynamical systems 2014 10.1145/2562059.2562139
  4. COMPLEX CONTINUOUS NONLINEAR SYSTEMS: THEIR BLACK BOX IDENTIFICATION AND THEIR CONTROL IFAC Proceedings Volumes · Elsevier BV · 2006 10.3182/20060329-3-au-2901.00062
  5. Practical relative degree in black-box control 2012 10.1109/cdc.2012.6427040
  6. Local stability analysis using simulations and sum-of-squares programming Automatica · Elsevier BV · 2008 10.1016/j.automatica.2008.03.010
  7. Contraction Analysis of Nonlinear Systems 1999
  8. A tutorial on sum of squares techniques for systems analysis 2005 10.1109/acc.2005.1470374
  9. Control Barrier Certificates for Safe Swarm Behavior IFAC-PapersOnLine · Elsevier BV · 2015 10.1016/j.ifacol.2015.11.154
  10. Control Barrier Function Based Quadratic Programs for Safety Critical Systems IEEE Transactions on Automatic Control · Institute of Electrical and Electronics Engineers · 2016 10.1109/tac.2016.2638961
  11. A survey on Nonlinear Ship Control: from Theory to Practice IFAC Proceedings Volumes · Elsevier BV · 2000 10.1016/s1474-6670(17)37044-1
  12. Learning control lyapunov functions from counterexamples and demonstrations Autonomous Robots · Springer Science+Business Media · 2018 10.1007/s10514-018-9791-9
  13. Control Contraction Metrics: Convex and Intrinsic Criteria for Nonlinear Feedback Design IEEE Transactions on Automatic Control · Institute of Electrical and Electronics Engineers · 2017 10.1109/tac.2017.2668380
  14. End-to-End Safe Reinforcement Learning through Barrier Functions for Safety-Critical Continuous Control Tasks Proceedings of the AAAI Conference on Artificial Intelligence · Association for the Advancement of Artificial Intelligence · 2019 10.1609/aaai.v33i01.33013387
  15. Control Barrier Functions: Theory and Applications 2019 10.23919/ecc.2019.8796030
  16. FASTER: Fast and Safe Trajectory Planner for Flights in Unknown Environments 2021 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS) · 2019 10.1109/iros40897.2019.8968021
  17. Neural Contraction Metrics for Robust Estimation and Control: A Convex Optimization Approach IEEE Control Systems Letters · Institute of Electrical and Electronics Engineers · 2020 10.1109/lcsys.2020.3001646
  18. Guaranteed Obstacle Avoidance for Multi-Robot Operations With Limited Actuation: A Control Barrier Function Approach IEEE Control Systems Letters · Institute of Electrical and Electronics Engineers · 2020 10.1109/lcsys.2020.3000748
  19. Fast and Guaranteed Safe Controller Synthesis for Nonlinear Vehicle Models Lecture notes in computer science · Springer Science+Business Media · 2020 10.1007/978-3-030-53288-8_31
  20. KETO: Learning Keypoint Representations for Tool Manipulation 2020 10.1109/icra40945.2020.9196971
  21. Rapidly-Exploring Random Trees: Progress and Prospects 2001 10.1201/9781439864135-43
  22. Safe Multi-Agent Interaction through Robust Control Barrier Functions with Learned Uncertainties 2021 60th IEEE Conference on Decision and Control (CDC) · 2020 10.1109/cdc42340.2020.9304395
  23. Robust Control Barrier–Value Functions for Safety-Critical Control 2021 60th IEEE Conference on Decision and Control (CDC) · 2021 10.1109/cdc45484.2021.9683085
  24. On-the-fly, data-driven reachability analysis and control of unknown systems 2021 10.1145/3447928.3457355
  25. Pointwise Feasibility of Gaussian Process-based Safety-Critical Control under Model Uncertainty. arXiv (Cornell University) · Cornell University · 2021
  26. Lyapunov-stable neural-network control 2021 10.15607/rss.2021.xvii.063
  27. MADER: Trajectory Planner in Multiagent and Dynamic Environments IEEE Transactions on Robotics · Institute of Electrical and Electronics Engineers · 2021 10.1109/tro.2021.3080235
  28. On-The-Fly Control of Unknown Smooth Systems from Limited Data 2022 American Control Conference (ACC) · 2021 10.23919/acc50511.2021.9483367
  29. FISAR: Forward Invariant Safe Reinforcement Learning with a Deep Neural Network-Based Optimizer 2021 10.1109/icra48506.2021.9561147
  30. Nonlinear Control Systems Communications and control engineering/Communications and control engineering series · 1995 10.1007/978-1-84628-615-5