## 2 Electromechanical Model  
Let us consider a fully-actuated \(n\)-dof robot with rigid links and either closed or open kinematic chain. Let \(t\) be the time variable and \(\mathbf{q}=\mathbf{q}(t)\in\mathbb{R}^{n}\) be the vector of the generalized coordinates of the actuated joints. The torques \(\boldsymbol{\tau}=\boldsymbol{\tau}(t)\in\mathbb{R}^{n}\) that the actuators must exert to move the system from the initial time \(t_{0}\) to the final one \(t_{f}\) along a given trajectory in the joint space (\(\mathbf{q}(t)\) with \(t\in[t_{0};t_{f}]\)) can be computed from the system equations of motion as follows:  
\[\boldsymbol{\tau}=\mathbf{I}\mathbf{K}_{r}^{-1}\ddot{\mathbf{q}}+\mathbf{K}_{ r}\left(\mathbf{M}(\mathbf{q})\ddot{\mathbf{q}}+\mathbf{f}_{c}(\mathbf{q}, \dot{\mathbf{q}})+\mathbf{F}_{v}\dot{\mathbf{q}}+\mathbf{f}_{s}(\mathbf{q}, \dot{\mathbf{q}})+\mathbf{f}_{g}(\mathbf{q})+\mathbf{f}_{c}(\mathbf{q})\right) \tag{1}\]  
where  
* \(\dot{\mathbf{q}}=\dot{\mathbf{q}}(t)\in\mathbb{R}^{n}\) and \(\ddot{\mathbf{q}}=\dot{\mathbf{q}}(t)\in\mathbb{R}^{n}\) denote the first and second time derivative of vector \(\mathbf{q}\), i.e., the vectors of the actuated joint velocities and accelerations, respectively;
* \(\mathbf{I}\in\mathbb{R}^{n\times n}\) is the diagonal matrix of the motor inertia;
* \(\mathbf{K}_{r}\in\mathbb{R}^{n\times n}\) is the diagonal matrix of the gear transmission ratios;
* \(\mathbf{M}(\mathbf{q})\in\mathbb{R}^{n\times n}\) is the mass matrix;
* \(\mathbf{f}_{c}(\mathbf{q},\dot{\mathbf{q}})\in\mathbb{R}^{n}\) is the torque vector due to centrifugal and Coriolis effects;
* \(\mathbf{F}_{v}\in\mathbb{R}^{n\times n}\) is the diagonal matrix of viscous friction coefficients;* \(\mathbf{f}_{s}(\mathbf{q},\dot{\mathbf{q}})\in\mathbb{R}^{n}\) is the vector of the static friction torques, that may be represented by means of the Coulomb friction model. In this case \(\mathbf{f}_{s}=\mathbf{F}_{s}\text{sign}(\dot{\mathbf{q}})\), where \(\mathbf{F}_{s}\in\mathbb{R}^{n\times n}\) is a diagonal matrix of the static friction coefficients;
* \(\mathbf{f}_{s}(\mathbf{q})\in\mathbb{R}^{n}\) is the torque vector due to the effects of gravity;
* \(\mathbf{f}_{\epsilon}(\mathbf{q})\in\mathbb{R}^{n}\) is the torque vector due to the interaction of the end-effector with the environment. The robotic system considered is actuated by means of DC or permanent magnet synchronous (PMS) motors. The vector of the actuation torques in Equation (1) is related to the armature current vector, \(\dot{\boldsymbol{i}}\in\mathbb{R}^{n}\), of the motors by means of the diagonal matrix of the motor torque constants \(\mathbf{K}_{t}\in\mathbb{R}^{n\times n}\). \[\dot{\boldsymbol{i}}(t)=\mathbf{K}_{t}^{-1}\boldsymbol{\tau}(t) \tag{2}\]  
The supply voltage of the motor drivers \(\boldsymbol{e}\in\mathbb{R}^{n}\) is given by:  
\[\boldsymbol{e}(t)=\mathbf{R}\dot{\boldsymbol{i}}(t)+\mathbf{K}_{\epsilon} \mathbf{K}_{r}^{-1}\dot{\mathbf{q}}(t) \tag{3}\]  
where \(\mathbf{R}\in\mathbb{R}^{n\times n}\) and \(\mathbf{K}_{\epsilon}\in\mathbb{R}^{n\times n}\) are diagonal matrices of the resistances of the motor windings and the velocity constants of the motors, respectively. \(\mathbf{K}_{r}^{-1}\dot{\mathbf{q}}(t)\) is the motor speed. In Equation (3), the inductive terms have not been considered since the energy dissipated in the inductances in rest-to-rest motion is equal to zero [35]. The instantaneous input power, \(P\), to the motor drivers is given by the product of Equations (2) and (3), that it is equivalent to the sum of the instantaneous input power to each motor driver, \(P_{j}\):  
\[P(t)=\boldsymbol{e}(t)^{\text{T}}\boldsymbol{\eta}^{-1}\dot{\boldsymbol{i}}(t) =\sum_{j=1}^{n}P_{j}(t)=\sum_{j=1}^{n}\frac{e_{j}(t)i_{j}(t)}{\boldsymbol{ \eta}_{j}} \tag{4}\]  
where \(\boldsymbol{\eta}\in\mathbb{R}^{n\times n}\) is the diagonal matrix of the efficiency of each driver, \(\boldsymbol{\eta}_{j}\), \(j=1,\ldots,n\).