## 3 Enhancing Movement Quality by Implementing a Compensation Function
This vector determines the direction and value of the force with which the patient acts on the handle. Therefore, it can be set for the appropriate compensation. The results of determining the compensating functions are presented in Figure 11.  
By approximating the obtained characteristics with a quadratic function, a compensating function was obtained for the upward movement of \(f_{kg}(\varphi_{2})\) and downward movement of \(f_{kd}(\varphi_{2})\):  
\[f_{kg}(\varphi_{2})\ =\ -0.0026\varphi_{2}^{2}-2.23\varphi_{2}+15.047 \tag{5}\]  
\[f_{kd}(\varphi_{2})\ =\ -0.0019\varphi_{2}^{2}-0.83\varphi_{2}+9.198 \tag{6}\]  
After the experiments, a modification was introduced to the \(\varphi_{2}\) axis control system (Figure 12). In the control system, a compensating function \(f_{k}(\varphi_{2})\) was added to the control torque \(M_{2}(t)\), obtaining the control torque \(M_{2}^{\prime}(t)\). Figure 11: Compensation function characteristics: \(f_{kg}(t)-\) upper limit, \(f_{kp}(t)-\) lower limit. Figure 12: _Cont._  
In order to examine the improvement of the mode performance, the experiment was performed again for the linear input signals \(\varphi_{lz2}\) and \(\varphi_{sz2}\). The linear input tests were performed for the same adopted parameters \(\varphi_{P2}\) and \(\varphi_{K2}\) and the movement time \(T_{1}\), as well as for the movement without compensation (Figure 13). Analyzing the linear input signal, a significant improvement can be observed at the beginning of the movement. The position error at the beginning of the movement for \(t=0.4\) s was \(0.024^{\circ}\). However, the angular velocity \(\omega_{2}\) stabilization time did not improve and was \(t_{u}~{}=~{}0.24\) s. The integral criterion of the absolute value of the error signal was used to assess the improvement of the system's performance. For a linear set signal, it was \(I_{e_{2}}~{}=~{}\int_{0}^{T_{1}}\lvert e_{2}(t)\rvert\,dt~{}=~{}6.69\). At the same time, after adding the compensating function, it decreased by nearly 53% to \(I_{e_{2k}}~{}=~{}\int_{0}^{T_{1}}\lvert e_{2k}(t)\rvert\,dt~{}=~{}3.145\) (Figure 14). For a linear set signal, the introduction of a compensation function resulted in a significant improvement in the motion quality. Figure 12: Diagram of an MWR control system: (**a**) control system for all axes; (**b**) modified control system diagram for \(\varphi_{2}\) axis: \(\varphi_{iz}(t)\)-input signal, \(\varphi_{i}(t)\)-actual angular position, \(e_{1}(t)\)-angular position error, \(M_{1}(t)\)-control signal for \(i=1\), \(2\), \(3\), \(f_{kg}(\varphi_{2})\)-compensation function for upward movement, \(f_{kd}(\varphi_{2})\)-compensation function for downward movement, \(M_{2}(t)\)-control signal with compensation. Figure 13: Characteristics of linear input with compensation: \(\varphi_{lz2}(t)\)-given input signal, \(\varphi_{2}(t)\)-measurement result, \(\omega_{2}(t)\)-angular velocity. However, the velocity error was investigated by \(I_{\dot{e}_{2}}\ =\ \int_{0}^{T_{1}}\dot{e}_{2}(t)\big{|}\ dt\ =\ 6.36\). This time, adding the compensating function resulted in an increase to \(I_{\dot{e}_{2k}}\ =\ \int_{0}^{T_{1}}\bigl{|}\dot{e}_{2k}(t)\big{|}\ dt\ =\ 7.63\) (Figure 15). However, when investigating \(I_{\dot{e}_{2}}\ =\ \int_{0}^{T_{1}}\dot{e}_{2}(t)\ dt\ =\ 0.23\) and \(I_{\dot{e}_{2}}\ =\ \int_{0}^{T_{1}}\dot{e}_{2k}(t)\ dt\ =\ 0.21\), one can notice an improvement in the operation. Adding the compensation function resulted in stronger oscillations over the given velocity signal, and therefore, the quality factors lowered; however, what was the most visible was how it reduced the maximal error at the beginning of the movement. In the next step, an experiment with the sinusoidal input \(\varphi_{sz2}\) was performed for the same adopted parameters as for the test without the compensating function (Figure 16). Figure 14: Summary of position errors for linear input signal \(\ \varphi_{2}\): \(e_{2}(t)\)-position error, \(e_{2k}(t)\)-position error with compensation function.