RECyT

Year 24 / Nº 38 / 2022 /

DOI: https://doi.org/10.36995/j.recyt.2022.38.002

 

Electronic device for gait analysis

 

Dispositivo electrónico para el estudio de la marcha

 

Alejandro A., Vistorte Salgado1, *; Fidel E., Hernández Montero1; Gianna, Arencibia Castellanos1

 

1- Universidad Tecnológica de La Habana (CUJAE). Cuba.

* E-mail: alejandrovistorte@gmail.com

 

Received: 06/08/2021; Accepted: 20/01/2022

 

Abstract

In order to automate the determination of gait parameters, a system capable of acquiring data from inertial units, exploiting their maximum sampling frequency, was developed. The study of gait is one of the fundamental indicators for the evaluation of physical performance. It allows the estimation of the functional deterioration of the elderly in an objective way, so several tests have been designed to evaluate it. The system developed has two fundamental elements: an electronic device and a desktop application. The electronic device has the function of collecting data from the MPU-9255 sensor using an ESP32 to set the sampling rate, transmitting the data via WiFi to the computer and monitoring the system's battery. The desktop application allows the electronic device to be configured and controlled, as well as receiving, displaying and storing the data. As a result, a prototype capable of operating at a sampling frequency of 1 kHz was built. Tests carried out on the system demonstrate its reliability and allow the limits of sampling frequency and working distance to be set.

Keyworks: Server-Client Application; ESP32; Gait Analysis; MPU-9255; Data Acquisition Systems.

 

Resumen

Con el objetivo de automatizar la determinación de los parámetros de la marcha, se desarrolló un sistema capaz de adquirir datos de unidades inerciales, explotando su máxima frecuencia de muestreo. El estudio de la marcha constituye uno de los indicadores fundamentales para la evaluación del desempeño físico. Este permite la estimación del deterioro funcional del anciano de forma objetiva, por lo que se han diseñado diversas pruebas que permiten evaluarlo.. El sistema desarrollado cuenta con dos elementos fundamentales: un dispositivo electrónico y una aplicación de escritorio. El dispositivo electrónico tiene la función de recoger los datos del sensor MPU-9255 usando un ESP32 para establecer la frecuencia de muestreo, transmitir los datos por WiFi hacia la computadora y monitorizar la batería del sistema. La aplicación de escritorio permite configurar y controlar el dispositivo electrónico, así como la recepción, la visualización y el almacenamiento de los datos. Como resultado, se construyó un prototipo capaz de operar con una frecuencia de muestreo de 1 kHz. Las pruebas realizadas al sistema demuestran su confiabilidad y permiten establecer los límites de la frecuencia de muestro y la distancia de trabajo.

Palabras claves: Aplicación cliente-servidor; ESP32; Estudio de la marcha; MPU-9255; Sistema de Adquisición de Datos.

 

1. Introduction

Population ageing is currently one of the most important problems in society at large. This is a phenomenon caused in particular by the increase in life expectancy and the decline in the birth rate, which has led to significant changes in the age structure of the world's population [1].

Cuba has experienced an increase in life expectancy, with 19.8% of the population now aged 60 and over, with approximately 78 years of life expectancy. It is also among the oldest countries in the region, with indicators equivalent to those of developed countries [1].

At the same time, there is a trend towards increasing disability in the elderly population, but there is an increase in the prevalence of chronic conditions, which can lead to functional limitation, disability and dependence [2], increasing health and care costs for both the family and the health system.

With respect to the above, early assessment of signs and symptoms related to functional decline would contribute to the detection of frail elderly, who could receive therapeutic interventions, both in primary and secondary care, with the aim of minimising the occurrence of adverse outcomes [3].

Physical performance assessment allows the estimation of functional impairment in the elderly in an objective, simple, easily reproducible and also cost-effective manner. Various tests have been designed to assess physical performance, and the most commonly used parameters include gait, balance and muscle strength [4].

The traditional method of gait testing involves a person walking a known distance, counting the number of steps and measuring the elapsed time with a stopwatch [5]. In these experiments it is assumed that the step lengths are equal, which is not correct, and the time measurement is subject to errors associated with the operation of the stopwatch.

In Cuba, there is a precedent for the study of physical performance indicators in the elderly that has allowed for their correct characterisation and the identification of frail older adults, in order to prioritise their specialised care in the National Health System. This work consists of an evolutionary study of the performance of older adults who attend Grandparents' Circles in the Plaza de la Revolución municipality. In particular, gait, among other aspects, is measured, for which data on speed, step amplitude and cadence are recorded [6].

