*2.5. Hybrid Controller Description*

If a PR reaches a type II singularity, a controller must move the actuators to release the PR from the singularity, maintaining a minimum deviation from the original configuration. Therefore, a method to identify the best set of actuators to be moved is needed. The index Ω*i*,*j*, using the position and orientation of the mobile platform, is able to identify the actuators involved in the type II singularity. However, in a type II singularity, the measurement of the actual position and orientation of the PR require an external sensor, such as a 3DTS. For this reason, a novel controller able to release the PR under study from a type II singularity using the index Ω*i*,*<sup>j</sup>* and a 3DTS is proposed. It is important to note that this is the first time that the index Ω*i*,*<sup>j</sup>* is employed as an online proximity detector to a type II singularity.

The novel vision-based hybrid controller to release the 3UPS+RPU PR from a type II singularity is shown in Figure 9. The hybrid controller combines two-level closed loops: an algebraic algorithm (inner loop) and a type II singularity releaser (outer loop). The type II singularity releaser calculates the Ω*i*,*<sup>j</sup>* indices using the position and orientation of the PR provides by the OptiTrack 3DTS.

**Figure 9.** Hybrid controller architecture.

In the inner loop, the control signals (<sup>→</sup> *μ*) to track the desired actuator's location <sup>→</sup> *q indd* are calculated by an algebraic algorithm based on the measured location of the actuators → *q indc* . The <sup>→</sup> *μ* is proportional to the forces (<sup>→</sup> *τ* ) applied by the linear actuators to move the mobile platform.

In the outer loop, the reference location of the actuators (<sup>→</sup> *q indr* ) is obtained by solving the inverse kinematics for a knee rehabilitation trajectory (<sup>→</sup> *Xr*), and <sup>→</sup> *Xr* is designed for the 4-DOF of the 3UPS+RPU PR.

Based on the <sup>→</sup> *Xc* measured by the 3DTS, the proximity to a type II singularity is detected by <sup>→</sup> <sup>V</sup>Ω*<sup>c</sup>* and ||*JD*||*<sup>c</sup>* at every time step. <sup>→</sup> VΩ*<sup>c</sup>* stores the six Ω*i*,*<sup>j</sup>* indices as <sup>Ω</sup>1,2 <sup>Ω</sup>1,3 <sup>Ω</sup>1,4 <sup>Ω</sup>2,3 <sup>Ω</sup>2,4 <sup>Ω</sup>3,4 *<sup>T</sup>* . If the 3UPS+RPU PR gets close to a type II singularity, <sup>→</sup> *<sup>q</sup> indr* is modified to define <sup>→</sup> *q indd* . In Figure 9, the type II singularity releaser module (SRM) calculates the desired location of the actuator as follows:

$$
\stackrel{\rightarrow}{q}\_{ind\_d} = \stackrel{\rightarrow}{q}\_{ind\_r} + \nu\_d \cdot t\_s \cdot \stackrel{\rightarrow}{\Delta i} \tag{9}
$$

where *ν<sup>d</sup>* is the releasing velocity module for each actuator, *ts* stands for the controller sample time, and <sup>→</sup> Δ*i* represents an integer vector that counts the deviation required in the *F* actuators to release the PR from a type II singularity.

The SRM calculates <sup>→</sup> *<sup>q</sup> indd* at every time step, although <sup>→</sup> Δ*i* is modified only if an enable pin (*epin*) is activated. Two versions of the algorithms have been proposed to contrast the results when (i) moving the actuators that cause the singularity and (ii) moving the actuators that do not cause the singularity according to <sup>→</sup> VΩ*c*.

The first version (SRM-V1) releases a PR from a type II singularity by moving the limbs identified by minΩ*c*, which represents the minimum value of <sup>→</sup> VΩ*c*. If minΩ*<sup>c</sup>* or *JD<sup>c</sup>* is lower than a certain limit, <sup>Ω</sup>*lim* and *JDlim*, respectively, the two rows of <sup>→</sup> Δ*i* that have to change are identified by <sup>→</sup> *i ch*. The possible change combinations for the two rows of <sup>→</sup> Δ*i* are defined by the columns of M*inc* as follows:

