## 3 Control Design Methodology
### Design of the Mid-Level Control
#### 3.3.3 Transparency: Gravity and Friction Compensation  
Transparency mode is implemented in order to let the user perform free movements, exploring the working space minimizing the exoskeleton weight and friction effects that can interfere with the smoothness of the performed movement. The motor control is performed in torque (current), the control signal is computed from the sum of different components: the gravity torque, the friction compensation torque and the interaction torque (obtained from the SEA sensed torque). This control exploits two different layers:  
* Gravity compensation: it is needed to compensate the gravity effect to avoid that the structure collapses under its weight, thus a reliable gravity compensation model is needed. The obtained rigid body tree model (Figure 4) is exploited in Simulink by the Gravity Torque block of the Robotic Toolbox allowing to real-time compute, given a certain joints' configuration, the gravity torques to be compensated. * Friction compensation: frictions can result in a lack of smoothness during the movement, especially at low speeds when static frictions need to be won. A Stateflow state machine has been implemented to evaluate, based on the actual motor speed, a compensatory friction torque used to overcome friction dissipation. The friction contribute is computed as \(\tau_{fr}=-\beta_{fr}\cdot\dot{q}\), with \(\beta_{fr}\) parameter evaluated by the state machine in a dynamic way following Algorithm 1. \(\beta_{fr}\), is evaluated at each interaction. The highest compensation for overcoming frictions occurs at low speeds when static frictions need to be overcome. The coefficient \(\beta_{f}\) remains constant within an accepted speed range for movement in transparency. If the motor speed exceeds a specified threshold, indicating that the joint is moving too fast, \(\beta_{f}\) takes on a different value, increasing the viscous effect until reaching the maximum set velocity, thereby implying minimal support in overcoming frictions. Figure 7: The impedance control scheme employs the presented algorithm individually for each joint to compute the control signal. The reference target, representing the desired position, has to be reached by ensuring a certain compliance between the user and the device. The difference between the target and actual positions represents the delta displacement of a virtual spring, that multiplied by a virtual stiffness coefficient (\(k_{\mathrm{p}}\)) provides the spring torsional torque. The actual joint speed introduces a viscous behavior, determined by the viscous coefficient (\(\beta_{\mathrm{p}}\)). The interaction torque, calculated as the difference between the estimated SEA torque and the gravity torque, serves as the feed\(-\)forward term. This ensures that the user can displace the exoskeleton in a compliant manner. ```
if\(|q|\ <q_{s}\)then \(\beta_{fr}\leftarrow\beta_{s}\) else if\(|q|\ \geq q_{s}\) and \(|q|\ \leq q_{f}\)then \(\beta_{fr}\leftarrow\beta_{f}\) endif if\(|q|\ >q_{f}\)then \(\beta_{fr}\leftarrow\beta_{m}\cdot(q_{max}/|q|)\) endif endif
```  
**Algorithm 1** Friction compensation: the algorithm implemented in the dedicated state machine for friction compensation involves monitoring the rotational speed of the joint. Depending on the speed value, the compensation effect is determined, mirroring the behavior of a damper. Specifically, if the speed is below a minimum threshold, denoted as \(q_{s}\), it indicates that the joint is initiating movement. To overcome initial static friction, the compensation effects against friction are amplified. Within a predefined ideal speed range for device activities, the compensation contribution remains constant. However, if the speed exceeds a high threshold, denoted as \(q_{t}\), a gradual effect begins to compensate less against friction until minimal compensation is achieved at the predefined maximum speed, \(q_{\max}\).