# Inducing Optimality in Prescribed Performance Control for Uncertain Euler-Lagrange Systems
## 4 Methodology
### Identification of System Dynamics  
We adopt an iterative process, which aims at creating a progressively improving approximation of the unknown functions \(f(q,\dot{q})\), \(g(q)\), denoted as \(\hat{f}(q,\dot{q})\) and \(\hat{g}(q)\), respectively, at each iteration, until convergence is achieved, i.e., \(|f(q,\dot{q})+g(q)\tau-\hat{f}(q,\dot{q})-\hat{g}(q)\tau|<\tilde{e}\), with \(\tilde{e}\) being an arbitrarily small positive number. To acquire the data needed for the neural network estimation at each iteration and in order to guarantee that this data set is representative of the compact workspace \(\Omega_{q}\times\Omega_{\dot{q}}\subset\mathbb{R}^{2n}\), we form a reference trajectory by linking together multiple points located all over \(\Omega_{q}\times\Omega_{\dot{q}}\). To elaborate further on this, first, a set of \(N\) points \(X=[X_{1},\dots,X_{N}]^{T}\) is selected such that it covers \(\Omega_{q}\times\Omega_{\dot{q}}\). Then, we need to devise a closed path that traverses these points. For that purpose, we connect any pair of points \(X_{i}\to X_{j}\) with a trajectory of minimum acceleration (see Chapter 3 in [26]), as follows:  
\[ \begin{bmatrix}q_{d}(t)\\ \dot{q}_{d}(t)\end{bmatrix} =\left( \begin{bmatrix}1&t\\ 0&1\end{bmatrix} \otimes\mathbf{I}_{n}\right)X_{i}-\left( \begin{bmatrix}-\frac{t ^{3}}{T^{3}}&-\frac{\hat{e}(T-t)}{T^{2}}\\ \frac{6t(T-t)}{T^{3}}&\frac{t(2T-3t)}{T^{2}}\end{bmatrix} \otimes\mathbf{I}_{n} \right)\left[X_{j}-\left( \begin{bmatrix}1&T\\ 0&1\end{bmatrix} \otimes\mathbf{I}_{n}\right)X_{i}\right]\]  
for all \(t\in[0,T]\), where \(T\) denotes the transition time from \(X_{i}\) to \(X_{j}\). The path in every iteration is then created by a different random sequence of \(X_{i}\), \(i=1,\dots,N\) (i.e., a permutation of \(X\)) to ensure that the final result is free of bias along a specific trajectory. Subsequently, the aforementioned reference trajectory that covers the whole domain space will be tracked with predefined transient and steady-state performance using the PPC technique, as described in Section 3.1, with the position \(q\) and velocity \(\dot{q}\) being measurable, according to Assumption 1. Hence, based on the collected data over the aforementioned series of reference trajectories, we shall approximate the unknown dynamics using a neural network structure \(NN(q,\dot{q},\tau)\) that will fit the system dynamics as \(f(q,\dot{q})+g(q)\tau\approx NN(q,\dot{q},\tau)\). In particular, we are interested in learning \(f(q,\dot{q})\) and \(g(q)\) separately, which correspond to the terms \(-M(q)^{-1}(C(q,\dot{q})\dot{q}+G(q))\) and \(M^{-1}(q)\), respectively. This can be straightforwardly accomplished by setting \(\tau=\mathbf{0}_{n}\), where \(\mathbf{0}_{n}\) denotes an \(n\)-dimensional vector of zeros, as follows:  
\[NN(q,\dot{q},\mathbf{0}_{n})\approx f(q,\dot{q}). \tag{9}\]  
Then, by setting \(\tau=c\mathbf{1}_{n}^{\{i\}}\), \(i=1,\dots,n\), where \(c\
eq 0\) is a constant number, and \(\mathbf{1}_{n}^{\{i\}}\) denotes an \(n\)-dimensional vector with one in the \(i\)th element and zeros everywhere else, we obtain:  
\[\frac{1}{c}\Big{[}NN(q,\dot{q},c\mathbf{1}_{n}^{\{i\}})-NN(q,\dot{q},\mathbf{ 0}_{n})\Big{]}_{i=1,\dots,n}\approx g(q,\dot{q}). \tag{10}\]  
Finally, the gravity vector of the dynamic model that is employed in (8) can be easily accessed by the aforementioned structure following the property \(G(q)=-g^{-1}(q)f(q,0)\). Nevertheless, under Assumption 1, we do not have access to the acceleration \(\ddot{q}\) in (2), and thus, the target values to train the neural network \(NN(q,\dot{q},\tau)\) are not available. To remedy this issue, the following tracking differentiator [27] is employed:  
\[z_{1} =z_{2} \tag{11}\] \[z_{2} =-k_{z_{1}}R^{2}(z_{1}-q)-k_{z_{2}}R(z_{2}-q)+NN(q,\dot{q},\tau) \tag{12}\]  
with positive gains \(k_{z_{1}},k_{z_{2}},R\).