$$\mathbf{M}\_{\text{inc}} = \begin{bmatrix} & 1 & -1 & 1 & -1 & 1 & -1 & 0 & 0\\ & 1 & -1 & -1 & 1 & 0 & 0 & 1 & -1 \end{bmatrix} \tag{10}$$

where 0, 1, and −1 correspond to the stop, unit forward motion, and unit backward motion commands for an actuator, respectively.

For each column of <sup>M</sup>*inc*, an auxiliary variable <sup>→</sup> *<sup>q</sup> ch* is initialized as <sup>→</sup> *q indd* , and then its elements indexed by <sup>→</sup> *i ch* are modified using the current M*inc* column. Then, it is checked that this position is confined within the geometrical limits. If <sup>→</sup> *q ch* is inside the actuators' displacement range, the forward kinematic problem is solved (<sup>→</sup> X*ch*). Next, the angles reached by the spherical joints (<sup>→</sup> <sup>α</sup>*ch*) are calculated. If <sup>→</sup> α*ch* is within the working range, a new <sup>Ω</sup>*i*,*<sup>j</sup>* is calculated for the limbs identified by <sup>→</sup> *<sup>i</sup> ch*, and it is added to <sup>→</sup> VΩ*ch*. Then, → <sup>Δ</sup>*<sup>i</sup>* takes the value of the column of <sup>M</sup>*inc* that produces the maximum element of <sup>→</sup> VΩ*ch* (maxΩ*ch*), as that combination contributes the most to releasing the singularity without exceeding any range limit. Finally, <sup>→</sup> *<sup>q</sup> indd* is updated using the new <sup>→</sup> Δ*i*.

An alternative algorithm called SRM-V2 has been proposed to test the behaviour when moving the wrong limbs. It modifies the rows of <sup>→</sup> Δ*i* that are not related to minΩ*<sup>c</sup>* ( → *<sup>i</sup> nc*) to release the PR from the type II singularity caused by the actuators <sup>→</sup> *i ch*. SRM-V2 is designed to verify that moving the actuators identified by minΩ*<sup>c</sup>* is the best way to release the 3UPS+RPU PR from a type II singularity.

The complete process performed by SRM-V1 is described in the pseudocode shown in Algorithm 1, where SRM-V2 is obtained by adding and replacing, the lines marked with ∗ and ∗∗, respectively. A description of the variables used in Algorithm 1 is presented in Table 2.


**Table 2.** Description of parameters, inputs, and outputs of SRM-V1 and SRM-V2.

