## 2 Materials and Methods
### Equations of the Simulated Model  
The equations for the simulated system were generated using the Robotran software (version 1.22.0) [28]. The semi-explicit formalism, as presented in (1), also referred to as the direct dynamic model in the literature, was used as follows:  
\[\mathbf{M}(\mathbf{q},\delta)\tilde{\mathbf{q}}+\mathbf{c}\big{(}\mathbf{q},\dot{\mathbf{q}},\delta, \mathbf{\textit{frc}},\mathbf{\textit{trq}},\mathbf{g}\big{)}=\mathbf{\tau}\big{(}\mathbf{q},\dot{ \mathbf{q}}\big{)}, \tag{1}\]  
where \(\mathbf{M}[n\cdot n]\) is the symmetric generalized mass matrix of the system; \(\mathbf{c}[n\cdot 1]\) is the nonlinear dynamic vector containing the gyroscopic, centrifugal and gravity terms, as well as the contributions of external forces and torques; \(\mathbf{q}[n\cdot 1]\) contains the relative generalized coordinates; \(\delta[10n\cdot 1]\) contains the dynamic parameters of the system, i.e., masses, centers of masses, inertia; and \(\mathbf{\tau}[n\cdot 1]\) contains the generalized joint forces.  
To be as realistic as possible, the dynamic effects of the motors were considered by accounting for the inertia of the rotor of each motor and viscous friction, which is velocity-dependent [29]. For simplicity, we neglected the nonlinear friction torque given in this article. Thus, the model of the motors was written as follows:  
\[\mathbf{J}_{m}\ddot{\mathbf{q}}_{m}+\mathbf{D}_{m}\dot{\mathbf{q}}_{m}=\mathbf{\tau}_{m}-\mathbf{R} \mathbf{\tau}, \tag{2}\]  
with \(\mathbf{\tau}\) corresponding to the generalized joint forces from Equation (1); \(\dot{\mathbf{q}}_{m}[n\cdot 1]\) and \(\ddot{\mathbf{q}}_{m}[n\cdot 1]\) being the velocities and accelerations of the \(n\) motors, respectively; \(\mathbf{J}_{m}\), \(\mathbf{D}_{m}\), and \(\mathbf{R}\) being three \([n\cdot n]\) diagonal matrices corresponding to the moments of inertia, the viscous friction coefficients of the motors, and the gear reduction ratios, respectively.  
Finally, \(\mathbf{\tau}_{m}[n\cdot n]\) is the vector of torques supplied by the motors, which corresponds to the output of the PD controller. Based on [29], we used (1) to replace \(\mathbf{\tau}\) in (2) and applied the relation \(\mathbf{q}=\mathbf{R}\mathbf{q}_{m}\) to combine the equations to obtain the complete model of the simulated arm:  
\[\mathbf{J}_{m}\ddot{\mathbf{q}}_{m}+\mathbf{D}_{m}\dot{\mathbf{q}}_{m}=\mathbf{\tau}_{m}-\mathbf{R}( \dot{\mathbf{q}}+\mathbf{c}) \tag{3}\]  
\[(\mathbf{J}_{m}+\mathbf{R}\mathbf{M})\ddot{\mathbf{q}}_{m}+\mathbf{D}_{m}\dot{\mathbf{q}}_{m}+\mathbf{R} \mathbf{c}=\mathbf{\tau}_{m} \tag{4}\]  
\[\ddot{\mathbf{q}}=\mathbf{R}\ddot{\mathbf{q}}_{m}=\mathbf{R}(\mathbf{J}_{m}+\mathbf{R}\mathbf{M})^{-1} \big{(}\mathbf{\tau}_{m}-\mathbf{D}_{m}\dot{\mathbf{q}}_{m}-\mathbf{R}\mathbf{c}\big{)} \tag{5}\]  
An n-DOF robot arm was considered with a joint servocontrol with input \(\mathbf{q}_{c}\in\mathbb{R}^{n}\), the joint position commands, and the output \(\mathbf{q}\in\mathbb{R}^{n}\), the measured joint positions. Our goal was to find a feedforward compensation such that, for desired joint trajectories \(\mathbf{q}_{d}\), the corrected input commands \(\mathbf{q}_{c}\) would result in the perfect tracking of these desired trajectories: \(\mathbf{q}_{c}\rightarrow\mathbf{q}=\mathbf{q}_{d}\). The architecture of the control structure is presented in Figure 1.