A Novel Explicit Analytical Multibody Approach for the Analysis of Upper Limb Dynamics and Joint Reactions Calculation Considering Muscle Wrapping

Featured Application: Explicit biomechanical multibody model for the inverse dynamics of upper limb musculoskeletal systems considering muscle wrapping. Abstract: The aim of this paper is to present an explicit analytical biomechanical multibody procedure able to be implemented in the solution of the musculoskeletal systems inverse dynamics problems. The model is proposed in formal multibody analysis and implemented in the Matlab numerical environment. It is based on the constraint kinematical behaviour analysis and considers both linear muscle actuators and curved ones, by calculating the geodesic muscle path over wrapping surfaces ﬁxed to the bodies. The model includes the Hill muscle approach in order to evaluate both the contractile elements’ actions and the passive ones. With the aim to have a ﬁrst validation, the model was applied to the dynamical analysis of the “arm26” OpenSim model, an upper limb subjected to external forces of gravity and to known kinematics. The comparison of results shows interesting matching in terms of kinematical analysis, driving forces, muscles’ activations and joint reactions, proving the reliability of the proposed approach in all cases in which it is necessary to achieve in-silico explicit determinations of the upper limb dynamics and joint reactions (i.e., in joint tribological optimization).


Introduction
In the framework of biomechanics, the dynamics of the human body plays an important role: it is necessary to apply knowledge of the joint contact forces during certain human kinematics motion to analyse the joint loading, and to define the synovial joints (hip, knee, ankle, etc.) tribological behaviour and mechanical performances. It is necessary to estimate the friction and the wear of the articulated surfaces [1][2][3], to predict some articular diseases such as the osteoarthritis [4,5] and to design prostheses able to replace the worn natural joint [6][7][8] or to investigate the influence of some properties on the prosthesis performance [9][10][11], etc.
The in vitro or in vivo approaches to study biomechanical phenomena, are characterised by a wide deviation of the measurement results. Since they are dependent on many parameters and vary from subject to subject [12][13][14], many experiments are required to define an average behaviour of a certain physical system. For these reasons, the in silico approach is becoming a very suitable way to overcome the described issues, and many software, able to solve numerically dynamical musculoskeletal systems, have been developed by researchers, such as OpenSim, AnyBody, etc.
Each software is built with algorithms used to approach mathematical problems; despite them being computationally optimized to solve problems, they are not fully controllable and they are not easy to use as a subroutine in more complex models.
A musculoskeletal system can be seen as a set of bodies; the bones, linked by joints which, simultaneously, allow and constrain the relative motions between them. It is moved by a complex actuation system composed by "deformable actuators" attached to the bodies, the muscles, governed by neural excitation signals [15]. In order to analyse the joint contact forces of an articulated system subjected to a known motion, one of the best ways to achieve the goal is to solve the inverse dynamics problem with a multibody approach, after performing the scaling and the inverse kinematics [16] to adapt the musculoskeletal system to the particular subject and motion.
With reference to the above issues, an analysis of scientific literature furnishes interesting findings. In [6] the authors analysed the differences between two multibody musculoskeletal models of the upper limb, an anatomical one and one provided with a reverse shoulder prosthesis. They focused on the comparison between the muscles' lengths, forces and joint reactions by varying the shoulder replacement location and geometry.
In [9] the authors validated the quality of a multibody simulation in the framework of above-knee amputees subjects based on a socket. They compared the calculated loads acting on the socket interface with the ones acquired by measurement devices applied on six subjects during level walking captured in gait laboratories, obtaining good agreements.
In [11] the authors discussed the theoretical multibody approaches and contact simulations in the framework of mechanical hands so as to adapt them to prosthetic hands. They studied the dynamical behaviour of the finger and the phalanx in order to analyse the grasping ability of the artificial hand.
In [17] the authors proposed to associate a fatigue model to the muscle one, in a general multibody simulation, considering the muscular force history, to evaluate its fitness level. The authors, with reference to a simple upper extremity system subjected to gravity and a concentrated load, obtained interesting results in terms of the increase of the muscles activation and/or of the number of recruited muscles after a loss of force production capacity.
In [18] the authors furnished a detailed description of the main techniques used to solve the inverse dynamics of musculoskeletal systems, showing the joint modelling, the muscular tissue dynamics and the physiological criteria. They applied the model in the case of the gait analysis of a geometrically reliable whole body.
In [19] the authors showed the multibody analysis potential to solve problems in the framework of the craniofacial biomechanics of both human and non-human applications.
In [20] the authors performed an overview on the multibody kinematic optimization, focusing on the reliability of the kinematical analysis associated to the upper limb modelling with respect to the motion of the soft tissue artefacts, the skin, which in general provides errors.
In [21] the authors developed an interesting multibody model of the human spine by discretising the linked intervertebral discs by a series of rotational joints, obtaining reliable results and pointing out on the model utility in the framework of the seating systems comfort investigation and of the surgical field.
In the above scientific framework, the aim of this paper is to develop, step by step, an explicit analytical multibody model representing the "core model" of a novel algorithm written by the authors in the Matlab environment, able to solve the inverse dynamics of upper limb musculoskeletal systems, allowing the explicit control of the involved variables. The reliability of the model is evaluated by performing a comparison with the results of an inverse dynamics analysis obtained from the open-source software OpenSim on the upper limb system subjected to a known kinematics example.