**Algorithm 1.** Initialization 3 *INITIALIZATION* → <sup>Δ</sup>*<sup>i</sup>* <sup>=</sup> <sup>→</sup> 0 *Nch* = number of columns of M*inc*. *BEGIN* → *<sup>q</sup> indd* <sup>=</sup> <sup>→</sup> *q indr* + *νd*·*ts*· → Δ*i* **IF** *epin* == *true* minΩ*<sup>c</sup>* <sup>=</sup> minimum element in <sup>→</sup> VΩ*<sup>c</sup>* **IF** minΩ*<sup>c</sup>* < Ω*lim* OR *JD<sup>c</sup>* < *JDlim* **IF** minΩ*<sup>c</sup>* == <sup>→</sup> VΩ*c*(1) → *i ch* = 1 2 <sup>∗</sup> <sup>→</sup> *i nc* = 3 4 **ELSEIF** minΩ*<sup>c</sup>* == <sup>→</sup> VΩ*c*(2) → *i ch* = 1 3 <sup>∗</sup> <sup>→</sup> *i nc* = 2 4 **ELSEIF** minΩ*<sup>c</sup>* == <sup>→</sup> VΩ*c*(3) → *i ch* = 1 4 <sup>∗</sup> <sup>→</sup> *i nc* = 2 3 **ELSEIF** minΩ*<sup>c</sup>* == <sup>→</sup> VΩ*c*(4) → *i ch* = 2 3 <sup>∗</sup> <sup>→</sup> *i nc* = 1 4 **ELSEIF** minΩ*<sup>c</sup>* == <sup>→</sup> VΩ*c*(5) → *i ch* = 2 4 <sup>∗</sup> <sup>→</sup> *i nc* = 1 3 **ELSE** minΩ*<sup>c</sup>* == <sup>→</sup> VΩ*c*(6) → *i ch* = 3 4 <sup>∗</sup> <sup>→</sup> *i nc* = 1 2 **ENDIF** → VΩ*ch* = column vector of *Nch* zeros **FOR** *<sup>c</sup>*<sup>1</sup> <sup>=</sup> 1 : *Nch* <sup>→</sup> *<sup>q</sup> ch* <sup>=</sup> <sup>→</sup> *q indd* → *<sup>q</sup> ch*<sup>→</sup> *<sup>i</sup> ch* = <sup>→</sup> *<sup>q</sup> ch*<sup>→</sup> *<sup>i</sup> ch* + *νd*·*ts*·M*inc*(:, *c*1) ∗ ∗ <sup>→</sup> *<sup>q</sup> ch*<sup>→</sup> *<sup>i</sup> nc* = <sup>→</sup> *<sup>q</sup> ch*<sup>→</sup> *<sup>i</sup> nc* + *νd*·*ts*·M*inc*(:, *c*1) **IF** <sup>→</sup> *minqind* <sup>&</sup>lt; <sup>→</sup> *<sup>q</sup> ch* <sup>&</sup>lt; <sup>→</sup>*maxqind* (element-wise comparison) <sup>→</sup> <sup>X</sup>*ch* <sup>=</sup> Solve the Forward Kinematics for <sup>→</sup> *<sup>q</sup> ch*, using <sup>→</sup> *Xc* as initial condition → <sup>α</sup>*ch* <sup>=</sup> Angle of spherical joints for <sup>→</sup> X*ch* **IF** <sup>→</sup> <sup>α</sup>*ch* < <sup>→</sup> <sup>α</sup>*lim* (element-wise comparison) <sup>→</sup> <sup>V</sup>Ω*ch*(*c*1) <sup>=</sup> Calculate the index <sup>Ω</sup>*i*,*<sup>j</sup>* for <sup>→</sup> <sup>X</sup>*ch* with *<sup>i</sup>*, *<sup>j</sup>* <sup>=</sup> <sup>→</sup> *i ch* **ENDIF ENDIF ENDFOR** *<sup>c</sup>*<sup>1</sup> <sup>=</sup> *argmax* <sup>→</sup> <sup>V</sup>Ω*ch* → Δ*i* → *<sup>i</sup> ch* <sup>=</sup> <sup>→</sup> Δ*i* → *<sup>i</sup> ch* + M*inc*(:, *c*1) → *<sup>q</sup> indd* <sup>=</sup> <sup>→</sup> *q indr* + *νd*·*ts*· → Δ*i* **ENDIF ENDIF** *END*

Due to the properties of the index Ω*i*,*j*, the SRM algorithm has the advantage of moving a pair of *F* actuators simultaneously in each time step of the controller. For this reason, the SRM reduces the consumption of computing resources and the difference between <sup>→</sup> *<sup>q</sup> indd* and the original <sup>→</sup> *q indr* .

#### **3. Results**

This section begins with a detailed description of the simulation setup, including the singular trajectories to be tested with SRM-V1 and SRM-V2 versions of the hybrid controller. Next, the performance of the hybrid controller in simulation is evaluated, where SRM-V1 appears to be better than SRM-V2. Subsequently, the experimental setup and the features of the actual 3UPS+RPU PR are detailed. Finally, the main experimental results show the effectiveness of the hybrid controller using SRM-V1 to release the PR under study from a type II singularity.
