A Smartphone-Based Acquisition System for Hips Rotation Fluency Assessment

The present contribution is motivated by recent studies on the assessment of the fluency of body movements during complex motor tasks. In particular, we focus on the estimation of the Cartesian kinematic jerk (namely, the derivative of the acceleration) of the hips' orientation during a full three-dimensional movement. The kinematic jerk index is estimated on the basis of gyroscopic signals acquired through a smartphone. A specific free mobile application available for the Android mobile operating system, HyperIMU, is used to acquire the gyroscopic signals and to transmit them to a personal computer via a User Datagram Protocol (UDP) through a wireless network. The personal computer elaborates the acquired data through a MATLAB script, either in real time or offline, and returns the kinematic jerk index associated to a motor task.


I. INTRODUCTION
C OMPLEX body tasks, such as rock climbing, involve the alternation of periods dedicated to postural regulation and of quadruped displacement.The Figure 1 illustrates a typical hips sway during climbing.In neurosciences engineering [1] and in sports science [16], the assessment of body fluency provides valuable information on the patient's musculoskeletal system as well of the mental state of an athlete (for example, rigid posture and erratic movements during a climbing performance may indicate a state of anxiety [17]); likewise, since restoring movement fluency is a key focus in physical rehabilitation, objective measurement of fluency is of prime importance [9].
While previous studies on the fluency of body movements from temporal and spatial measurement analyses took into account only the displacement of the hips on a two-dimensional projective plane [3], recent studies have highlighted how the presence of anteroposterior and lateral sway would rather imply the need of combined temporal and full 3-dimensional movement analysis.Such analysis should take into account both hip translation and rotation.The recent study [17], in particular, focuses on the assessment of the kinematic jerk of the hips rotation during a complex body task.In kinematics, the jerk of a positional variable is defined as its third timederivative, namely, as the derivative of the acceleration.
The present technical report is dated December 22, 2021.Personal use of this material is permitted.However, permission to use this material for any other purposes must be obtained from the corresponding author.The hips orientation is described by a 3 × 3 rotation matrix which is a function of the time.Therefore, the orientation jerk is defined as the third-order time-derivative of a curve on the group of special orthogonal matrices.Such group, denoted as SO(3), is a curved manifold, hence, in such space, the assessment of kinematic variables such as acceleration and jerk is not straightforward as it is for curves in the ordinary space R 3 .
Although a complete analysis of body movement fluency would imply a statistical characterization of both hips rotation jerk and translation jerk, the study [17] showed that the (normalized) kinematic jerk of hips orientation and the (normalized) kinematic jerk of hips trajectory exhibit a significant positive correlation, signifying that both measures provide a similar measure of fluency.In addition, several clinical studies focus on hips rotation only, such as, for example, the research [10], that focuses on the analysis of reduced range of motion of the hips, which is an established clinical indicator of osteoarthritis.
A number of related studies made use of the kinematic jerk of positional data to investigate (bio)mechanical phenomena.In the studies [1], [6], concerning human three-dimensional pointing movements, it is assumed that the speed profile along the hand path is determined by minimization of the squared kinematic jerk.Likewise, in the paper [15], the impact of a kinematic jerk index is analyzed in the context of the the generation of minimum time collision-free trajectories for industrial robots in a complex environment.In the research paper [18], it was hypothesize that there exists a functional relationship between kinematic jerk cost and energy consumption during walking.Energy consumption during walking is closely related to the gait speed.Minimum kinematic jerk theory states that a body movement is carried out by minimizing the kinematic jerk of the motion trajectory.The study [8] showed that kinematic jerk and its response spectrum can enhance the recognition of the nonstationary groundmotion.In fact, kinematic jerk represents the nonstationary component in the high frequency band of an earthquake wave.
The aim of the present contribution is to illustrate the details of a smartphone-based acquisition systems to evaluate hips rotation fluency by estimating the kinematic jerk of the acquired signals.Nowadays, smartphones come with a large set of embedded sensors, including gyroscopes.The previous contribution [12] investigated instrumented 'Timed Up and Go' based on a specialized measurement system, namely, the accelerometer of a smartphone, to identify and evaluate specific mobility skills.The contribution [13] evaluated the reliability of a smartphone accelerometer in gait analysis.Likewise, the project SmartGait TM [11] makes use of a smartphone to acquire a number of postural indicators from a moving body with the aim to develop an inexpensive and accurate gait tracking tool that can be easily implemented by researchers and clinicians.

