# Multi-Layered Interactive Target Guidance with Visual Safety in Convex-Shaped Obstacle Environments
## 3 Safety Layer for Visual Safety
### Control Barrier Functions  
Here, control barrier functions, which form the core of the method proposed in this paper, are first introduced. Consider the control affine system  
\[\dot{x}=f(x)+g(x)u, \tag{21}\]  
where \(x\in\mathbb{R}^{N}\), \(u\in U\subseteq\mathbb{R}^{M}\), and \(f,g\) are locally Lipschitz continuous. A set \(\mathcal{C}\subset\mathbb{R}^{N}\) is said to be forward invariant if \(x(t)\in\mathcal{C}\) holds for all \(t\geq 0\). If the set \(\mathcal{C}\) represents the safety set of the system (21) and becomes forward invariant, the system is said to be safe. Next, suppose that the set \(\mathcal{C}\) is defined by a continuously differentiable function \(h:\mathbb{R}^{N}\to\mathbb{R}\) as  
\[\mathcal{C}(x)\coloneqq\{x\in\mathbb{R}^{N}\mid h(x)\geq 0\}. \tag{22}\]  
Then, the definition of control barrier functions is introduced. **Definition 3** ([32] Definition 5). : _Given a dynamical system (21) and a set \(\mathcal{C}\) defined in (22), a continuously differentiable function \(h:\mathcal{D}\to\mathbb{R}\) is a control barrier function defined on \(\mathcal{D}\) with \(\mathcal{C}\subseteq\mathcal{D}\subset\mathbb{R}^{N}\), if there exists an extended class \(\mathcal{K}\) function (A continuous function \(\alpha:(-b,a)\to(\infty,\infty)\) is said to belong to an extended class \(\mathcal{K}\) for some \(a,\ b>0\) if it is strictly increasing and \(\alpha(0)=0\)[32] ([Definition 2] ).) \(\alpha\) such that_  
\[\sup_{u\in U}\Bigl{[}L_{f}h(x)+L_{g}h(x)u+\alpha(h(x))\Bigr{]} \geq 0,\ \ \forall x\in\mathcal{D}. \tag{23}\]  
Note that \(L_{f}h\coloneqq\frac{\partial h}{\partial x}f\), \(L_{g}h\coloneqq\frac{\partial h}{\partial x}g\) are the Lie derivative of \(h\) in the directions of the vector fields \(f\) and \(g\), respectively. Based on Definition 3, we define the set of admissible input  
\[K(x)\coloneqq\Bigl{\{}u\in U\mid L_{f}h(x)+L_{g}h(x)u+\alpha(h(x)) \geq 0\Bigr{\}}. \tag{24}\]  
The following lemma ensures that \(\mathcal{C}\) is rendered forward invariant by a feedback controller \(u(x)\in K(x)\). **Lemma 1** ([32] Corollary 2). : _Suppose that \(h(x)\) is a control barrier function and \(\frac{\partial h}{\partial x}(x)\
eq 0\) for all \(x\in\partial\mathcal{C}\). Then, any Lipschitz continuous controller \(u(x)\in K(x)\) will render \(\mathcal{C}\) forward invariant, i.e., \(x(0)\in\mathcal{C}\Rightarrow x(t)\in\mathcal{C}\ \forall t\geq 0\)._  
Based on this lemma, the controller that guarantees the safety of the system (21) is synthesized. Let \(k(x)\) be a feedback controller. Then, inputs from the controller \(k(x)\) can be minimally modified so that the modified input \(u\) satisfies \(u(x)\in K(x)\) even if \(k(x)\
otin K(x)\). The modified controller \(u(x)\) can be obtained by solving the quadratic programming (QP) problem:  
\[ \begin{split} u(x)=\operatorname*{argmin}_{u\in U}& \|u-k(x)\|^{2}\\ \text{subject to}& L_{f}h(x)+L_{g}h(x)u\geq-\alpha(h( x)).\end{split}  \tag{25}\]We can guarantee multiple levels of safety for the superlevel sets of control barrier functions \(h_{1},h_{2},\ldots,h_{n}\) in the same way. Consider input sets \(K^{i}\) (\(i=1,2,\ldots,n\)), defined as  
\[K^{i}\coloneqq\Big{\{}u\in U\mid L_{f}h_{i}(x)+L_{g}h_{i}(x)u+\alpha_{i}(h_{i}( x))\geq 0\Big{\}}. \tag{26}\]  
A controller \(u\in\bigcap_{i=1}^{n}K^{i}\) renders the intersect of the safe sets \(\bigcap_{i=1}^{n}\{x\mid h_{i}(x)\geq 0\}\) forward invariant. The minimally modified input is obtained by solving the following quadratic program with several constraints:  
\[ \begin{split} u(x)&=\operatorname*{argmin}_{u\in U} \qquad\|u-k(x)\|^{2}\\ &\text{subject to}\quad L_{f}h_{i}(x)+L_{g}h_{i}(x)u\geq-\alpha(h_{i}( x)),\ \ \forall i=1,2,\ldots,n.\end{split}  \tag{27}\]  
The advantage of using an optimization-based controller with control barrier functions is that it allows for the incorporation of safety considerations into an already designed controller \(k(x)\) by adding functionality. Additionally, (25) and (27) require solutions to be computed at each time step.