# Assist-as-Needed Controller of a Rehabilitation Exoskeleton for Upper-Limb Natural Movements
## 2 Materials and Methods
### Friction Modeling  
Compensating for joint friction has a significant effect on interaction transparency. Joint friction can be modeled by measuring the torque required to rotate the motor at different velocities. For BLDC, output torque is linearly proportional to the current. When the motor is unloaded and only affected by frictional forces, the motor torque \(\mathbf{\tau}_{\rm fri}\) can be obtained using the motor's torque constant, as follows:  
\[\mathbf{\tau}_{\rm fri}=\mathbf{N}_{\rm m}\mathbf{K}_{\rm m}\mathbf{I}_{\rm m} \tag{4}\]  
where \(\mathbf{N}_{\rm m}\), \(\mathbf{K}_{\rm m}\), and \(\mathbf{I}_{\rm m}\) denote the gear ratio of each joint, feedback current, and torque coefficient of the motors, respectively.  
The first term on the right side of the equation is a function related to the sign of the velocity, which causes the direction of the friction torque to change suddenly when the motor velocity passes through 0. Previous studies commonly employed a friction force model that combines Coulomb friction and viscous friction, expressed as  
\[\mathbf{\tau}_{\rm fri}=\mathbf{c}\,\text{sgn}(\mathbf{\dot{q}}_{i})+\mathbf{v}\mathbf{\dot{q}}_{i} \tag{5}\]  
Because of the similarity in friction characteristics among different joints, J3 is selected as a representative example. Figure 3 shows the frictional torque at different velocities. As velocity increases, the friction in the harmonic drive does not exhibit a linear relationship. It can be observed that this model does not fit the friction data well at both low and high speeds. Therefore, a friction model that couples the Stribbeck effect and takes into account the nonlinear relationship between viscous friction and joint speed is modified as follows:  
\[\mathbf{\tau}_{\rm fd}=\left(\mathbf{f}_{\rm c}+(\mathbf{f}_{\rm s}-\mathbf{f}_{\rm c})e^{ \left(-|\mathbf{\dot{q}}_{i}/\mathbf{v}_{\rm s}|\mathbf{\dot{q}}_{\rm s}\right)}+\mathbf{f}_{ \rm v}|\mathbf{\dot{q}}_{i}|^{\gamma_{\rm c}}\right)\text{sgn}(\mathbf{\dot{q}}_{i}) \tag{6}\]  
where \(\mathbf{\dot{q}}_{i}\) represents the angular velocity of the \(i_{th}\) joint, \(\mathbf{f}_{\rm c}\) is the Coulomb friction coefficient, \(\mathbf{f}_{\rm s}\) is the maximum static friction coefficient, \(\mathbf{v}_{\rm s}\) is the Stribbeck velocity, \(\mathbf{\eta}_{\rm s}\) is the shape coefficient of contact friction, which ranges from 0.5 to 2, in this study \(\mathbf{\eta}_{\rm c}=1\). \(\mathbf{f}_{\rm v}\) is the viscous friction coefficient, \(\mathbf{\eta}_{\rm v}\) is the shape coefficient for viscous friction.  
The friction torque exhibits two inflection points within the velocity range of [0, 30], showing a trend of decreasing first and then increasing. Therefore, a linear function is used to describe the friction torque before the first inflection point. The piecewise model is represented as  
\[\mathbf{\tau}_{\rm fri}=\begin{cases}\mathbf{f}_{\rm c}\mathbf{\dot{q}}_{i}+\left(\mathbf{F}_ {\rm g}-\mathbf{f}_{\rm cr}\mathbf{\dot{q}}_{\rm ig}\right)&\text{if }|\mathbf{\dot{q}}_{i}|\leqslant\mathbf{\dot{q}}_{ig}\\ \mathbf{\tau}_{\rm fd}&\text{if }|\mathbf{\dot{q}}_{i}|>\mathbf{\dot{q}}_{ig}\end{cases} \tag{7}\]  
where \(\mathbf{f}_{\rm cr}\) represents the slope in the first linear interval, \(\mathbf{F}_{\rm g}\) represents the vector composed of the ordinate of the first inflection point of each joint.