## 3 Controller Design
### Sliding Mode Controller Design (SMC)  
In the sliding mode control system, joint space trajectories are compelled to reach a sliding manifold within a finite time, known as the reachability phase. Subsequently, these trajectories are constrained to indefinitely remain on the manifold during the sliding phase [46]. The objective of the tracking control issue in the joint space is to precisely move the joint position \(q\) to the desired location \(q_{d}\). This difference between the \(q\) and \(q_{d}\) can be defined as the tracking error \(\widetilde{q}\). \[\widetilde{q}=q-q_{d}, \tag{45}\]  
The sliding surface is determined using the following equation:  
\[\mathbf{s}=\dot{\widetilde{q}}-\lambda\widetilde{\dot{q}}, \tag{46}\]  
where \(\lambda=diag\{\lambda_{1},\ \lambda_{2},\ldots,\lambda_{4}\}\) represents a diagonal positive definite matrix serving as a weighting parameter. The design of the controller can be expressed as the task of deriving a control law for the input vector \(\tau\) that satisfies the individual sliding conditions of the following form:  
\[\frac{1}{2}\frac{d}{dt}s_{i}^{2}\leq-\eta_{i}|s_{i}|\qquad\qquad(\eta_{i}>0), \tag{47}\]  
Fulfilling Equation (47) results in the surface becoming an invariant set. Moreover, it suggests that disruptions or unpredictable changes may be accepted without affecting the stability of the surface as a fixed set. The optimal approximation \(\hat{\tau}\) of a control rule that would result in \(\dot{s}=0\) is as follows:  
\[\hat{\mathbf{\tau}}=\hat{\mathbf{M}}\tilde{\mathbf{q}}+\hat{\mathbf{N}}-\mathbf{A}\mathbf{s}, \tag{48}\]  
where \(\hat{\mathbf{M}}\) and \(\hat{\mathbf{N}}\) are estimates of \(\mathbf{M}\) and \(\mathbf{N}\), and \(A=diag\{a_{1},\ldots a_{4}\}\) is a diagonal positive definite constant matrix. To fulfill the sliding condition defined in Equation (47) in the presence of uncertainties in the dynamics, the term \(\hat{\mathbf{\tau}}\) could be introduced to ensure discontinuity across the surface. Consequently, the control input becomes the following:  
\[\mathbf{\tau}=\hat{\mathbf{\tau}}-\mathbf{F}\mathbf{s}gn(\mathbf{s}), \tag{49}\]  
Substituting Equation (49) into Equation (43) leads to the following:  
\[\mathbf{M}\dot{\mathbf{s}}+(\mathbf{N}+\mathbf{A})\mathbf{s}=\Delta\mathbf{f}-\mathbf{F}\mathbf{s}gn(\mathbf{s}), \tag{50}\]  
where \(\Delta\mathbf{f}\) represents the estimation error, defined as \(\Delta\mathbf{f}=(\hat{\mathbf{M}}-\mathbf{N})\tilde{\mathbf{q}}+(\hat{\mathbf{N}}-\mathbf{N})\), and it is assumed that the estimation error is bounded by a known quantity denoted as \(\mathbf{F}\). \[\left|\Delta f\right|_{bound}\leq F, \tag{51}\]  
In order to demonstrate the convergence to the sliding mode, the variable \(\mathbf{s}\) must approach zero within a specified duration. In order to achieve this objective, the Lyapunov approach may be used to derive a control rule that ensures the stability of the system. Choosing a Lyapunov function can be defined with the following equation:  
\[\mathbf{V}=\frac{1}{2}\mathbf{s}^{T}\mathbf{M}\mathbf{s} \tag{52}\]  
Since \(\mathbf{M}\) is the symmetric and positive definite, then \(\
eq 0\ \mathbf{V}>0\). Additionally, differentiating Equation (52) and using Equation (50), the following equation is true:  
\[\dot{\mathbf{V}}=\mathbf{s}^{T}[-(\mathbf{N}+\mathbf{A})\mathbf{s}+\Delta\mathbf{f}-\mathbf{F}\mathbf{s}gn(\bm {s})+\mathbf{N}\mathbf{s}]=\sum_{i=1}^{n}\mathbf{s}_{i}[\Delta\mathbf{f}_{i}-\mathbf{F}\mathbf{s}gn( \mathbf{s}_{i})]-\mathbf{s}^{T}\mathbf{A}\mathbf{s}\leq 0 \tag{53}\]Using Equation (51) for the \(s_{i}>0\) and \(s_{i}<0\) conditions, Equation (53) provides an exponentially stable system. In practical applications, the control rule described in Equation (49) may lead to rapid and repetitive oscillations known as chattering, particularly in situations involving high frequency switching. In order to decrease the control's chattering activity, the high-frequency switching function \(sgn\) may be approximated using a smooth-bounded saturation function \(sat\).