Musculoskeletal System
From a general point of view, a multibody model firstly needs the topology of the system, namely the set of n B bodies and n J joints together with the information about which joint links the parent body to the child bodies. The parent body of a joint is the body in which the joint is defined in terms of reference frame, while the child bodies of a joint are the bodies subjected to the relative motion, linked through the joint to the parent body.
We assumed as reference model the OpenSim "arm26" [22] ( Figure 1) together with the reference frames of the ground and the joints: it is composed of 3 bodies: the ground, the humerus and the forearm; these are denoted by the complex of the ulna-radius-hand and by 2 joints, the shoulder, which connects the humerus to the ground, and the elbow, which links the forearm to the humerus.

Musculoskeletal System
From a general point of view, a multibody model firstly needs the topology of the system, namely the set of bodies and joints together with the information about which joint links the parent body to the child bodies. The parent body of a joint is the body in which the joint is defined in terms of reference frame, while the child bodies of a joint are the bodies subjected to the relative motion, linked through the joint to the parent body.
We assumed as reference model the OpenSim "arm26" [22] ( Figure 1) together with the reference frames of the ground and the joints: it is composed of 3 bodies: the ground, the humerus and the forearm; these are denoted by the complex of the ulna-radius-hand and by 2 joints, the shoulder, which connects the humerus to the ground, and the elbow, which links the forearm to the humerus. Each body in the space is described by Lagrangian coordinates , (1), which is a vector of 7 elements composed of its mass centre translation with respect to the ground and its orientation with respect to the ground reference frame denoted by the unit quaternion .
According to the quaternion theory [23], a unit quaternion is a unit vector composed of a scalar real part and a vector imaginary part, describing the orientation of a floating reference frame rotated with respect to a fixed one by the knowledge of the rotation angle and the axis around which it is performed. The information about the quaternion and its time derivatives allows calculating a Each body i in the space is described by Lagrangian coordinates q i , (1), which is a vector of 7 elements composed of its mass centre G i translation with respect to the ground t i and its orientation with respect to the ground reference frame denoted by the unit quaternion θ i .
According to the quaternion theory [23], a unit quaternion θ is a unit vector composed of a scalar real part and a vector imaginary part, describing the orientation of a floating reference frame rotated with respect to a fixed one by the knowledge of the rotation angle and the axis around which it is performed. The information about the quaternion and its time derivatives allows calculating a body's angular velocity ω together with the rotation matrix R with respect to the ground reference frame. A kinematical analysis is necessary to elaborate the position r P , the velocity v P or the acceleration a P of any point P in the space (joint, muscle attachment point, external force application point, etc.) fixed to a body i, through its local position with respect to the body i, u P,i , the body's Lagrangian coordinates q i and their derivatives . q i and .. q i [23], as described in (2).

Kinematical Analysis Based on the Constraints
Since the time evolutions of the n do f system's degrees of freedom are known, a kinematical analysis can be immediately performed. The analysis is based on the idea that the system has to satisfy during the time t the set of constraint equations coming from the joints' kinematical behaviour, through the right set of the bodies' Lagrangian coordinates q [24,25], obtained by concatenating the individual ones q i along the column direction.
A multibody system made of n B bodies (including the ground) which move in a known way, is subjected to the constraint equations composed by: n do f rheonomic constraints which drive the degrees of freedom to move with the known trajectories (C r ); -n c scleronomic constraints due to the relative motions blocked by the joints kinematical behaviour (C s ); -(n B − 1) constraints which guarantee that the bodies' quaternions keep the unitary norm (C b ).
From the mobility Equation (3), the 7(n B − 1) constraint equations needed to find the same number of unknown q are included in the constraint vector C in (4).
The kinematical analysis, in (5), can be performed by solving the closed non-linear system of equations C through the Newton iterative method for the position problem and by differentiating the constraints with respect to time t, obtaining two linear systems to solve the velocity and acceleration, which provide the Lagrangian velocities Appl. Sci. 2020, 10, 7760