With the aim of automating this process, in [6] an experimental electronic device was developed to measure the physical variables necessary to determine the gait parameters of elderly people. This system consists of an Arduino Nano, MPU-6050 sensor with accelerometers and gyroscopes in the three coordinate axes, a MicroSD card reader for an offline working mode and a Bluetooth module for real-time data transmission. This system was able to store the samples in a file for later processing, obtaining a sampling frequency of 144 Hz.

The electronic device described above is used in [7] in order to determine the orientation. For this purpose, a data fusion method using conventional complementary filters is applied and a new variant of Kalman filter was proposed. The proposed algorithm showed some improvement over conventional algorithms, but obtaining the phase using only the gyroscope output signal from the angular velocity integration does not give accurate results due to the deviation that accumulates over time. This result can be improved with the inclusion of a magnetometer.

Based on [7] and with the aim of determining position, in [8] an algorithm is developed using a windowing method for position estimation by detecting stability periods in a walking process. The final result in the application of the algorithm is translated as the stride length. The different experiments performed were obtained with a certain degree of effectiveness, indicating the need for sensors, such as the magnetometer, for better accuracy. It was shown that it is necessary to increase the number of samples per window to improve the effectiveness of the algorithm, this implies that the sampling frequency must be increased which is not possible using the existing hardware.

This work aims to develop an electronic device capable of operating with IMUs (Inertial Measurement Units) containing magnetometer at the maximum sampling rate.

 

2. Design requirements and system structure

The following aspects were taken into account when designing the system:

·         Electronic device capable of reliably sampling at a maximum frequency of 1 kHz, in order to exploit the sensor bandwidth to the maximum and to achieve higher accuracy in the determination of gait parameters.

·         Real-time data transmission and display.

·         Simple interface design, capable of setting the system's working frequency and controlling the data acquisition process.

·         Portable and lightweight electronic device.

The system will have two fundamental elements: an electronic device for sample acquisition and a desktop application for system control, storage, visualisation and processing of the data obtained. Both parts will communicate via WiFi without the need to use a separate module because the microcontroller used has an internal adapter.

 

3. Electronic device

An electronic device was developed, which is able to acquire signals from an IMU which can be stored for further processing. If the device is used in gait testing, with these signals it is possible to obtain different parameters such as: step length, number of steps and cadence, among others.

Figure 1 shows the design of this system, which is mainly composed of an ESP32 microcontroller [9], [10], an MPU-9255 sensor [11], [12], a voltage regulator and a battery.

Figure 1. Design of the electronic device.

 

In this design, the ESP32 will be in charge of establishing the sampling frequency of the sensor signals and their transmission via WiFi to the computer. The battery will allow portability, while the regulator will allow monitoring to determine its charge. A button with two functionalities will be used: when not transmitting, when pressed, the LEDs will show the battery status, and when transmitting, it will be used to stop the process and wait for new instructions.

 

3.1. Software on the microcontroller

The acquisition system has three main tasks: acquiring data from the sensors, measuring the battery level and transmitting this data to the PC.  Figure 2 shows the flowchart of the implemented algorithm.

To meet these specifications, the system starts by initialising the sensor, the WiFi adapter and will connect to the socket created on the PC by sending the battery level that powers the system. The program will be waiting for the command from the PC to start taking data. The received frame will contain some "header" bytes and the information about the sampling frequency to be set for sample acquisition; if this is zero, it will indicate that the sampling process has been stopped by the control system and sampling will stop until another non-zero sampling frequency (fs) value is received. When a non-zero fs value is received, a timer is set and activated, which, each time it interrupts, will take a sample and form the frame to be transmitted.

The MPU-9250.h library, developed by the programming community to facilitate the work with the sensor, was used to acquire the samples. The process starts by configuring the sensor, i.e. the range of the accelerometer, gyroscope and magnetometer. A study of the range effect of the accelerometer and gyroscope in measurements of this type using an MPU-6050 (includes accelerometer and three-axis gyroscope) was performed in [13] and it was determined that for these scenarios it is necessary for the sensors to work at full scale; for this reason, these sensors were configured in this way.

While the interruption caused by the timer allows the samples to be taken, the main flow of the program will wait for a block of 250 samples. When the block of samples is built, the header will be set and sent to the PC. The sending of samples per block is done in order to save battery power as the WiFi adapter has a high consumption.

 

Figure 2. Algorithm implemented in the electronic device.

 

4. Desktop application

The desktop application was developed in Python and has 3 main windows (see Figure 3):