II. ACQUISITION OF A GYROSCOPIC DATA-STREAM BY A SMARTHPHONE AND A PERSONAL COMPUTER
The present section explains how to connect wirelessly an ANDROID TM -based smartphone with a personal computer equipped with a MATLAB development environment to process the acquired data.
The smartphone runs under an ANDROID TM mobile operating system and is worn on the waist of an athlete or a patient.An installed mobile application, namely the Hyper IMU, version 1.3, acquires the orientation of the smartphone expressed by three angles, namely yaw, ranging in [0, 360), pitch, ranging in [−180, 180) and roll, ranging in [−90, 90].An illustration of the three angles is displayed in the Figure 2. The application allows the user to set the sampling period from a minimum value of ∆T = 20ms.A screenshot of the Hyper IMU mobile application is displayed in the Figure 3.
The transmission of the data-stream from a smartphone to a MATLAB -equipped personal computer takes place through a User Datagram Protocol (UDP, RFC 768) [14].The UDP was defined to make available a simple packet-switched communication mode in networks of interconnected devices.The UDP assumes that the Internet Protocol (IP) is used as underlying protocol.The UDP provides a means for mobile applications and computer programs to exchange messages to each other with a minimum of protocol machinery.
If the room where the measures take place is served by a wireless router, the smartphone and the personal computer may be connected to the wireless network and exchange data.Otherwise, (as, for example, in an outdoor experiment), it is possible to make a personal computer behave as a wirelessnetwork access point that the smartphone may bind to.Under a MICROSOFT WINDOWS operating system, the access point may be created upon the execution of the command netsh wlan set hostednewtork mode allow ssid=... key=... keyUsage=persistent where the parameter ssid denotes the name assigned to the access point and the parameter key denotes the access password.The wireless network starts operating upon the execution of the command netsh wlan start hostednetwork while, upon the execution of the command netsh wlan stop hostednetwork the access point stops operating.
The MATLAB platform was used to acquire the gyroscopic signals from the smartphone and to compute the kinematic jerk index of an acquired signal.In the MATLAB language, a port is managed like a data-file, therefore, reading out signals from a smartphone via a wireless network can be performed like reading the records of a data-file, as shown in the code excerpt Listing 1.Such script shows the minimal instructions set necessary to acquire the data correctly.It might need additional instructions to reset the MATLAB settings (such as the instrreset command) and to display and save the acquired data.
Line 6 of the MATLAB script creates the UDP object UDPComIn and specifies the IP address and the port number Lport of the transmitter.Setting the IP address to the conventional value 0.0.0.0 indicates that the actual IP address of the transmitting device is not specified and that the computer will listen to any data stream sent through the port specified at Line 5 (which needs, therefore, to be uniquely dedicated to the communication between the smartphone and the personal computer).Using the conventional IP address 0.0.0.0 allows the acquisition script in Listing 1 to work within a dynamic host configuration protocol (DHCP) network.
The Line 7 of the script sets relevant attributes of the object UDPComIn, namely: • the attribute UDPComIn.DatagramTerminateMode to the value off, in order to make the personal computer keep acquiring packets as they become available from the smartphone; • the attribute UDPComIn.InputBufferSize to the value DataStream, whose value is set in Line 5, so that the personal computer will stop listening after a sufficiently large number of acquired characters; • the attribute UDPComIn.TimeOut to the value LstTime, expressed in seconds and set in Line 5, so that the personal computer will stop listening after a sufficiently time-span to allow acquiring the gyroscopic signals pertaining to a sufficiently long experiment.It should be noted that the conditions set on the input buffer size and on the timeout cause the listening process to stop, whichever verifies first.
Line 11 of the MATLAB script Listing 1 reads the character-string output from the smartphone into the variable readout.The variable readout appears as a string of the format Namely, every record is formed by three angles (expressed in degrees and represented as floats) separated by two commas and each record ends with a hash character.
The commands in the Lines 13-15 separate each record and construct a cell object, named scan, that contains the list of acquired yaw, pitch and roll angles.Line 16 expunges empty records.
The Line 17 converts the string-type cell elements into numbers and the Line 18 constructs a 3 × N array data whose columns contain the acquired angles.
A further auxiliary MATLAB script converts the yaw, pitch and roll angles triples to a gyroscopic signal R(t), whose elements are 3 × 3 rotation matrices, that represents the instantaneous orientation of the smartphone with respect to a fixed reference frame (typically defined on the basis of a magnetoscopic sensor).The obtained gyroscopic signal will be converted back to angular speeds as explained in the next Section.The intermediate rotation data are introduced in order to make the procedure independent of the type of acquired data, since different gyroscopic mobile applications might acquire different kinds of angles 1 .