of 26
The constraint Jacobian C q and the other matrices and vectors involved in the kinematical analysis in (5) (C, C t , . C q , . C t ), are obtained by analysing the joints kinematical behaviour. In this application the shoulder and the elbow are modelled as revolute joints, so only this joint type is discussed. A revolute joint J allows only a relative rotation θ between the linked bodies i and j around an axis defined by the unit vectorv fixed to the parent body i, as showed in the Figure 2. he rheonomic constraint , associated to the revolute joint is generally mode ering that the scalar product between two particular vectors fixed to the related bodies ha al to the cosine of the relative rotation [18,25]: the periodicity of the trigonometric funct ot allow to reaching a unique solution numerically solving the position analysis. In this w articular constraint is modelled considering that the difference between the bodies' abso ar coordinates projected on the rotation axis ̂ has to be equal to the relative rotation n in (6). e joint position calculated starting from the body , , , has to be equal to the one seen by ody , , ; vector fixed to body , ̅ , parallel to the rotation axis ̂, has to be orthogonal with respe thers two vectors fixed to the body , ̅ 1 and ̅ 2 , both orthogonal to the rotation axis ̂ each other. , = + ̅ , The rheonomic constraint C r,J associated to the revolute joint J is generally modelled considering that the scalar product between two particular vectors fixed to the related bodies has to be equal to the cosine of the relative rotation θ [18,25]: the periodicity of the trigonometric functions does not allow to reaching a unique solution numerically solving the position analysis. In this work this particular constraint is modelled considering that the difference between the bodies' absolute angular coordinates ϕ projected on the rotation axisv has to be equal to the relative rotation θ, as written in (6).
The related scleronomic constraints C s,J are composed of a translational part and a rotational one [25], in (7): the joint position calculated starting from the body i, r J,i , has to be equal to the one seen by the body j, r J,j ; -a vector fixed to body j, s j , parallel to the rotation axisv, has to be orthogonal with respect to others two vectors fixed to the body i, s i1 and s i2 , both orthogonal to the rotation axisv and to each other.
While the joint local positions u J,i and u J, j are provided by the geometry of the system, the vectors s j , s i1 and s i2 can be calculated considering the spherical transformation that rotates the reference frame of the body i or j leading the x axis to be parallel with respect to the rotation axisv.
The time derivatives of the rheonomic constraint are then performed in (8) (considering that from the quaternion theory results Collecting the terms in order to build the matrices needed for the kinematical analysis, Equation (9) is obtained.
The same logic is adopted in order to find the time derivatives of the scleronomic constraints in (10).
Collecting the terms again, Equation (11) is obtained.
Once the rheonomic and scleronomic constraints are evaluated, the ones related to the quaternions' unitary norm are written for each body i in (12).
The time derivatives of C b,i are evaluated in (13).

of 26
Collecting the terms for the last time, Equation (14) is written.
Every constraint k is written in the form of (15) in order to extrapolate the needed submatrices that have to be associated to the related i and j bodies' Lagrangian coordinates, so that the kinematical analysis can be solved. With reference to Equation (6), it is worth noting that the rheonomic constraint equations C r are written in such a way as to separate the functional dependence on the Lagrangian coordinates q, through the vector a, and the one on the time t, through the set of degrees of freedom q do f .

Inverse Dynamics
The solution over time of the kinematical problem provides all the quantities needed for the inverse dynamics. In particular, with reference to the chosen generalised coordinates q i , the equation of motion includes the mass matrix M, the vector of the centrifugal and Coriolis generalised force Q v and the external generalised force Q e [23] and it is written in the form of virtual work for a virtual displacement δq by including the work of the internal forces through the constraint Jacobian C q and the Lagrange multipliers λ in (16).
Since the work of the internal forces is considered, the equation of motion (22) is satisfied for any virtual displacement δq: in order to refer the bodies' orientations to the local cartesian angular coordinates ϕ i , instead of the quaternion θ i , a coordinate change is performed through the matrix J q [23], in (17).
The generalised force vector Q c and the new constraint Jacobian C q are defined in (18), leading to the final form of the multibody equation of motion.
The coordinate transformation in (17) allows neglecting the part of the Jacobian associated with the constraints needed to keep the quaternions' unitary norm: then Equation (18) becomes a closed linear system in which the unknowns are the Lagrange multipliers associated with the rheonomic constraints λ r , representing the driving forces associated to each degree of freedom, and the ones related to the scleronomic constraints λ s [25], as showed in (19).
Appl. Sci. 2020, 10, 7760 8 of 26 The scleronomic multipliers λ s are not equal to the joint reaction forces, because the actuation of the musculoskeletal system doesn't associate a single actuator to each degree of freedom: there are more muscles than degrees of freedom (redundancy) and, moreover, the muscular action is composed of a passive part which has to be considered as a known external force. In order to evaluate muscle forces and joint reactions, a muscle model is needed.

Hill Muscle Model
The Hill muscle model considers the muscle-tendon unit as a linear actuator between two attachment points A and B on the linked bodies ( Figure 3) composed by the series of the tendon SE with length l t and the muscle, that is modelled as a parallel between the contractile element CE and the passive element PE, with length l m and inclined with respect to the action line by the pennation angle α p [26][27][28].
The scleronomic multipliers are not equal to the joint reaction forces, because the actuation of the musculoskeletal system doesn't associate a single actuator to each degree of freedom: there are more muscles than degrees of freedom (redundancy) and, moreover, the muscular action is composed of a passive part which has to be considered as a known external force. In order to evaluate muscle forces and joint reactions, a muscle model is needed.

Hill Muscle Model
The Hill muscle model considers the muscle-tendon unit as a linear actuator between two attachment points and on the linked bodies ( Figure 3) composed by the series of the tendon SE with length and the muscle, that is modelled as a parallel between the contractile element CE and the passive element PE, with length and inclined with respect to the action line by the pennation angle [26][27][28].  The force F m generated by the muscle-tendon series is shared by the tendon and the muscle, so it can be evaluated as the sum of the ones generated by the contractile element F CE , representing the active action due to the sarcomeres' contractions, and the passive element F PE , due to the muscular fibre tissue stiffness, projected on the action line through the pennation angle α p . The active part F CE depends on the activation level a, a scalar number between 0 and 1 determined by the muscular recruitment criterion, the muscle fibre length l m and deformation velocity v m through the force-length-velocity relationships, while the passive force F PE depends only on the muscle fibre length l m [28][29][30], as written in (20) and depicted in the Figure 4: according to the force-length relation f l , increasing the muscle fibre length, the active force increases until it reaches a peak (the maximum isometric force F 0 ) in correspondence with the optimal fibre length l 0 , then it decreases; -the muscle generates a greater force than the maximum isometric one (in correspondence of zero deformation velocity) when it lengthens, with an asymptotic behaviour, and a lower force until it reaches the maximum contraction velocity v max , beyond which it is not able to produce actuation, following the force-velocity relation f v ; Appl. Sci. 2020, 10, 7760 9 of 26 -the passive element opposes a growing resistance only if the muscle length is greater than the optimal fibre length l 0 , until it reaches a maximum value following the relation f PE . 20) it reaches the maximum contraction velocity , beyond which it is not able to produce actuation, following the force-velocity relation ; -the passive element opposes a growing resistance only if the muscle length is greater than the optimal fibre length 0 , until it reaches a maximum value following the relation . Generally it is assumed that the tendon dynamics is negligible, so that the tendon length can be considered as a constant, and that the muscle width keeps constant values, even in correspondence of the muscle optimal fibre length 0 , when the muscle is inclined by the known optimal pennation angle 0 . Then, with reference to Figure 3, Equation (21) is used to calculate the muscle length , the muscle deformation velocity and the pennation angle , starting from the length and the deformation velocity of the muscle-tendon unit, which are known from kinematical analysis [25]. Generally it is assumed that the tendon dynamics is negligible, so that the tendon length l t can be considered as a constant, and that the muscle width w m keeps constant values, even in correspondence of the muscle optimal fibre length l 0 , when the muscle is inclined by the known optimal pennation angle α 0 . Then, with reference to Figure 3, Equation (21) is used to calculate the muscle length l m , the muscle deformation velocity v m and the pennation angle α p , starting from the length l mt and the deformation velocity v mt of the muscle-tendon unit, which are known from kinematical analysis [25].

Wrapping Muscles
While some muscles' attachment points are fixed to the bodies, others depend on the particular pose of the musculoskeletal system, because the related muscles can wrap around bony surfaces fixed to the bodies [31][32][33]. In order to locate the intermediate attachment points due to the muscle wrapping, the curve that the muscle follows around the wrapping surface is modelled with a geodesic [34,35], since this approach models the wrapping muscle by constraining its associated curve to follow the smooth shortest path around the related surfaces; this approach also achieves a low computation cost. The surface's spatial representation can be described with two parameters, u and v, through the parametric equations x(u, v) which satisfy the implicit surface equation f (x) = 0. The geodetic curve c(s), along the curvilinear coordinate s, is evaluated as the constrained motion of a particle with mass m on the surface x(u, v) in absence of external actions: then the particle's equation of motion is assembled in (22) and it is solved according to its forward dynamics. The particle is characterised by three degrees of freedom in space; for the translation q, its mass m is arbitrary because its value affects only the Lagrange multiplier λ associated to the unique surface constraint C.
Differentiating the constraint C with respect to the curvilinear coordinate s, the constraint Jacobian C q and its derivative C q are obtained. The geodesic forward dynamics problem written in (23) is a closed non-linear differential algebraic equation and it is solved numerically by marching techniques. Coupling it with the initial conditions r 0 , the attachment point position, andt 0 , the tangent unit vector parallel to the surface, calculated from the straight-line muscle line action projected on the surface tangent plane, gives the initial direction: the solution q(s) is equal to the geodesic c(s).
With reference to Figure 5, in correspondence with each time instant, the model detects the contact between the straight-line muscles AB. and the associated surfaces x(u, v); then it calculates the geodesics starting from the two intersections P and Q on the surface, c P and c Q , varying the attachment points location until the original muscle AB is split in two straight-line muscle units AP and QB tangent to the surface while the related geodesics are collinear to each other in correspondence with the geodesics' closest points P * and Q * [34]. arbitrary because its value affects only the Lagrange multiplier associated to the unique surface constraint .
Differentiating the constraint with respect to the curvilinear coordinate , the constraint Jacobian and its derivative ′ are obtained. The geodesic forward dynamics problem written in (23) is a closed non-linear differential algebraic equation and it is solved numerically by marching techniques. Coupling it with the initial conditions 0 , the attachment point position, and ̂0 , the tangent unit vector parallel to the surface, calculated from the straight-line muscle line action projected on the surface tangent plane, gives the initial direction: the solution ( ) is equal to the geodesic ( ).
With reference to Figure 5, in correspondence with each time instant, the model detects the contact between the straight-line muscles and the associated surfaces ( , ); then it calculates the geodesics starting from the two intersections and on the surface, and , varying the attachment points location until the original muscle is split in two straight-line muscle units and tangent to the surface while the related geodesics are collinear to each other in correspondence with the geodesics' closest points * and * [34].  From the differential geometry, the tangent, normal and binormal unit vectors,t,n andb, respectively, are given in (24).t The objective is to find the unknown geodesics initial positions, the attachment points locations described by the surface parameters (u 0P , v 0P ) and u 0Q , v 0Q , that set to zero the function f in (25), in which the first two components impose the surface's tangency of the split muscles, while the last two components guarantee the geodesics' collinearity. The non-linear closed problem can be solved using the Newton iterative method, numerically calculating numerically the Jacobian function J f .
Once the Newton cycle has reached convergence, the two geodesics c P and c Q are joined in correspondence of the collinearity point, resulting in the definitive muscle path c PQ .
The surface types analysed in this work are the cylinder x c , with radius r and height h, and the ellipsoid x e , with semiaxes s x , s y and s z , given in (26).

Static Optimization
Once the muscle path is defined, the muscle forces have to be turned into generalised forces through the muscle Jacobian Φ q by the principle of virtual work in order to include them in the equation of motion [17,18,25]. In general, each muscle is modelled as a series of straight-line and curved musculotendon actuators (Figure 6), so the muscle's virtual work δW m is calculated with the sum of the individual units work considering that the muscle force F m is constant along the muscle path and that there is no friction between the muscle path and the wrapping surfaces [35]. With reference to Figure 6, the three bodies , and are linked by the same muscle, together with an intermediate wrapping surface fixed to another body : locating the musculotendon units action lines by the unit vectors ̂ and the position of the attachment points, the aim is to relate the virtual work to the bodies' generalised coordinates in order to build the muscle Jacobian in With reference to Figure 6, the three bodies i, j and k are linked by the same muscle, together with an intermediate wrapping surface fixed to another body w: locating the musculotendon units action lines by the unit vectorsl and the position r of the attachment points, the aim is to relate the virtual work to the bodies' generalised coordinates δq in order to build the muscle Jacobian Φ q in (27).
Then, once the muscle Jacobian Φ q and the muscle force vector F m have been assembled, the generalised muscle force Q m can be included as an external force in the equation of motion (16) instead of the constraint Jacobian part related to the rheonomic constraints, as written in (28).
Changing the orientation coordinates through the matrix J q , so as to neglect the constraint Jacobian part related to the unitary norm of the quaternions, Equation (29) is obtained.
Each muscle force F m,i depends on the muscle length l m,i , the muscle deformation velocity v m,i and the pennation angle α p,i through the Hill model: these quantities can be calculated through Equation (21), evaluating the musculotendon length l mt,i and deformation velocity v mt,i . Analysing each muscle series i, in general it can be composed by n s straight-line units (from A j to B j ) and n w wrapped units (from P k to Q k ), so the musculotendon length l mt,i and deformation velocity v mt,i can be calculated as the sum of the individual contributions in (30).
From Equation (20), each muscle force F m,i is written in Equation (31) as the sum of an active part F CE,i multiplied by the activation level a i and a passive part F PE,i , in order to relate the muscle force vector F m to the activation vector a, through the maximum active muscle force F CE , and the passive muscle force vector F PE (which take into account the muscles' length, velocity, pennation and maximum isometric force).
Substituting in (29), the unknowns in the equation of motion (32) are the activation vector a and the Lagrange multipliers related to the scleronomic constraints λ s , which definitely represent the joint reactions, by including the muscle activation Jacobian Φ q,CE and the generalised passive muscle force vector Q PE .
Since the linear equation system (32) has more unknowns than equations, due to the muscle redundancy, it is used as an equality constraint in the static optimization problem which minimizes the global muscle activation level (physiological criterion). If the muscle topology modelling is not accurate, the static optimization could fail, so the Lagrange multipliers associated with the rheonomic constraints λ r are reintroduced in (32) with the role of residual actuators, whose action has to be minimized together with the muscle activations (bounded between 0 and 1), in order to ensure the optimization convergence while satisfying the equation of motion, as written in (33).

Results and Discussion
In this section, the results regarding the simulation of the upper limb subjected to gravity during a simple kinematics are discussed. The input data are taken from the OpenSim model "arm26" [22]. As already mentioned, the analysed upper limb is composed of three bodies: ground, humerus and forearm; these are linked by two revolute joints, the shoulder and elbow, whose main data (inertial properties, relative locations and rotation axes) are listed in Tables 1-4.  The musculoskeletal system is moved by six muscles (long triceps, lateral triceps, medial triceps, long biceps, short biceps and brachialis), characterised by parameters included in the Table 5. The wrapping surfaces included are a cylinder fixed to the ground interacting with the long triceps, a first ellipsoid interacting with the long biceps, a second ellipsoid interacting with the long triceps (both the ellipsoids are fixed to the humerus) and a cylinder fixed to the humerus interacting with all the triceps on the back and with the brachialis on the front. The wrapping surfaces have locations u w and orientations θ w with respect to the reference joints, these are reported in Table 6, along with the surface geometries. The degrees of freedom are the shoulder and the elbow rotations and the analysed kinematics, as reported in Figure 7, which shows the movement of the elbow from 0 • to 90 • during 1 s while the shoulder does not move.
The degrees of freedom are the shoulder and the elbow rotations and the analysed kinemati s reported in Figure 7, which shows the movement of the elbow from 0° to 90° during 1 s while t oulder does not move. In order to prove the reliability of the kinematical analysis, Figure 8; Figure 9 show t mparison between the system configuration (the position of the bodies with their mass centre, t uscles and the wrapping surfaces) in the OpenSim model and in the Matlab model, rrespondence of the first and the last time instants. The kinematical analysis can be viewed upplementary Materials-Video S1. In order to prove the reliability of the kinematical analysis, Figure 8; Figure 9 show the comparison between the system configuration (the position of the bodies with their mass centre, the muscles and the wrapping surfaces) in the OpenSim model and in the Matlab model, in correspondence of the first and the last time instants. The kinematical analysis can be viewed in Supplementary Materials-Video S1.
Appl. Sci. 2020, 10, x FOR PEER REVIEW 14 of 24 The degrees of freedom are the shoulder and the elbow rotations and the analysed kinematics, as reported in Figure 7, which shows the movement of the elbow from 0° to 90° during 1 s while the shoulder does not move. In order to prove the reliability of the kinematical analysis, Figure 8; Figure 9 show the comparison between the system configuration (the position of the bodies with their mass centre, the muscles and the wrapping surfaces) in the OpenSim model and in the Matlab model, in correspondence of the first and the last time instants. The kinematical analysis can be viewed in Supplementary Materials-Video S1.  The long biceps wrapped on the ellipsoid keeps its path on the surface during the simulation because the shoulder angle is constant; it is shown in Figure 10. The wrapping muscles on the cylinder close to the elbow are viewed in Figure 11 at the start and at the end of the analysis time period, in order to show the brachialis wrapping on the cylinder front and the triceps wrapping on the cylinder back. The complete time evolution of the muscles' wrapping on the cylinder is available in Supplementary Materials-Video S2. The long biceps wrapped on the ellipsoid keeps its path on the surface during the simulation because the shoulder angle is constant; it is shown in Figure 10. The long biceps wrapped on the ellipsoid keeps its path on the surface during the simulat ecause the shoulder angle is constant; it is shown in Figure 10. The wrapping muscles on the cylinder close to the elbow are viewed in Figure 11 at the start a t the end of the analysis time period, in order to show the brachialis wrapping on the cylinder fr The wrapping muscles on the cylinder close to the elbow are viewed in Figure 11 at the start and at the end of the analysis time period, in order to show the brachialis wrapping on the cylinder front and the triceps wrapping on the cylinder back. The complete time evolution of the muscles' wrapping on the cylinder is available in Supplementary Materials-Video S2. A first quantitative comparison in the framework of the kinematical analysis is shown in Figure  12 on the muscles' fibre length , which also accounts for the muscle wrapping. Given that the comparison is satisfactory, the unique noticeable difference is related to the long A first quantitative comparison in the framework of the kinematical analysis is shown in Figure 12 on the muscles' fibre length l m , which also accounts for the muscle wrapping. A first quantitative comparison in the framework of the kinematical analysis is shown in Figure  12 on the muscles' fibre length , which also accounts for the muscle wrapping. Given that the comparison is satisfactory, the unique noticeable difference is related to the long biceps fibre length, probably due to a different wrapping algorithm used by the OpenSim software. After the kinematical analysis, the results of the inverse dynamics are shown in the Figure 13, in which the comparison between OpenSim and Matlab is made on the driving forces (rheonomic Lagrange multipliers ). The inverse dynamics outputs result in a very satisfactory match between the Matlab model and the OpenSim software. Given that the comparison is satisfactory, the unique noticeable difference is related to the long biceps fibre length, probably due to a different wrapping algorithm used by the OpenSim software. After the kinematical analysis, the results of the inverse dynamics are shown in the Figure 13, in which the comparison between OpenSim and Matlab is made on the driving forces (rheonomic Lagrange multipliers λ r ). The inverse dynamics outputs result in a very satisfactory match between the Matlab model and the OpenSim software. The tool "Static Optimization" in OpenSim does not take into account the muscle passive force and allows choosing between the physiological criterion by using the muscle's force-length-velocity relationships or not. In the latter option the muscular activation is intended as the ratio between the muscle force and the maximum isometric force 0 , bounded between 0 and 1. In the configuration of non-physiological criterion, the comparison on the muscles' activation is shown, respectively, in Figure 14. The comparison of the muscle forces is not shown because in this case the forces are proportional to the activations. The evaluated activations calculated with the Matlab model are slightly underestimated with respect to the ones evaluated by OpenSim, which, moreover, show some discontinuities. The tool "Static Optimization" in OpenSim does not take into account the muscle passive force and allows choosing between the physiological criterion by using the muscle's force-length-velocity relationships or not. In the latter option the muscular activation a is intended as the ratio between the muscle force F m and the maximum isometric force F 0 , bounded between 0 and 1. In the configuration of non-physiological criterion, the comparison on the muscles' activation is shown, respectively, in Figure 14. The comparison of the muscle forces is not shown because in this case the forces are proportional to the activations. The evaluated activations a calculated with the Matlab model are slightly underestimated with respect to the ones evaluated by OpenSim, which, moreover, show some discontinuities.
The results obtained with the physiological criterion but not taking into account the passive muscle forces are shown in Figure 15, in terms of muscle activations a, and in Figure 16, in terms of muscle forces F m . In this configuration there are small underestimations and overestimations in different parts of the time period and the OpenSim software returns some discontinuities, regarding both the activations and the muscle forces.
the muscle force and the maximum isometric force 0 , bounded between 0 and 1. In the configuration of non-physiological criterion, the comparison on the muscles' activation is shown, respectively, in Figure 14. The comparison of the muscle forces is not shown because in this case the forces are proportional to the activations. The evaluated activations calculated with the Matlab model are slightly underestimated with respect to the ones evaluated by OpenSim, which, moreover, show some discontinuities.  The results obtained with the physiological criterion but not taking into account the passive muscle forces are shown in Figure 15, in terms of muscle activations , and in Figure 16, in terms of muscle forces . In this configuration there are small underestimations and overestimations in different parts of the time period and the OpenSim software returns some discontinuities, regarding both the activations and the muscle forces.   The "Computed Muscle Control" tool in OpenSim [36] allows evaluating the muscle activations, also considering the passive muscle forces, by calculating through PID controllers the muscle actions necessary to obtain the minimum difference between the trajectories of the degrees of freedom The "Computed Muscle Control" tool in OpenSim [36] allows evaluating the muscle activations, also considering the passive muscle forces, by calculating through PID controllers the muscle actions necessary to obtain the minimum difference between the trajectories of the degrees of freedom simulated with the forward dynamics and the ones known by inverse kinematics. The comparison results regarding the muscle activation a and the muscle forces F m are shown respectively in Figure 17 and in Figure 18. In this last configuration, which includes all the analysed phenomena, despite the good qualitative match between the Matlab model and the OpenSim software, there are some discrepancies, probably due to the different approaches with respect to static optimization. While the muscle activations are underestimated, the muscle forces seems to be more similar to each other, except for the first instants of the time period discussed.
Appl. Sci. 2020, 10, x FOR PEER REVIEW 19 of 24 simulated with the forward dynamics and the ones known by inverse kinematics. The comparison results regarding the muscle activation and the muscle forces are shown respectively in Figure  17 and in Figure 18. In this last configuration, which includes all the analysed phenomena, despite the good qualitative match between the Matlab model and the OpenSim software, there are some discrepancies, probably due to the different approaches with respect to static optimization. While the muscle activations are underestimated, the muscle forces seems to be more similar to each other, except for the first instants of the time period discussed.   Another interesting result is obtained regarding the residual actuators (which are the rheonomic Lagrange multipliers of Equation (33)), also provided in the OpenSim tools, in this configuration. With reference to Figure 19, the residual actuators show a similar behaviour, both quantitively and qualitatively. The quantitative response of the residual actuators shows that the Another interesting result is obtained regarding the residual actuators λ res (which are the rheonomic Lagrange multipliers λ r of Equation (33)), also provided in the OpenSim tools, in this configuration. With reference to Figure 19, the residual actuators show a similar behaviour, both quantitively and qualitatively. The quantitative response of the residual actuators shows that the particular muscles' topology, together with their characteristic parameters listed in Table 5, does not fully satisfy the equation of motion, since they result from the minimization, but their role is marginal if compared to the rheonomic Lagrange multipliers coming from the inverse dynamics ( Figure 13) and, in fact, the residual action is needed just to reach the minimization convergence and to complete the calculus, not for substituting the real actuators represented by the muscles.
Appl. Sci. 2020, 10, x FOR PEER REVIEW 20 of 24 particular muscles' topology, together with their characteristic parameters listed in Table 5, does not fully satisfy the equation of motion, since they result from the minimization, but their role is marginal if compared to the rheonomic Lagrange multipliers coming from the inverse dynamics ( Figure 13) and, in fact, the residual action is needed just to reach the minimization convergence and to complete the calculus, not for substituting the real actuators represented by the muscles. Once the inverse dynamics problem of the musculoskeletal system is solved, the Matlab model provides the joint reactions. In Figure 20, the joint reactions (which are the scleronomic Lagrange multipliers of Equation (33)) which act on the upper limb joints during the analysed kinematics are shown. Once the inverse dynamics problem of the musculoskeletal system is solved, the Matlab model provides the joint reactions. In Figure 20, the joint reactions λ jr (which are the scleronomic Lagrange multipliers λ s of Equation (33)) which act on the upper limb joints during the analysed kinematics are shown. Once the inverse dynamics problem of the musculoskeletal system is solved, the Matlab model provides the joint reactions. In Figure 20, the joint reactions (which are the scleronomic Lagrange multipliers of Equation (33)) which act on the upper limb joints during the analysed kinematics are shown.

Conclusions
The objective of this work was to propose and to describe step by step the procedure to achieve a general multibody approach able to solve the inverse dynamics problem of a musculoskeletal system, the upper limb, implemented in a novel code developed in the Matlab environment. By knowledge of the musculoskeletal system degrees of freedom together with the system's topology, the model allows a kinematical analysis based on the evaluation of the constraints' kinematical behaviour. Subsequently, associating an actuator for each degree of freedom and including the external forces, the inverse dynamics is solved by calculating the rheonomic Lagrange multipliers, related to the driving actions that lead the system to move following the known kinematics. The knowledge of the muscles' topology leads the kinematical analysis to evaluate the muscle paths between the bodies and around the wrapping surfaces fixed to the bodies: in the case of wrapped muscle, an algorithm based on the calculus of geodesic curves is used. The muscle paths are involved in the elaboration of the muscles' lengths, deformation velocities and pennation angles, in order to include in the equation of motion, through the Hill muscle model, the muscles' passive forces and the muscles' activations. The last step of the model is to analyse the muscular recruitment through static optimization: the evaluation of the set of muscles' activation levels and joint reaction forces, able to minimize the global activation and to satisfy the equation of motion.
The effectiveness of the model was examined by its application on an upper limb model subjected to a simple kinematics and to gravity forces. All the inputs data were taken from the OpenSim software and the simulation results were compared with the ones provided by the software, obtaining a general satisfactory qualitative and quantitative matching: despite the kinematical analysis, exactness is noticeable, the only difference found was a small overestimation of the long biceps muscle fibre length, probably due to the different wrapping algorithm used by OpenSim; -the inverse dynamics in terms of driving force results were almost completely matched; -the static optimization was characterised by a general underestimation of the muscles' activations in all the cases considered (both physiological and non-physiological criterion in absence of passive muscles' forces and physiological criterion considering the passive muscle actions compared with the Computed Muscle Control tool of OpenSim). The underestimation was regained by comparing the muscle forces, the differences were probably due to the different approaches in the minimization techniques and, certainly, to the different approach to the inverse dynamics of the Computed Muscle Control; -the good outcome of the comparison was also confirmed by the matching of the residual actuators.
In summary, with the limitation of its validation with only one imposed upper limb kinematics, the model resulted as a suitable, open and fully controllable tool in the framework of the multibody musculoskeletal dynamics of the human upper limb. However, despite the model being characterised by the accurate analytical description of important muscular phenomena (muscle dynamics, recruitment and wrapping), it has to process more complex kinematics in order to perform a more accurate validation and to design a fully in silico optimization model of the artificial human joints. The deepening of the involved phenomena is always a stimulating necessity, in order to understand more clearly the human body mechanical behaviour, so future research perspectives will be devoted to: a full validation with more upper limb kinematics; -the application of the model in the framework of the lower limb musculoskeletal system, in order to compare the simulated joint reactions with the in vivo measurements during the gait analysis; -the coupling of the model with a lubrication one, in order to estimate the wear of an artificial joint or to evaluate the joints friction forces or torques to include in the equation of motion as non-conservative actions; -the upgrade of the model by including the forward dynamics, in order to make a detailed comparison with the Computed Muscle Control tool of the OpenSim software; -the deepening of the Hill muscle model, in order to include the tendon dynamics; -the possible applications of the model in the framework of the biomechatronics and robotics fields.  Tangent, normal and binormal unit vectors Φ q Muscle (Jacobian) a Muscle activation vector λ r , λ s Lagrange multipliers related to the rheonomic constraints (or residual actuators) and to the scleronomic constraints (or joint reactions)