## 3 Digital Twin and Physical Twin Integration
### Virtual Prosthesis Dynamic Model and Trackers Interface
Corrective impulses \(\{P\}_{constraint}\) generate variations according to [PERSON]'s law of impulses:  
\[[M]\Big{(}\{\dot{q}\}_{corrected}-\{\dot{q}\}_{approx}\Big{)}=\{P\}_{constraint} \tag{4}\]  
where \(\{\dot{q}\}_{corrected}\) is the vector of the corrected velocities that can be computed from Equation (4) as:  
\[\{\dot{q}\}_{corrected}=\{\dot{q}\}_{approx}+[M]^{-1}\{P\}_{constraint} \tag{5}\]  
Considering that impulses are exerted to satisfy constraints, it will result in the following:  
\[\{P\}_{constraint}=\left[\psi_{q}\right]^{T}\{\delta\} \tag{6}\]  
where \(\left[\psi_{q}\right]\) is the Jacobian matrix of the constraint equations and \(\{\delta\}\) is the vector of the Lagrange multipliers associated with the impulses. Considering the time derivatives of the constraint equations, we obtain:  
\[ \begin{array}{l}\{\psi\}=\{0\}\Rightarrow\frac{\mathrm{d}\{\psi\}}{\mathrm{d}t} =\big{[}\psi_{q}\big{]}\big{\{}\hat{q}\big{\}}+\{\psi_{t}\}=\{0\}\\ \big{[}\psi_{q}\big{]}\big{\{}\hat{q}_{corrected}\big{\}}+\{\psi_{t}\}=\{0\}\end{array}  \tag{7}\]  
Substituting the corrected accelerations in Equation (7):  
\[\big{[}\psi_{q}\big{]}\Big{(}\Big{\{}\dot{q}_{approx}\Big{\}}+[M]^{-1}\big{[} \psi_{q}\big{]}^{T}\{\delta\}\Big{)}+\{\psi_{t}\}=\{0\} \tag{8}\]  
Solving for Lagrange multipliers of the impulses:  
\[\{\delta\}=\Big{(}\big{[}\psi_{q}\big{]}[M]^{-1}\big{[}\psi_{q}\big{]}^{T} \Big{)}^{-1}\Big{(}\big{[}\psi_{q}\big{]}\big{\{}\hat{q}\big{\}}_{approx}+\{ \psi_{t}\}\Big{)} \tag{9}\]  
and consequently, we find the impulses to be applied:  
\[\{P\}_{constraint}=\big{[}\psi_{q}\big{]}^{T}\{\delta\} \tag{10}\]  
Correcting the accelerations and fulfilling the constraints requires a few iterations by repeating the algorithm. The sequential impulse formulation is also particularly suitable for managing contacts, which are necessary to implement the general forms of interaction with virtual objects in the immersive scene. In particular, the collisions may be treated as penalty constraints. The generic not-overlapping condition between two bodies, \(C_{n}\) can be written as:  
\[C_{n}=(\mathbf{P}_{A}-\mathbf{P}_{B})\cdot\mathbf{n}_{A}\geq 0 \tag{11}\]  
where \(\mathbf{P}_{A}\) and \(\mathbf{P}_{B}\) are the closest points of two bodies that can come in contact and \(\mathbf{n}_{A}\) is the normal unit vector of the body shape at \(\mathbf{P}_{A}\). Equation (11) can be written at the velocity level as:  
\[\frac{dC_{n}}{dt}=\hat{C}_{n}=\frac{d(\mathbf{P}_{A}-\mathbf{P}_{B})}{dt} \cdot\mathbf{n}_{A}+(\mathbf{P}_{A}-\mathbf{P}_{B})\cdot\frac{d\mathbf{n}_{A }}{dt}\geq 0 \tag{12}\]  
The Baumgarte scheme Baumgarte (1953) can be used to push the bodies apart when they overlap. The velocity constraint is augmented with a feedback term proportional to the penetration depth:  
\[\hat{C}_{n}+\beta C_{n}=0 \tag{13}\]  
where \(\beta\) is a tunable scalar parameter which governs the speed of the penetration resolution. Equation (13) is then appended to the vector \(\{\psi\}\) and treated as a generic constraint. Therefore, the complete procedure from the acquisition of the signals to the solution of the digital twin model to the integration with the virtual reality environment can be summarised in Figure 4.  
In summary, the proposed procedure starts with the acquisition of the signals from the trackers and the myoelectric pads. From the former, the information about the position and attitude of the trackers is extracted, and from the latter, the electrical potential differences are extracted and then transferred to the classifier. The classifier interprets the patterns and returns the most likely grasping posture. With this posture, the driving constraints on the spherical joints are updated to move the phalanges accordingly. The data of the position and the attitude of the trackers and of the driving constraints on the phalanges are then transferred to the sequential impulse solver that integrates the equations. Once resolved, the updated positions and attitudes of all rigid bodies of the model are known.