III. COMPUTATIONAL ESTIMATION OF THE KINEMATIC JERK INDEX ASSOCIATED TO A GYROSCOPIC DATA STREAM
Given a hips rotation trajectory R(t), define the "angular velocity" matrix field The matrix Ω is 3×3 and skew-symmetric, namely, its diagonal elements are zero and only its 3 strictly-upper triangular entries are independent of each other, namely The "vee" operator ∨ [2] returns, in a vector, such independent entries.One may, thus, associate to a trajectory R(t) a vectorized angular velocity whose entries are ω The contribution [17] takes, as hips rotation jerk, the second-order time-derivative of the 3 × 1 vector ω, namely ω(t).The advantage of such definition of kinematic jerk is that it appears as a vector in R 3 and the scalar kinematic jerk may be simply computed through the 2-norm ω .By using the above parameterization for the angular velocity matrix, the scalar kinematic jerk taken in [17] is computed as The integrated kinematic jerk index associated to a trajectory R(t), t ∈ [0 T ], is defined as where the constant C is chosen in a way that makes the kinematic jerk index J dimensionless.The index J defined in ( 5) is termed Cartesian kinematic jerk to distinguish it from other possible definitions (see, for example, [19]).Furthermore, the constant C is chosen in a way that makes the kinematic jerk index independent from the total length of a path and from the total observation time T .In order to estimate numerically the derivative Ṙ(t), the paper [17] makes implicitly use of the following idea.Let R k and R k+1 denote two subsequent samples of an acquired, discrete-time gyroscopic data-stream counting N observations spaced apart in time of ∆T .The relationship between the number of acquired samples, the sampling interval and the total observation time is Consider such samples as joined by a geodesic arc of the curved space SO(3) (for a review of the geometry of the special orthogonal group, readers might consult, e.g., [4], [5]), namely where exp R (•) denotes a group exponential map at R ∈ SO(3) and Exp denotes the matrix exponential.Reversing such formula by means of the logarithmic map, one gets the estimate where Log denotes the (principal) matrix logarithm (that can be calculated, by the MATLAB language, by the function logm).Let us define ω k def = Ω ∨ k .Now, the kinematic jerk index may be estimated as the sum where ωk The total length of a measured data-stream may be defined as which can be estimated numerically as In the spirit of the contributions [17], [19], the normalization constant C may be defined as The MATLAB function that implements the above calculations is displayed in the Listing 2. The MATLAB function displayed in the Listing 2 inputs an array R of size 3×3×N and a sampling period DT and returns the numerical estimate of the Cartesian kinematic jerk index (9).At Line 9, note that the operator real was introduced to get rid of the imaginary part of the matrix logarithm, that, in principle, should be equal to zero, while, in practice, it arises from finite-precision machine calculations.

IV. EXPERIMENTAL RESULTS
The current Section presents results of experiments on the acquisition of hips rotation data and on the computational assessment of the fluency of a body movement during complex motor tasks.The experiments were performed on acquired data measured in different conditions.

A. Acquisition of test-type complex-body-movement signals
As a preliminary test of the described acquisition procedure and of the kinematic jerk-estimation scripts, three different kinds of gyroscopic signals were acquired during three complex body tasks: walking, running and jumping.The walking and running body tasks were carried out over a straight path 10 meters long.During the acquisition of the gyroscopic signals, the smartphone was fastened to the subject's belt.
A number N = 450 of samples was acquired for each task.The data stream acquired during walking is displayed in the Figure 4, the data stream acquired during running is displayed in the Figure 5 and the data stream acquired during jumping is displayed in the Figure 6.The results of the computation of the Cartesian kinematic jerk J according to the formula (9) are displayed in the Table I.As it is readily appreciated, the Cartesian kinematic jerk grows in value as the analyzed motion becomes increasingly erratic.

