## 6 Controller Design
### Exponential Control Barrier Function as a Safety Filter  
In this section, an ECBF-based safety filter is introduced to prevent collisions with the human operator by constraining the trajectory generated by NMPC to be in a safe zone. ECBFs are formally defined as follows:  
**Definition 1** (ECBF [40]).: _Consider the system (8) and a set \(\mathcal{C}=\{\mathbf{x}\in\mathbb{R}^{3}|h(t,\mathbf{x})\geq 0,\forall t>0\}\) defined by a continuously differentiable function \(h(t,\mathbf{x}):\mathbb{R}^{3}\to\mathbb{R}\) with relative degree \(\kappa\geq 2\). Then, \(h(t,\mathbf{x})\) is an exponential control barrier function (ECBF) if there is a \(\mathbf{k}_{b}\in\mathbb{R}^{\kappa-1}\), such that_  
\[\inf_{\mathbf{u}\in\mathcal{U}}[L_{f}^{K}h(t,\mathbf{x})+L_{g}L_{f}^{K-1}h(t,\mathbf{x}) \mathbf{u}+\mathbf{k}_{b}\mathbf{\zeta}_{\mathbf{b}}(\mathbf{x})\geq 0, \tag{24}\]  
_where \(\mathbf{\zeta}_{\mathbf{b}}\) can be written as_  
\[\mathbf{\zeta}_{b}(\mathbf{x}):=\begin{bmatrix}h(\mathbf{x})\\ \dot{h}(\mathbf{x})\\ \vdots\\ h^{(\kappa-1)}(\mathbf{x})\end{bmatrix}=\begin{bmatrix}h(\mathbf{x})\\ L_{f}h(\mathbf{x})\\ \vdots\\ L_{f}^{(\kappa-1)}h(\mathbf{x})\end{bmatrix}. \tag{25}\]  
_The method for selecting \(\mathbf{k}_{b}\) is detailed in [40]. The Lie derivative of \(h(\mathbf{x})\) along \(f(\mathbf{x})\) is defined as_  
\[L_{f}h(t,\mathbf{x})=\frac{\partial h(t,\mathbf{x})}{\partial\mathbf{x}}\mathbf{f}(\mathbf{x}, \dot{\mathbf{x}}), \tag{26}\]  
_where \(\mathbf{x}\) is the state of the system. The Lie derivative of \(h(\mathbf{x})\) along \(\mathbf{g}(\mathbf{x})\) is defined as \(L_{g}h(t,\mathbf{x})\)._  
Denote \(\mathbf{p}_{oi}(t)\in\mathbb{R}^{3}\) as the support point (i.e., a point on the boundary of the convex set that is closest to the robot) on the convex set representing the area of the human obstacle for the \(i^{th}\) robot joint computed by GJK at time \(t\). To ensure the robot does not collide with the moving human, the Cartesian position of the robot joints \(\mathbf{x}_{i}\in\mathbb{R}^{3}\), \(i\in\mathbb{N}_{[1,7]}\) are under the following constraints  
\[\|\mathbf{x}_{i}(t)-\hat{\mathbf{p}}_{s}(t)\|_{2}>d_{\text{safe}},\text{ for }i\in\mathbb{N}_{[1,7]},\ t\geq 0, \tag{27}\]  
where \(\hat{\mathbf{p}}_{s}\) is a support point on the boundary of the capsule with the minimum distance to the \(i^{\text{th}}\) robot joint, as shown in Figure 3. We define a candidate ECBF \(h_{i}(t,\mathbf{x}_{i})\) as  
\[h_{i}(t,\mathbf{x}_{i})=\|\mathbf{x}_{i}(t)-\hat{\mathbf{p}}_{s}(t)\|_{2}^{2}-d_{\text{safe }}^{2}. \tag{28}\]  
To modify the applied forces, \(\mathbf{f}_{\mathbf{h}}\), to guarantee safety, a quadratic programming (QP)-based safety filter is employed. Considering the position constraints with relative degree 2, the optimization problem can be formulated as minimizing the normed difference between \(\mathbf{f}_{\mathbf{h}}\) and the actual input \(\mathbf{u}_{\text{act}}\), in order to maintain the robot within the safety region. In other words, \(\mathbf{u}_{\text{act}}(\mathbf{x},t)\) is the control input that minimizes the following QP:  
\[\operatorname*{minimize}_{\mathbf{u}_{\text{act}}\in\mathcal{U}}\|\mathbf{f}_{\mathbf{h}} -\mathbf{u}_{\text{act}}\|^{2},\] (29a) subject to \[L_{f}^{2}h_{i}(t,\mathbf{x})+L_{g}L_{f}h_{i}(t,\mathbf{x})\mathbf{u}_{\text{ act}}+k_{1}h_{i}(t,\mathbf{x})\] \[\qquad+k_{2}L_{f}h_{i}(t,\mathbf{x})\geq 0,i\in\mathbb{N}_{[1,7]}, \tag{29b}\]  
where \(h_{i}(t,\mathbf{x})\) is as defined in (28). The robot joint torques are then obtained as \(\mathbf{\tau}_{\text{act}}=J^{\intercal}(\mathbf{q})\mathbf{u}_{\text{act}}\). Further details on the implementation of ECBFs are given in [40].