## 2 Control Design
Indeed, the EMG signal is used to extract muscle contraction which is used further to estimate patient pain during the rehabilitation session for safety purposes. EMG-RMS, EMG-SSI, EMG-vorder and EMG-Logdetect features are extracted within an N sample analysis time window, and for each, \(X_{i}\) represents the ith sample of EMG signal [49]. **The root mean square (RMS)** is modeled as the amplitude-modulated Gaussian random process where the RMS is related to the constant force, and the non-fatguing contractions of the muscles. \[RMS=\sqrt{\frac{1}{N}\sum_{i=1}^{N}X_{i}^{2}} \tag{1}\]  
**The simple square integral (SSI)** expresses the energy of the EMG signal as a usable feature:  
Figure 1: Control architecture overview. \[SSI=\sum_{i=1}^{N}\left|X_{i}^{2}\right| \tag{2}\]  
**EMG_v-order (V)** V is a non-linear detector that computes implicitly the strength of a muscular contraction. \[V=\left(\frac{1}{N}\sum_{i=1}^{N}X_{i}^{v}\right)^{\frac{1}{5}} \tag{3}\]  
where v is an optimum value has been reported to be 2 in [50] and used as \(v=1\) in this work to be equivalent to the integral absolute value (IAV) [49]. **The log-detector (logdetect)** provides an estimate of the strength of muscle contraction. \[logdetect=e^{\frac{1}{N}\sum_{i=1}^{N}log(\left|X_{i}\right|)} \tag{4}\]  
In this application, we are only interested in the flexion-extension movement. For this reason, we adopted a 1 DoF dynamic model, as presented by Equation (5). \[m\ddot{q}+b\dot{q}+g\left(q\right)=\tau \tag{5}\]  
where  
* \(m\) is the link mass. * \(q\) is the joint variable. * \(\dot{q}\), and \(\ddot{q}\) are the joint velocity and acceleration. * \(b\) is the dynamic coefficient of friction. * \(g\) is the gravitational force. Equation (5) can be written as:  
\[m\dot{z}=y\dot{\theta}-\tau-bz \tag{6}\]  
where  
\[z=\gamma e+\dot{e} \tag{7}\]  
\(e=q_{d}-q\) is the tracking error, \(q_{d}\) represents the desired trajectory of the joint variable and \(\gamma>0\). \[y\dot{\theta}=m\left(\ddot{q_{d}}+\gamma e\right)+b\left(q_{d}+\gamma e\right) +g\left(q\right) \tag{8}\]  
where \(y\) represents the regression matrix. * \(y=\left[y_{11}\ \ y_{12}\right]\)
* \(\dot{\theta}\) is \(2x1\) vector of the unknown constant parameters  
The following controller is proposed:  
\[\tau=y\dot{\theta}+k_{v}z \tag{9}\]  
where \(k_{v}\) is a scalar value representing the control gain. With the adaptive update rule:  
Figure 1:0  
where  
\(\dot{\dot{\theta}}\) is a vector representing the estimate of the unknown parameters;\(\hat{\theta}\) is 2x1 matrix; (\(\hat{\theta}\in\Re^{2x1}\)), \(\tilde{\theta}=\theta-\hat{\theta}\);  
\(\lambda= \begin{pmatrix}\lambda_{1}&0\\ 0&\lambda_{2}\end{pmatrix} \), and \(\lambda_{i}>0\). The stability of the proposed controller can be achieved using the following Lyapunov function \(V\):  
\[V=\frac{1}{2}m\left(q\right)z^{2}+\frac{1}{2}\tilde{\theta}^{T}\lambda^{-1} \tilde{\theta}^{2} \tag{11}\]  
\[\dot{V}=z\dot{z}+\tilde{\theta}^{T}\lambda^{-1}\dot{\tilde{\theta}} \tag{12}\]  
By substituting Equation (6) into Equation (12), we get:  
\[\dot{V}=z\left(y\dot{\theta}-\tau\right)-bz^{2}+\tilde{\theta}^{T}\lambda^{-1} \dot{\tilde{\theta}} \tag{13}\]  
Substituting Equation (9) into Equation (13) yields:  
\[\dot{V}=-k_{v}z^{2}+\tilde{\theta}^{T}\left(\lambda^{-1}\dot{\tilde{\theta}}+y ^{T}z\right)-bz^{2} \tag{14}\]  
Substituting Equation (10) into Equation (14) yields:  
\[\dot{V}=-k_{v}z^{2}-bz^{2}<0 \tag{15}\]  
\(V\) is lower bounded by zero, \(\dot{V}\) is negative semidefinite and \(\ddot{V}\) is bounded by [PERSON]'s Lemma  
\[\lim_{t\rightarrow\infty}\dot{V}=0 \tag{16}\]  
By the Rayleigh-Ritz theorem, we can prove that  
\[\lim_{t\rightarrow\infty}z=0 \tag{17}\]  
which means that  
\[\lim_{t\rightarrow\infty}e=0 \tag{18}\]  
The novelty proposed in the developed solution is to deal with the pain that the patient feels during the rehabilitation process. Indeed, this pain can affect a person's reactivity and therefore their susceptibility to a rehabilitation protocol.