## 3 Impedance-Based Assist-as-Needed Controller
### Design of the Controller
Firstly, the reference position \(P_{ref}\) was defined  
Figure 5: Schematic diagram of enhancing the spatial virtual fault-tolerant region. Figure 6: The concept of the FTR (simplified to a planar circular case) in the assist-as-needed (AAN) controller. based on the distance \(d\) between actual position of patient's hand and the nearest point on predetermined trajectory:  
\[d=\left(\sum_{i=1}^{3}\left|P_{NN}(R)^{(i)}-P_{act}(i)\right|^{2}\right)^{\frac{1 }{2}} \tag{11}\]  
\[P_{ref}:\left\{ \begin{array}{ll}P_{act}&d<R_{W}\\ \left|P_{act}-P_{ref}\right|=2(d-R_{W})&R_{W}<d<2R_{W}\\ P_{NN}&d>2R_{W}\end{array} \right. \tag{12}\]  
As shown in Figure 6, the red dashed line is the boundary of the FTR. When the patient's arm is moving inside the FTR, the reference point at this time is the actual point itself--for example, the point \(f_{3}\) in Figure 6. When the patient's hand deviates from the FTR but does not exceed \(R_{W}\), the reference point is calculated by Equation (12), such as the point \(f_{1}\) in Figure 6. When the deviation of the patient's arm from the FTR exceeds the radius \(R_{W}\), the reference point at this time is the nearest point on the predetermined trajectory, such as the point \(f_{2}\) in Figure 6. Finally, when the patient's hand is at the end of the trajectory \(R\), the reference point is the endpoint of the trajectory, such as the point \(f_{4}\) in Figure 6. For any trajectory \(R\), the distance between current position and the nearest position should be greater than the radius of curvature of \(P_{NN}\) on the trajectory:  
\[\kappa<\frac{1}{\left|P_{act}-P_{NN}\right|}\quad\forall P_{act}\in W \tag{13}\]  
where \(\kappa\) is the curvature radius and \(W\) is the point reachable by the manipulator. After defining the reference point \(P_{ref}\), the distance \(d\) is solved to judge if the patient's hand deviates from the predetermined trajectory or not, which is used to approximately evaluate the patient's upper limb functional ability. The distance \(\Delta L\) between the actual position of the hand and the reference position is used to calculate the time-varied assistance force provided by the robot:  
\[\Delta L=\left(\sum_{i=1}^{3}\left|P_{ref}(R)^{(i)}-P_{act}(i)\right|^{2} \right)^{\frac{1}{2}} \tag{14}\]  
According to Equation (9), an assistance force field \(F_{assist}\) distributed around the FTR is:  
\[F_{assist}=\left(K_{tun}\cdot\Delta L\right)\cdot\overset{\rightarrow}{n} \tag{15}\]  
\[\overset{\rightarrow}{n}=\frac{P_{ref}(R)-P_{act}}{\left|P_{ref}(R)-P_{act} \right|} \tag{16}\]  
where \(F_{assist}\) is the assistance force and \(K_{tun}\) is the stiffness for the FTR. According to the distance by which the patient deviates from the predetermined trajectory, the controller in reference [43] constructs a rigid wall with fixed stiffness to assist the patient's arm by controlling the robot. In the controller proposed in this paper, the concept of the stiffness field is proposed and then the stiffness field is constructed within the scope of the width \(R_{W}\) around the FTR. Assuming that the gradient of the stiffness field is \(\Phi\), a series of columnar virtual stiffness walls are constructed. For example, the thin black solid line and the thick black solid line outside FTR in Figure 6; the thicker the line, the greater the stiffness of the wall. When the patient's arm deviates from the FTR, a series of stiffness walls generated by the robot would provide a corresponding assistance force according to the patient's functional ability. The greater the deviation of the patient's hand, the greater the hardness of the stiffness wall, which could further improve the assistance effect of the manipulator. The stiffness \(K_{tun}\) of these columnar walls can be solved based on the position of the patient's arm according to Equations (17) and (18):  
\[\Phi=\frac{K_{1}-K_{0}}{R_{W}} \tag{17}\]  
\[K_{tun}=\left\{ \begin{array}{lr}K_{2}&d\leq R_{W}\\ K_{0}+|d-R_{W}|\cdot\Phi&R_{W}<d<2R_{W}\\ K_{1}&d\geq 2R_{W}\end{array} \right.