## 2 Materials and Methods
### Test Procedure  
The main steps for designing an accurate control structure with a feedforward neural network were identified prior to the study. To provide a guide for the design of our minimal model-free control structure by using neural networks for feedforward compensation, we studied each of these steps in detail. Using both real robotic arms and simulated models, we followed these steps:  
_Build a dataset of trajectories_, all with the same duration representing the entire workspace of the arm, by using a simple PD controller on each joint, with the following control law. \[\mathbf{c}(t)=\mathrm{P}(\mathbf{q}(\mathbf{t})-\mathbf{u}(\mathbf{t}))+\mathrm{D}\big{(}\dot{\mathbf{ q}}(\mathbf{t})-\dot{\mathbf{u}}(\mathbf{t})\big{)},\]  
with \(\mathbf{c}\) the vector of commands (in current) of the \(n\) motors, \(\mathbf{q}\) and \(\dot{\mathbf{q}}\) the position and velocity of the \(n\) motors, \(\mathbf{u}\) and \(\dot{\mathbf{u}}\) are the desired position and velocity of the \(n\) motors, and \(P\) and \(D\) the gains of the internal PD controller. The dataset comprised 1000 trajectories, a number selected to provide enough data to ensure optimal training while being feasible for real systems. Joint trajectories were generated from a home position by using quintic polynomials by choosing the desired random position and velocity in the workspace of each motor, as follows:  
\[q_{i}(t)=a_{0}+a_{1}t+a_{2}t^{2}+a_{3}t^{3}+a_{4}t^{4}+a_{5}t^{5}, \tag{6}\]  
with  
\[ \begin{bmatrix}1&0&0&0&0&0\\ 0&1&0&0&0&0\\ 0&0&2&0&0&0\\ 1&t_{d}&t_{d}^{2}&t_{d}^{3}&t_{d}^{4}&t_{d}^{5}\\ 0&1&2t_{d}&3t_{d}^{2}&4t_{d}^{3}&5t_{d}^{4}\\ 0&0&2&6t_{d}&12t_{d}^{2}&20t_{d}^{3}\end{bmatrix}\begin{bmatrix}a_{0}\\ a_{1}\\ a_{2}\\ a_{3}\\ a_{4}\\ a_{5}\end{bmatrix} = \begin{bmatrix}q_{i0}\\ \dot{q}_{i0}\\ \dot{q}_{i0}\\ \dot{q}_{id}\\ \dot{q}_{id}\\ \dot{q}_{id}\end{bmatrix} , \tag{7}\]  
with \(q_{i0}\) being the home position of the \(i\)th motor, \(\dot{q}_{i0}=0\) and \(\dot{q}_{i0}=0\) being the initial velocity and acceleration of the motor, \(q_{id}\), \(\dot{q}_{id}\) being the desired position and velocity, and \(\dot{q}_{id}^{\prime}=0\) being the desired acceleration. The same equations were used to generate the second half of the trajectory between \(q_{id}\) and \(q_{if}=q_{i0}\). \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Values** \\ \hline Arm & Real (3/5 DOF), Simulated (5 DOF) \\ NN Architecture & INN, GNN \\ Number of neurons & 1, 3, 16, 3 + 3, 16 + 16, 3 \(\times\) 16 \\ \hline \multicolumn{3}{c}{**Additional parameters studied in simulation**} \\ \hline PD parameters & RNN \\ Motor reduction ratio & 1, 0.5, 0.25, 0.16, 0.1, 0.01 \\ Noise magnitude (m) & 0, 0.001, 0.002, 0.003, 0.005, 0.01, 0.02, 0.04 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Summary of tested parameters. All these trajectories were generated at 100 Hz to ensure regular commands were sent to the motors with our computer. Once the trajectories were executed, the dataset was built using a desired number of trajectories (between 20 and 1000). Each datum of the dataset consisted of five variables for each motor: the position \(\mathbf{q}\) and the velocity \(\dot{\mathbf{q}}\) of the motor at two consecutive timestamps--\(\mathbf{q}(t)\), \(\mathbf{q}(t+\delta)\), \(\dot{\mathbf{q}}(t)\), \(\dot{\mathbf{q}}(t+\delta)\)--and the command sent between these two timestamps \(\mathbf{u}(t)\). _Train the NN architecture_ to learn the dynamic model through the response of the PD controller. By giving the NN a lot of data from the trajectories, it learned which command had to be sent to each motor to go from a state--\(\mathbf{q}(t)\), \(\dot{\mathbf{q}}(t)\)--to the next one--\(\mathbf{q}(t+\delta)\), \(\dot{\mathbf{q}}(t+\delta)\)--and implicitly, the dynamic model of the robotic arm. The multi-layer perceptron regressor was trained with a maximum of 500 iterations by using the \"MLPRegressor.fit (0\") function from the Python library \"sklearn\" [30].