B. Acquisition of signals during indoor wall climbing sessions
The gyroscopic signals pertaining to the present experiment were acquired in a gym equipped with a professional wall- In particular, an Expert, an Intermediate-level and an Inexpert climbers completed two different climbing tasks, hereafter termed Task α and Task β.A frame of a camera-recording taken during a climbing session is displayed in the Figure 1.The experience level of the athletes as well as the hardness of a climbing task were evaluated by a professional trainer.
Before performing each task, the athletes planned a sequence of hand-grasps, in order to make the execution of the tasks as uniform as possible, while the foot standing strategy was left to each athlete's discretion.Nevertheless, due to the different level of experience of the athletes, the elapsed time took by each athlete to complete the same task was different, resulting in a different data-stream length for each of the six resulting sessions (one session per athlete and per task).
As an example of the acquired signals over Task β, the acquired gyroscopic signals, under the form of Yaw, Pitch and Roll pertaining to the Inexpert athlete are displayed in the Figure 7, the acquired signals pertaining to the Intermediatelevel athlete are displayed in the Figure 8, while the gyroscopic signals pertaining to the Expert athlete are displayed in the Figure 9.
The results of Cartesian kinematic jerk computation are displayed in the Table II.Even in this case, for each task separately, the Cartesian kinematic jerk grows in value as the analyzed motion becomes less fluent.It is interesting to compare the value of the accumulated kinematic jerk J index  with the value of the accumulated velocity d also reported in the Table II: Such phenomenon may be rephrased in terms of kinematics statistics by saying that there exists a weak correlation between the velocity index and the kinematic jerk index, in general.

V. CONCLUSION
The present research work deals with a new acquisition procedure to evaluate hips orientation fluency during a complex body motion task.The illustrated data-acquisition procedure is based on a smartphone endowed with a gyroscopic sensor that is able to reveal the instantaneous orientation of the hips of an athlete during motion.The smartphone runs an application that sends out the measured data over a wireless network and that transmits the acquired data, according to a User Datagram Protocol, to a personal computer.The personal computer, through a computer program written in MATLAB language and interpreted by a MATLAB environment, acquires in real time the gyroscopic data-stream and evaluates numerically a kinematic jerk index, taken as a meaningful measure of body movement fluency.The illustrated procedure was first tested on specific motor tasks, such as walking, running and jumping, as a validation stage.Then, data acquisitions were performed in a professional gymnasium, equipped with a professional wall-climbing facility.In particular, the hips orientation during climbing of three athletes with different skills were recorded over two different walls.
The obtained results confirm that the procedure is reliable and the numerical results of kinematic jerk index estimation could confirm the self-evaluation of the athletes' skills.
Possible extensions of the present work are real-time processing of the acquired gyroscopic data (to allow athletes to obtain a real-time feedback on their performances), multichannel acquisition by several concurring smartphones (to allow merging gyroscopic data pertaining to different body movements), remote acquisition/processing of gyroscopic data (to allow a central server to acquire and process the data streams sent over a wireless or cable network from different remote geographical sites) in a telemedicine setting, and the design of an automated (possible machine-learning based) classification algorithm to discern between different bodymovement fluency levels.

Fig. 2 .
Fig. 2.An illustration of the three angles yaw, pitch and roll returned by the 'Hyper IMU' mobile application.

Fig. 3 .
Fig. 3.A screenshot of the freeware 'Hyper IMU' mobile application for the ANDROID TM mobile operating system.

Fig. 6 .
Fig. 6.Walking, running and jumping gyroscopic signal.Graphical representation of the Yaw, Pitch and Roll angles acquired during jumping (unwrapped, radians).Cartesian kinematic jerkWalking 104517 Running 158509 Jumping 206153 TABLE I CARTESIAN KINEMATIC JERK CALCULATED ON ACQUIRED GYROSCOPIC SIGNALS OF THE TYPE 'WALK', 'RUN' AND 'JUMP'.

Fig. 9 .
Fig. 9. Gyroscopic signals acquired in a gym equipped with a professional wall-climbing facility: Expert athlete on Task β (unwrapped, radians).