·         Main window: where the graphs of the acceleration, gyroscope and magnetometer values (3 axes), as well as the temperature are displayed. In addition, it has the buttons to control the system and to display the configuration menu and the registration menu.

·         Registration window: allows new users to enter the system. Data such as identity card (ID), name, surname and gender are registered. In case a user is already registered, an alert will be displayed to indicate this.

·         Configuration window: here the user who is going to run the tests is selected and the values of the sampling frequency and the number of IMUs to be used are set. In case the user is not registered, an alert will appear indicating that he/she has to register before starting the tests.

 

Figure 3. Desktop application interface.

 

The main window is in charge of controlling the system in a general way by giving instructions to the ESP32 and displaying the graphs of the samples taken, which, at the end of the process, will be saved in a file.

The flow of the application is handled by two threads: a main thread in charge of maintaining the visual interface and controlling the events that are executed on it; and a secondary thread, using the Threading module (Python module that allows the concurrent execution of code), to carry out the other functions, such as graphing, updating the battery level on the screen, detecting the disconnection of the ESP32, etc. Figure 4 shows the algorithm of the desktop application.

When running the application, an access point will be created for the connection to the ESP32, and then a socket is created on the IP address of the gateway of the access point, which will run in the background of the application and will always be waiting for data from the electronic device controlled by the ESP32.

As the network is of the point-to-multipoint type, i.e., the access point created to connect the ESP32 can be accessed by other devices, and taking into account the problem of identity theft caused by the PC where the application is running being connected to the internet, a Symmetric Key authentication protocol was implemented [14].

If the battery does not exceed 5%, it will not be possible to start the process and an alert will indicate that the current battery must be charged or replaced by another one. This action is performed to guarantee the correct functioning of the electronic device and to ensure the reliability of the data. If all conditions are in place to start the sampling process, i.e. the ESP32 is connected, its battery level is sufficient and the system has been configured, the process can be started; a frame with the selected sampling rate is sent and data reception and display is enabled.

Once the data collection is completed, the Stop button must be pressed and if the test was successful, the data is stored in a file.

 

Figure 4. Algorithm of the desktop application.

 

5. Results and discussion

The proposed system was tested in two different scenarios: indoors in a house and outdoors in an open space. In each of the tests, the system was pushed a bit further than necessary in order to leave a margin for future needs when upgrading some of its functionalities or adding some new ones.

The tests performed checked two fundamental aspects: finding the limit of the reliable distance for future measurements and determining the maximum frequency of operation that guarantees the reliability of the data. In general, two types of tests were designed: transmitting a known value to check the performance of the system and transmitting real data taken by the sensor.

 

5.1. Sampling frequency analysis

The first test performed was to check the work at the sampling frequency of 1 kHz. First, the magnetometer data were validated. For this, one of the magnetometer's axes was oriented towards magnetic north and data collection was started. Then, the sensor was moved in known directions. To validate the accelerometer and gyroscope data, the sensor was placed in the rest position and movements in known directions were started, but this time, varying the acceleration of the movement to check the state of the gyroscope. The results were as expected. Figure 5 shows the graphs of the tests performed.

 

Figure 5. System response operating at a sampling frequency of 1 kHz.

 

To determine the maximum sampling frequency at which the system is reliable, the movement described in Figure 6 was performed. First, the system was started at a frequency of 1 kHz to determine the system response to this movement, and then the frequency was increased until the graph began to distort. As a result, the maximum sampling frequency at which the system operated satisfactorily was found to be 1.5 kHz. Figure 7 shows the results of tests performed at 1 kHz and 2 kHz, which show the distortion of the graphs obtained when the higher sampling frequency is applied.

 

Figure 6. Movement made to determine the maximum sampling frequency.

 

Figure 7. Tests performed at sampling frequencies of: a) 1 kHz and b) 2 kHz.

 

5.2. Working distance limit

A second test was performed to check the maximum distance at which the electronic device and the PC can be located in such a way that the communication between the two points is reliable.

The working distance was determined in two different scenarios: indoors and outdoors. For the indoor test, the electronic device was placed at various positions in the house and at each position, data transmission and graphical behaviour was started. For this test, a function was added to the software to determine the amount of data received and thus verify the amount of packets lost. At each position, 3 tests were performed, while the data transmission was carried out in 10-second intervals.

Table 1 shows the results of this test, i.e. the number of packets lost at each of the positions.

 

Table 1. Indoor test results.

Position

Distance [m]

Number of lost packets

Test 1

Test 2

Test 3

1

7.5

0

0

0

2

5.25

0

0

0

3

7

463

4876

0

4

10

10000

10000

10000

 

