## 2 Materials and Methods
### Design of the Recursive Least Squares Observer  
Incorporating the mathematical model of the motor, let us briefly introduce the principle of the recursive least squares (RLS) observer. By performing the Laplace transform on the motion equation of the motor, the motion equation of the motor in the frequency domain can be obtained as follows:  
\[\omega_{\text{m}}(s)=\frac{1}{Js+B_{\text{m}}}(T_{e}(s)-T_{\text{L}}(s)-h\cdot T _{f}(s)) \tag{13}\]  
In the equation, \(h=sgn(\omega_{m})\). After introducing the zero-order hold element, performing the \(Z\)-transform on the motion equation of the motor yields its expression, as shown in Equation (14) as follows:  
\[\left\{ \begin{array}{l}A=\frac{1-\text{e}^{-B_{\text{m}}T_{f}/l}}{B_{\text{ m}}}\\ B=-\text{e}^{-B_{\text{m}}T_{f}/l}\\ C=\frac{1-\text{e}^{-B_{\text{m}}T_{f}/l}}{B_{\text{m}}}T_{\text{L}}\\ D=\frac{1-\text{e}^{-B_{\text{m}}T_{f}/l}}{B_{\text{m}}}T_{f}\end{array} \right. \tag{14}\]  
The above equation can be solved to obtain the following:  
\[ \begin{array}{ll}\omega_{\text{m}}(z)&=\frac{z^{-1}(1-e^{-B_{\text{m}}T_{f} /l})}{B_{\text{m}}(1-z^{-1}\text{e}^{-B_{\text{m}}T_{f}/l})}\\ &\times(T_{e}(z)-T_{\text{L}}(z)-h\cdot T_{f}(z))\end{array}  \tag{15}\]  
where \(T_{\text{s}}\) represents the sampling period of the identification algorithm, assuming that within one sampling period, the values of \(\omega_{m}\) and \(T_{\text{e}}\) remain constant. \[\omega_{\text{m}(k)}=AT_{e(k-1)}-B\omega_{\text{m}(k-1)}-C-h\cdot D \tag{16}\]  
We define the output variable \(y_{(k)}\), input column vector \(\mathbf{x}_{(k)}\), and parameter column vector \(\lambda\) as expressed in Equation (16). \[\left\{ \begin{array}{l}y_{(k)}=\omega_{m(k)}\\ x_{(k)}=\left[T_{e(k-1)},-\omega_{m(k-1)},-1,-h\right]^{T}\\ \lambda=\left[A,B,C,D\right]^{T}\end{array} \right. \tag{17}\]  
The relationship between them can be derived from Equation (15), as follows:  
\[y_{(k)}=x_{(k)}^{\text{T}}\lambda \tag{18}\]  
According to the recursive least squares principle, the identification formula for the observer is given by the following:  
\[\left\{ \begin{array}{l}\mathbf{K}_{(N)}=\frac{\mathbf{P}_{(N-1)}\mathbf{\xi}_{(N)}}{1+x_ {(N)}^{\text{T}}\mathbf{P}_{(N-1)}\mathbf{x}_{(N)}}\\ \hat{y}_{(N)}=\mathbf{x}_{(N)}^{\text{T}}\hat{\lambda}_{(N-1)}\\ e_{(N)}=y_{(N)}-\hat{y}_{(N)}\\ \hat{\lambda}_{(N)}=\hat{\lambda}_{(N-1)}+\mathbf{K}_{(N)}e_{(N)}\\ \mathbf{P}_{(N)}=\mathbf{P}_{(N-1)}-\mathbf{K}_{(N)}\mathbf{x}_{(N)}^{\text{T}}\mathbf{P}_{(N-1)} \end{array} \right. \tag{19}\]  
In the equation, \(\mathbf{K}_{(N)}\) is a 4-dimensional column vector; \(\mathbf{P}_{(N)}\) is a 4 \(\times\) 4 covariance matrix; \(\hat{y}_{(N)}\) is the N-th estimate of the output variable; \(\hat{\lambda}_{(N)}\) is the N-th estimate of the parameter column vector; and \(e_{(N)}\) represents the deviation caused by using the parameter vector from the previous time step for prediction at the current time step. During the identification process, the correction value \(K_{(N)}e_{(N)}\) is continuously used to adjust the parameter vector estimate. The error between the estimated value and the actual value of parameter vector \(\hat{\lambda}_{(N)}\) gradually converges to zero. Eventually, using Equation (19), parameters \(\hat{T}_{\mathrm{L}}\) and \(\hat{J}\) can be inversely solved from \(\hat{A}\), \(\hat{B}\), and \(\hat{C}\). \[\left\{ \begin{array}{l}\hat{J}=\frac{-(1+\hat{B})T_{\mathrm{s}}}{\hat{A}\ln( -\hat{B})}\\ \hat{T}_{\mathrm{L}}=\hat{C}/\hat{A}\end{array} \right. \tag{20}\]  
Using the observed values \(\hat{T}_{\mathrm{L}}\) and \(\hat{J}\), combined with \(\theta_{\mathrm{ini}}\), the sliding mode control (VSMC) parameter \(c\) can be dynamically adjusted. A fitting method is employed to establish the relationship between the three values (\(\hat{T}_{\mathrm{L}}\), \(\hat{J}\), and \(\theta_{\mathrm{ini}}\)), and the parameter \(c\).