## 3 Control Design Methodology
### Design of the Mid-Level Control
#### 3.3.1 Passive User Mobilization  
This working mode exploits the position control. The exoskeleton moves the human limb in a rigid way, without keeping into account the interaction forces. A target trajectory is provided for each joint. The possible exercises are: shoulder flexion-extension, shoulder abduction-adduction and elbow flexion-extension. By means of the graphic user interface (Figure 6) it is possible to select the desired number of repetitions, timing (exercise duration) and maximum target angle. It is also possible to replicate, in position control, a recorded exercise. The model has a dedicated Stateflow state machine that can be used to perform the learn and replay. By exploiting the GUI buttons, it is possible to start the exercise recording (the exoskeleton goes in transparency mode and can be moved freely). Then joint position data are recorded, stored and used as target trajectory for the replay. 3.2 Compliant Exercises: Impedance Control to Provide Modular Assistance during Rehabilitative Exercises  
Impedance control can be exploited to support the patient in performing voluntary movements. Impedance control manages the capacity to exchange force between the controlled system and the subject or the environment. Linear impedance parameters, like stiffness and viscosity, are described as second-rank twice covariant tensors [31]. This impedance embodies the correlation between force and motion dictated by the supervisor, encompassing both the static force/displacement relationship and any dynamic terms necessary for controlled dynamic behavior [31]. Essentially, it dictates whether the robot exhibits rigidity or compliance upon interaction with external objects or surfaces. It belongs to the category of partially assistive controls [10], aiming to not only provide physical support but also to maintain the subject's motivation, training intensity, confidence in usingthe affected limb, and prevent negative reinforcement [21]. A tunable support level can be provided depending on the residual motor functionality of the user. The assistance level can be selected on the GUI, the target trajectories can be the ones of predefined exercises or a recorded complex trajectory stored during the learn-and-replay procedure. Impedance control can be used to ensure safety during human-machine interaction: it allows to dissipate torques and forces at joint level and not to the external environment. By tuning stiffness (\(k_{v}\)) and viscosity (\(\beta_{v}\)), it is possible to provide a modular assistance increasing the user engagement while decreasing the provided support. The adopted impedance algorithm is developed in the joint space. \[\Delta q=q_{target}-q_{actual} \tag{1}\]  
\[\tau_{interaction}=\tau_{SEA}-\tau_{gravity} \tag{2}\]  
\[\tau_{target}=\Delta q\cdot k_{v}+\vartheta\cdot\beta_{v}+\tau_{interaction} \tag{3}\]  
For each joint the control scheme shown in Figure 7 is applied. Simulink allows to fully explore the potential of real time computation. With reference to Figure 7, the Joint target position is real time computed for the standard exercises trajectory as a linear interpolation between the start and end position, set by the user into the GUI. This has to be performed in the desired amount of time and repeated for the selected number of repetitions. The trajectory can also be recorded during a learn process. The joint actual position and speed are provided from EPOS board. For this implementation a reference velocity \(\dot{q}_{tg}=0\) has been considered at all times. The sensed actual torque is computed by the model starting from the SEA sensor encoders readings (measure of the SEA spring deformation \(\Delta\theta\)), as explained in [17]:  
\[\tau_{SEA}=((\theta_{out}-\theta_{in})-\Delta\theta_{offset})\cdot k+\Delta \tau_{lm} \tag{4}\]  
Figure 6: Graphical User Interface Welcome Panel: within this tab of the GUI, crafted using the App Designer MATLAB Tool, users can establish the preferred working mode of the exoskeleton.