## 4 Structure of the First Diagram for Robot Control, the Iterative Learning Method  
### Algorithm Content According to the First Control Diagram  
Take the mathematical model (1) and assume that \(C(\underline{q},\dot{\underline{q}}),g(\underline{q})\) is undetermined. Then we have:  
\[H(\underline{q})\dot{\underline{q}}=\underline{u}_{dk}+\underline{\tau}_{d} \tag{4}\]  
With the sum of all the functional uncertainty components of the model:  
\[\underline{\tau}_{d}=\underline{u}(\underline{q},\dot{\underline{q}},\dot{ \underline{q}},t)-C(\underline{q},\dot{\underline{q}})\dot{\underline{q}}-g( \underline{q}) \tag{5}\]  
It can be seen immediately that when used:  
\[\underline{u}_{dk}=H(\underline{q})[\underline{\hat{q}}-g_{1}\underline{q}-g \underline{z}\dot{\underline{q}}] \tag{6}\]  
With \(g_{1},g_{2}\) being two properly chosen matrices, the system becomes:  
\[\dot{\underline{q}}=\underline{\hat{q}}-g_{1}\underline{q}-g_{2}\dot{ \underline{q}}+\varsigma\Leftrightarrow \begin{pmatrix}\dot{\underline{q}}\\ \dot{\underline{q}}\end{pmatrix} = \begin{pmatrix}0_{n}&I_{n}\\ -g_{1}&-g_{2}\end{pmatrix}\begin{pmatrix}\dot{\underline{q}}\\ \dot{\underline{q}}\end{pmatrix} + \begin{pmatrix}0_{n}\\ I_{n}\end{pmatrix}\begin{bmatrix}\underline{\hat{q}}+\underline{\varsigma} \end{bmatrix}  \tag{7}\]  
where \(\underline{\varsigma}=M(\underline{q})^{-1}\underline{\tau}_{d}\) is an uncertain component of system (7). \[\underline{X}= \begin{pmatrix}\dot{\underline{q}}\\ \dot{\underline{q}}\end{pmatrix} ,g= \begin{pmatrix}0_{n}&I_{n}\\ -g_{1}&-g_{2}\end{pmatrix} ,B= \begin{pmatrix}0_{n}\\ I_{n}\end{pmatrix}  \tag{8}\]  
The model (7) will have the canonical form:  
\[\dot{\underline{X}}=G\underline{X}+B \begin{bmatrix}\underline{\hat{q}}+ \underline{\varsigma}\end{bmatrix}  \tag{9}\]  
In addition, for system (9) to be stable, that is, to have a Hurwitz matrix \(\mathbf{A}\), we must choose two matrices \(g_{1},g_{2}\) so that the eigenvalues of \(\mathbf{A}\) given in (8) lie to the left of the imaginary axis. The simplest way is to choose them according to the method of assigning pole points using Matlab's _place(. )_ command, and these pole points should be selected as accurate (negative) numbers to eliminate fluctuations during transitions. And then the system output is:  
\[\underline{Y}=\underline{q}=(I_{n},0_{n})\underline{X} \tag{10}\]  
following the given periodic \(\underline{R}(t)\) pattern trajectory. Now we use notation: \(\underline{\hat{\varrho}}_{k}(n)=\underline{\hat{\varrho}}_{k}(t)|_{t=nt_{S}},\underline{Y}_{k}(n)=\underline{Y}_{k}(t)\left|{}_{t=nt_{S}}\right.\)  
Given the input and output of systems (9) and (10), respectively, \(nt_{s}\) at the time in the \(k\) test, with \(t_{s}\) being the sample extraction cycle, then the \(\mathbf{P}\)**-type** learning function, standard to all update time \(i\) at the \(k\) time, will be:  
\[\underline{\hat{\varrho}}_{k+1}=\underline{\hat{\varrho}}_{k}+K\underline{ \hat{\varrho}}_{k} \tag{11}\]  
where:  
\[\underline{\hat{\varrho}}_{k}=col(\underline{\hat{\varrho}}_{k}(0),\underline{ \hat{\varrho}}_{k}(1),\ldots,\underline{\hat{\varrho}}_{k}(S-1));\] \[\underline{\hat{\varepsilon}}_{k}=\underline{\hat{\varrho}}- \underline{\omega}_{k};\] \[\underline{\omega}_{k}=col(\underline{Y}_{k}(0),\underline{Y}_{k}(1 ),\ldots,\underline{Y}_{k}(S-1));\] \[\underline{\
u}_{k}=col(\underline{R}_{k}(0),\underline{R}_{k}(1 ),\ldots,\underline{R}_{k}(S-1)); \tag{12}\]\(K\) is the matrix of learning functions that must be chosen so that the learning function converges.