# Development and Assist-As-Needed Control of an End-Effector Upper Limb Rehabilitation Robot
## 3 Assist-As-Needed Control of the EULRR
### Assist-As-Needed Control Based on Cartesian Impedance Control
To better define the reference position, it is necessary to search the smallest Euclidean distance between the target trajectory and the current point of motion \(P_{NN}\):  
\[R:\|P_{NN}(R)-P_{act}\|^{2}\overset{!}{=}min \tag{12}\]  
Then, the reference position is defined according to the spatial geometric distance \(d\) between the nearest point \(P_{NN}\) and the actual point \(P_{act}\):  
\[d=\left(\sum_{i=1}^{3}\left|P_{NN}(R)^{(i)}-P_{act}{}^{(i)}\right|^{2}\right) ^{\frac{1}{2}} \tag{13}\]  
\[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{14}\]  
If the patient's arm is moving inside the virtual channel, as shown in \(f_{3}\) in Figure 5, the reference point \(P_{ref3}\) assisted by the robot is the current position of the patient's hand \(P_{act3}\); if the distance between the position of the patient's hand and the predetermined trajectory exceeds \(2R_{W}\), as shown in \(f_{2}\) in Figure 5, the reference point for robot-assisted movement is \(P_{ref2}\), i.e., \(P_{NN}\); when the distance from the position of the patient's hand to the predetermined trajectory exceeds the channel but does not exceed \(2R_{W}\), as shown in \(f_{1}\) in Figure 5, the reference point for robot motion assistance is \(P_{ref1}\); if the patient's hand is at the endpoint of the predetermined trajectory, as shown in \(f_{4}\) in Figure 5, the reference point of the current position is defined as the endpoint position of the trajectory, and the  
Figure 5: Concept of the virtual tunnel in the assist-as-needed (AAN) control (simplified to a planar case for better understanding). reference point assisted by the robot is \(P_{re/4}\). For space trajectory \(R\), the Euclidean distance between the current point and the nearest point should be greater than the radius of curvature of the nearest point on the space trajectory:  
\[\kappa<\frac{1}{|P_{act}-P_{NN}|}\forall P_{act}\in W \tag{15}\]  
where \(\kappa\) is the curvature radius of points on the trajectory, and \(W\) is the space point set reachable by the robot. The Euclidean distance \(d\) between the patient's current point and its nearest point should be calculated to determine whether the patient deviates from the virtual channel during the rehabilitation training. If the patient moves through the virtual channel, the robot's assistance force is calculated by calculating the Euclidean distance \(\Delta L\) between the patient's current point and its corresponding reference point. If the patient moves to the endpoint of the predetermined trajectory, the corresponding assistance force should be calculated according to the Euclidean distance between the current point of the patient and the endpoint of the trajectory. \[\Delta L=\left(\sum_{i=1}^{3}\left|P_{ref}(R)^{(i)}-P_{act}(i)\right|^{2} \right)^{\frac{1}{2}} \tag{16}\]  
According to Equation (11), the assistance force field \(F_{assist}\) distributed along the radial direction of the virtual channel is:  
\[F_{assist}=\left(K_{tun}\cdot\Delta L\right)\cdot\overrightarrow{n} \tag{17}\]  
\[\overrightarrow{n}=\frac{P_{ref}(R)-P_{act}}{\left|P_{ref}(R)-P_{act}\right|} \tag{18}\]  
where the \(F_{assist}\) is the robot assistance force, the \(K_{tun}\) is the diagonal matrix with the stiffness values for the virtual channel. To make the movement of patients in rehabilitation training follow the predetermined trajectory as far as possible and have spatial freedom, a virtual stiffness gradient field is designed within the range of the lateral width \(R_{W}\) of the virtual channel, and the gradient of the stiffness gradient field is assumed to be \(\psi\), as shown in Equation (19). When the patient's hand is moving across the virtual channel, it will be hindered by the gradient field to avoid large position errors, which can further improve the effect of robot assistance.