According to Table 1, in positions 1 and 2, the system functioned correctly as no samples were lost in the tests. In the case of position 4, the connection could not be established even though the system was moved around the room. In fact, a scan was carried out with a mobile phone, which also failed to find the access point created by the computer. In the case of position 3, the results showed high variability as the system was apparently at the limit of coverage; already in test 3 all transmitted packets were received.

For the outdoor test, the dynamics were different. The computer was placed at the entrance of a building and the system was configured to sample at 1 kHz. The desktop application was configured in such a way that once it detected that no data was being received, it would stop the process and display an alert that the connection had been lost. In the first scenario, there were not many obstacles between the PC and the electronic device. In the second scenario, there was no direct visibility due to the presence of bushes. In the third scenario, there was direct visibility between the electronic device and the PC. Table 2 shows the distance ranges obtained in each of the scenarios.

 

Table 2. Outdoor test results.

Scenario

Distance range [m]

1

33 – 35

2

23 – 24

3

49 – 52

6. Conclusions

In this work, a system capable of acquiring, visualising and storing inertial sensor data by exploiting its bandwidth to the maximum was developed. The system consists of an electronic device and a desktop application.

The electronic device takes data at a configured sampling rate from the desktop application and sends it to the PC. The desktop application is responsible for displaying the data on the screen and storing it in files for later use. The data is stored in a structured way to form a database on which data analysis and computational learning algorithms can be applied.

An authentication mechanism was added to the system to ensure the security of the system and to ensure that the desktop application only receives data from the ESP32.

The tests carried out on the system show its correct functioning and allowed the working limits to be established in terms of sampling frequency and distance. In this way, it was determined that it is possible to operate the system with a sampling frequency of 1 kHz, thus fulfilling the objectives set for this work.

 

7. Acknowledgements.

Esta investigación ha recibido financiamiento de la OGFPI, referencia PN305LH13-050.

 

References

[1]     “ENCUESTA NACIONAL DE ENVEJECIMIENTO DE LA POBLACIÓN ENE-2017,” Oficina Nacional de Estadística e Información, Sitio en Actualización. [Online]. Available: http://www.onei.gob.cu/node/14725. [Accessed: 19-Feb-2020].

[2]     J. E. Morley, “Frailty and Sarcopenia: The New Geriatric Giants,” Rev. Investig. Clin. Organo Hosp. Enfermedades Nutr., vol. 68, no. 2, pp. 59–67, Apr. 2016.

[3]     D. García Agustín, S. Morejón, C. de Dios, and Z. Rodríguez Pérez, “Las pruebas de desempeño físico en el pronóstico de desenlaces adversos en los ancianos,” MEDISAN, vol. 22, no. 6, pp. 466–470, Jun. 2018.

[4]     J. M. Guralnik, L. Ferrucci, E. M. Simonsick, M. E. Salive, and R. B. Wallace, “Lower-extremity function in persons over the age of 70 years as a predictor of subsequent disability,” N. Engl. J. Med., vol. 332, no. 9, pp. 556–561, Mar. 1995.

[5]     G. Rosas, “Velocidad de la marcha en ancianos de la comunidad de la ciudad de Pasto,” ResearchGate, 2015.

[6]     J. Méndez, “Sistema electrónico experimental para la medición de variables físicas necesarias en la determinación de parámetros de marcha en ancianos,”RECyT, vol 33, p. 108, 2020.

[7]     G. Arencibia, “Evaluación de métodos de estimación de orientación, basados en filtro complementario y filtro de Kalman, usando unidades de medición inercial,” Universidad Tecnológica de La Habana “José Antonio Echeverría”, CUJAE, La Habana, Cuba, 2019.

[8]     A. Perez, “Estimación de la posición mediante la detección de periodos de estabilidad durante la marcha humana,” Maestría, Universidad Tecnológica de La Habana “José Antonio Echeverría”, CUJAE, La Habana, Cuba, 2020.

[9]     Espressif Systems, “ESP32 Datasheet.” 2019.

[10]   Espressif Systems, “ESP32 Technical Reference Manual.” 2019.

[11]   InvenSense, “MPU-9255 Product Specification.” 14-Sep-2014.

[12]   InvenSense, “MPU-9255 Register Map.” 10-Oct-2014.

[13]   M. Potter, L. Ojeda, N. Perkins, and S. Cain, “Effect of IMU Design on IMU-Derived Stride Metrics for Running,” MDPI, vol. 19, p. 19, 2019.

[14]   Omar G, Abood, and S. K. Guirguis, “A Survey on Cryptography Algorithms,” Int. J. Sci. Res. Publ., 2018.