# Development of a Low-Cost Open-Source Measurement System for Joint Angle Estimation

^{*}

^{†}

## Abstract

**:**

## 1. Introduction

## 2. Materials and Methods

**Notation**

**1.**

#### 2.1. JAMA

#### 2.1.1. Data Acquisition

#### 2.1.2. Data Transmission

- Build JAMA and check connections;
- Compile and upload firmware to each JAMA device (set IP, SSID and password);
- Activate the hotspot and check if all variables were correctly determined;
- Turn on JAMA devices, check the Wi-Fi connection, and place it in the joint;
- Run Python script to check connections and data streaming and recording;
- Run Python script to perform the data acquisition.

#### 2.2. PyJama

#### 2.2.1. Data Handle

#### 2.2.2. Data Processing

Algorithm 1 Complementary Filter |

#### 2.2.3. Pattern Extraction

#### 2.2.4. Data Visualization

#### 2.2.5. Data Analysis

Algorithm 2 Kalman Filter |

Algorithm 3 Madgwick Filter |

#### 2.3. Experiments

#### 2.3.1. Experiment 1

Algorithm 4 Pattern Extraction |

#### 2.3.2. Experiment 2

#### 2.3.3. Experiment 3

## 3. Results

#### 3.1. Experiment 1

#### 3.2. Experiment 2

#### 3.3. Experiment 3

## 4. Discussion

#### 4.1. JAMA

#### 4.2. PyJama

#### 4.3. Experiment 1

#### 4.4. Experiment 2

#### 4.5. Experiment 3

#### 4.6. Limitations and Perspectives

## 5. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## Appendix A

Algorithm A1 Descendant Gradient |

Algorithm A2 Gauss-Newton |

## References

- Van der Straaten, R.; Wesseling, M.; Jonkers, I.; Vanwanseele, B.; Bruijnes, A.K.; Malcorps, J.; Bellemans, J.; Truijen, J.; De Baets, L.; Timmermans, A. Functional movement assessment by means of inertial sensor technology to discriminate between movement behaviour of healthy controls and persons with knee osteoarthritis. J. Neuroeng. Rehabil.
**2020**, 17, 1–12. [Google Scholar] [CrossRef] - Lebleu, J.; Gosseye, T.; Detrembleur, C.; Mahaudens, P.; Cartiaux, O.; Penta, M. Lower Limb Kinematics Using Inertial Sensors during Locomotion: Accuracy and Reproducibility of Joint Angle Calculations with Different Sensor-to-Segment Calibrations. Sensors
**2020**, 20, 715. [Google Scholar] [CrossRef] [Green Version] - Seel, T.; Raisch, J.; Schauer, T. IMU-based joint angle measurement for gait analysis. Sensors
**2014**, 14, 6891–6909. [Google Scholar] [CrossRef] [Green Version] - Mahony, R.; Hamel, T.; Pflimlin, J.M. Nonlinear complementary filters on the special orthogonal group. IEEE Trans. Autom. Control
**2008**, 53, 1203–1218. [Google Scholar] [CrossRef] [Green Version] - Madgwick, S. An Efficient Orientation Filter for Inertial and Inertial/Magnetic Sensor Arrays. 2010. Available online: https://www.x-io.co.uk/res/doc/madgwick_internal_report.pdf (accessed on 12 May 2020).
- Comotti, D. Orientation estimation based on gauss-newton method and implementation of a quaternion complementary filter. Univ. Bergamo Tech. Rep.
**2011**, 8, 1–8. [Google Scholar] - Weygers, I.; Kok, M.; Konings, M.; Hallez, H.; De Vroey, H.; Claeys, K. Inertial sensor-based lower limb joint kinematics: A methodological systematic review. Sensors
**2020**, 20, 673. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Patel, J.; Soni, B. Design and implementation of I2C bus controller using Verilog. J. Inf. Knowl. Res. Electron. Commun. Eng.
**2012**, 2, 520–522. [Google Scholar] - Strongman, C.; Morrison, A. A scoping review of non-linear analysis approaches measuring variability in gait due to lower body injury or dysfunction. Hum. Mov. Sci.
**2020**, 69, 102562. [Google Scholar] [CrossRef] [PubMed] - Trumble, M.; Gilbert, A.; Malleson, C.; Hilton, A.; Collomosse, J. Total Capture: 3D Human Pose Estimation Fusing Video and Inertial Sensors. In Proceedings of the 2017 British Machine Vision Conference (BMVC), London, UK, 4 September 2017. [Google Scholar]
- Zhang, Z.Q.; Yang, G.Z. Micromagnetometer calibration for accurate orientation estimation. IEEE Trans. Biomed. Eng.
**2014**, 62, 553–560. [Google Scholar] [CrossRef] - Toso, M.; Pennestrì, E.; Rossi, V. ESA multibody simulator for spacecrafts’ ascent and landing in a microgravity environment. CEAS Space J.
**2015**, 7, 335–346. [Google Scholar] [CrossRef] [Green Version] - Yean, S.; Lee, B.S.; Yeo, C.K.; Vun, C.H.; Oh, H.L. Smartphone orientation estimation algorithm combining kalman filter with gradient descent. IEEE J. Biomed. Health Inform.
**2017**, 22, 1421–1433. [Google Scholar] [CrossRef] [PubMed] - Comotti, D.; Ermidoro, M. Sviluppo di Algoritmi per la Stima Dell’orientamento di un Sensore Inerziale. Univ. Bergamo Tech. Rep.
**2011**, 58. [Google Scholar] - Colton, S. The Balance Filter: A Simple Solution for Integrating Accelerometer and Gyroscope Measurements for a Balancing Platform. Chief Delphi White Paper. 2007. Available online: https://d1.amobbs.com/bbs_upload782111/files_44/ourdev_665531S2JZG6.pdf (accessed on 22 July 2020).
- Kim, P. Kalman Filter for Beginners: With MATLAB Examples; CreateSpace: Scotts Valley, CA, USA, 2011. [Google Scholar]
- Bishop, G.; Welch, G. An introduction to the kalman filter. Proc. SIGGRAPH Course
**2006**, 8, 41. [Google Scholar] - Jeon, T.H.; Lee, J.K. IMU-based joint angle estimation under various walking and running conditions. J. Korean Soc. Precis. Eng.
**2018**, 35, 1199–1204. [Google Scholar] [CrossRef] - Takeda, R.; Tadano, S.; Natorigawa, A.; Todoh, M.; Yoshinari, S. Gait posture estimation using wearable acceleration and gyro sensors. J. Biomech.
**2009**, 42, 2486–2494. [Google Scholar] [CrossRef] [Green Version] - Jezernik, S.; Colombo, G.; Keller, T.; Frueh, H.; Morari, M. Robotic orthosis lokomat: A rehabilitation and research tool. Neuromodul. Technol. Neural Interface
**2003**, 6, 108–115. [Google Scholar] [CrossRef] - Puig-Diví, A.; Escalona-Marfil, C.; Padullés-Riu, J.M.; Busquets, A.; Padullés-Chando, X.; Marcos-Ruiz, D. Validity and reliability of the Kinovea program in obtaining angles and distances using coordinates in 4 perspectives. PLoS ONE
**2019**, 14, e0216448. [Google Scholar] [CrossRef] - Anwary, A.R.; Yu, H.; Vassallo, M. Gait quantification and visualization for digital healthcare. Health Policy Technol.
**2020**, 9, 204–212. [Google Scholar] [CrossRef] - Jarchi, D.; Lo, B.; Wong, C.; Ieong, E.; Nathwani, D.; Yang, G.Z. Gait analysis from a single ear-worn sensor: Reliability and clinical evaluation for orthopaedic patients. IEEE Trans. Neural Syst. Rehabil. Eng.
**2015**, 24, 882–892. [Google Scholar] [CrossRef] [Green Version] - Versteyhe, M.; De Vroey, H.; Debrouwere, F.; Hallez, H.; Claeys, K. A Novel Method to Estimate the Full Knee Joint Kinematics Using Low Cost IMU Sensors for Easy to Implement Low Cost Diagnostics. Sensors
**2020**, 20, 1683. [Google Scholar] [CrossRef] [Green Version] - Chen, Y.; Fu, C.; Leung, W.S.W.; Shi, L. Drift-free and self-aligned IMU-based human gait tracking system with augmented precision and robustness. IEEE Robot. Autom. Lett.
**2020**, 5, 4671–4678. [Google Scholar] - Caroselli, A.; Bagalà, F.; Cappello, A. Quasi-real time estimation of angular kinematics using single-axis accelerometers. Sensors
**2013**, 13, 918–937. [Google Scholar] [CrossRef] - Paulich, M.; Schepers, M.; Rudigkeit, N.; Bellusci, G. Xsens MTw Awinda: Miniature Wireless Inertial-Magnetic Motion Tracker for Highly Accurate 3D Kinematic Applications; Xsens: Enschede, The Netherlands, 2018; pp. 1–9. [Google Scholar]
- Favre, J.; Jolles, B.; Aissaoui, R.; Aminian, K. Ambulatory measurement of 3D knee joint angle. J. Biomech.
**2008**, 41, 1029–1035. [Google Scholar] [CrossRef] [PubMed] - Czech, M.D.; Patel, S. GaitPy: An open-source python package for gait analysis using an accelerometer on the lower back. J. Open Source Softw.
**2019**, 4, 1778. [Google Scholar] [CrossRef] [Green Version] - Liu, J.; Zhang, X.; Lockhart, T.E. Fall risk assessments based on postural and dynamic stability using inertial measurement unit. Saf. Health Work
**2012**, 3, 192–198. [Google Scholar] [CrossRef] - Hellmers, S.; Izadpanah, B.; Dasenbrock, L.; Diekmann, R.; Bauer, J.M.; Hein, A.; Fudickar, S. Towards an automated unsupervised mobility assessment for older people based on inertial TUG measurements. Sensors
**2018**, 18, 3310. [Google Scholar] [CrossRef] [Green Version] - Del Rosario, M.B.; Lovell, N.H.; Redmond, S.J. Quaternion-based complementary filter for attitude determination of a smartphone. IEEE Sens. J.
**2016**, 16, 6008–6017. [Google Scholar] [CrossRef] - Shamshirband, S.; Rabczuk, T.; Chau, K.W. A survey of deep learning techniques: Application in wind and solar energy resources. IEEE Access
**2019**, 7, 164650–164666. [Google Scholar] [CrossRef] - Banan, A.; Nasiri, A.; Taheri-Garavand, A. Deep learning-based appearance features extraction for automated carp species identification. Aquac. Eng.
**2020**, 89, 102053. [Google Scholar] [CrossRef] - Fan, Y.; Xu, K.; Wu, H.; Zheng, Y.; Tao, B. Spatiotemporal modeling for nonlinear distributed thermal processes based on KL decomposition, MLP and LSTM network. IEEE Access
**2020**, 8, 25111–25121. [Google Scholar] [CrossRef] - Weber, D.; Gühmann, C.; Seel, T. RIANN–A Robust Neural Network Outperforms Attitude Estimation Filters. arXiv
**2021**, arXiv:2104.07391. [Google Scholar] - Allseits, E.; Kim, K.J.; Bennett, C.; Gailey, R.; Gaunaurd, I.; Agrawal, V. A novel method for estimating knee angle using two leg-mounted gyroscopes for continuous monitoring with mobile health devices. Sensors
**2018**, 18, 2759. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Ludwig, S.A.; Burnham, K.D.; Jiménez, A.R.; Touma, P.A. Comparison of attitude and heading reference systems using foot mounted MIMU sensor data: Basic, Madgwick, and Mahony. In Sensors and Smart Structures Technologies for Civil, Mechanical, and Aerospace Systems 2018; International Society for Optics and Photonics: Bellingham, WA, USA, 2018; Volume 10598, p. 105982L. [Google Scholar]
- Fiorentino, N.M.; Atkins, P.R.; Kutschke, M.J.; Foreman, K.B.; Anderson, A.E. Soft Tissue Artifact Causes Underestimation of Hip Joint Kinematics and Kinetics in a Rigid-Body Musculoskeletal Model. J. Biomech.
**2020**, 108, 109890. [Google Scholar] [CrossRef] [PubMed] - Anwary, A.R.; Yu, H.; Vassallo, M. An automatic gait feature extraction method for identifying gait asymmetry using wearable sensors. Sensors
**2018**, 18, 676. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Yan, J.; Yuan, D.; Xing, X.; Jia, Q. Kalman filtering parameter optimization techniques based on genetic algorithm. In Proceedings of the 2008 IEEE International Conference on Automation and Logistics, Qingdao, China, 1–3 September 2008; pp. 1717–1720. [Google Scholar]
- Ludwig, S.A.; Jiménez, A.R. Optimization of gyroscope and accelerometer/magnetometer portion of basic attitude and heading reference system. In Proceedings of the 2018 IEEE International Symposium on Inertial Sensors and Systems (INERTIAL), Lake Como, Italy, 26–29 March 2018; pp. 1–4. [Google Scholar]
- Seel, T.; Schauer, T.; Raisch, J. Joint axis and position estimation from inertial measurement data by exploiting kinematic constraints. In Proceedings of the 2012 IEEE International Conference on Control Applications, Dubrovnik, Croatia, 3–5 October 2012; pp. 45–49. [Google Scholar]
- Nowka, D.; Kok, M.; Seel, T. On motions that allow for identification of hinge joint axes from kinematic constraints and 6D IMU data. In Proceedings of the 2019 18th European Control Conference (ECC), Naples, Italy, 25–28 June 2019; pp. 4325–4331. [Google Scholar]

**Figure 1.**JAMA circuit can be configured to ESP32 to connect to GY-80 via I${}^{2}$C master mode. The microcontroller uses pins 1 and 2 for power supply (the I${}^{2}$C typically supports 3.3 V or 5 V), and pins 21 and 22 connect to the bidirectional transmission lines Serial Data (SDA) and Serial Clock (SCL), respectively.

**Figure 2.**PyJama organization consists of four main classes to handle data formats, processing data, visualization, and analyze data.

**Figure 3.**Experiment 1. Figure shows Lokomat schema (sidebars removed for better viewing) and parameters used for data acquisition. Two JAMAs were positioned on the side of the robotic leg, one above and the other below the knee joint, using 75 Hz as the acquisition frequency. Camera was positioned 180 cm away on a 60 cm height tripod. Video was recorded in full HD resolution at 30 fps. Lokomat was configured for a 45${}^{\circ}$ hip and 60${}^{\circ}$ knee ROM and simulating a 1 km/h gait.

**Figure 4.**Experiment 2. Figure shows the positioning of the two JAMAs used to assess the knee joint with the parameters for data acquisition. One JAMA was positioned above and the other below the joint, using 75 Hz of acquisition frequency. Camera was positioned 180 cm away and 60 cm high on a tripod. Video was recorded in full HD resolution at 30 fps.

**Figure 5.**Data comparison between Madgwick and Kinovea. Figure shows the values of average ROM adjusted based on Min and Max, estimated based on the polynomial adjust.

**Figure 6.**Comparison between Madgwick and Kinovea processed data. Figure shows the values of average ROM adjusted based on Min and Max estimates, based on the polynomial adjust.

**Figure 7.**Data manipulation by PyJama. The figure shows the transformation of Xsens quaternion data to Euler angles, and from Euler angles back to quaternion, using quadrant constraint. The manipulation showed an RMSE of 0.00 and a MAPE of 0.00%.

**Figure 8.**Orientation estimation using the Complementary Filter with Gauss–Newton. The estimation resulted in an average RMSE of 0.04 and an average MAPE of 2.95%.

Components | Price ($) | Quantity (Unit) | Total ($) |
---|---|---|---|

ESP32 | 5.00 | 2 | 10.00 |

GY-80 | 15.00 | 2 | 30.00 |

Batteries 3.7 V | 4.00 | 4 | 8.00 |

Total | –//– | –//– | 48.00 |

Movement/Filter | ROM Max | Target ROM | Average ROM (sd) |
---|---|---|---|

Flex/Ext CF GD | 72.78${}^{\circ}$ | 60.00${}^{\circ}$ | 60.89 ± 4.81${}^{\circ}$ |

Flex/Ext CF GN | 73.58${}^{\circ}$ | 60.00${}^{\circ}$ | 61.57 ± 4.94${}^{\circ}$ |

Flex/Ext Kalman GD | 70.91${}^{\circ}$ | 60.00${}^{\circ}$ | 58.81 ± 2.90${}^{\circ}$ |

Flex/Ext Kalman GN | 69.14${}^{\circ}$ | 60.00${}^{\circ}$ | 56.81 ± 2.81${}^{\circ}$ |

Flex/Ext Madgwick | 65.92${}^{\circ}$ | 60.00${}^{\circ}$ | 58.28 ± 2.75${}^{\circ}$ |

Flex/Ext Kinovea | 61.59${}^{\circ}$ | 60.00${}^{\circ}$ | 56.25 ± 1.94${}^{\circ}$ |

Movement/Filter | CI 95% | Min/Max | Min/Max Est |

Flex/Ext CF GD | 9.43% | 0.00${}^{\circ}$/72.78${}^{\circ}$ | 6.00${}^{\circ}$/63.54${}^{\circ}$ |

Flex/Ext CF GN | 9.69% | 0.00${}^{\circ}$/73.58${}^{\circ}$ | 5.32${}^{\circ}$/63.61${}^{\circ}$ |

Flex/Ext Kalman GD | 5.68% | 0.00${}^{\circ}$/70.91${}^{\circ}$ | 7.36${}^{\circ}$/63.60${}^{\circ}$ |

Flex/Ext Kalman GN | 5.51% | 0.00${}^{\circ}$/69.14${}^{\circ}$ | 6.12${}^{\circ}$/61.71${}^{\circ}$ |

Flex/Ext Madgwick | 5.39% | 0.00${}^{\circ}$/65.92${}^{\circ}$ | 4.48${}^{\circ}$/58.58${}^{\circ}$ |

Flex/Ext Kinovea | 3.79% | 2.23${}^{\circ}$/63.82${}^{\circ}$ | 6.10${}^{\circ}$/63.38${}^{\circ}$ |

Movement/Filter | ROM Max | Target ROM | Average ROM (sd) |
---|---|---|---|

Flex/Ext Madgwick | 54.48${}^{\circ}$ | –//– | 44.62 ± 3.90${}^{\circ}$ |

Flex/Ext Kinovea | 63.06${}^{\circ}$ | –//– | 50.93 ± 5.96${}^{\circ}$ |

Movement/Filter | CI 95% | Min/Max | Min/Max Est |

Flex/Ext Madgwick | 7.64% | 0.09${}^{\circ}$/54.57${}^{\circ}$ | 4.82${}^{\circ}$/46.82${}^{\circ}$ |

Flex/Ext Kinovea | 11.67% | 3.62${}^{\circ}$/66.69${}^{\circ}$ | 9.80${}^{\circ}$/60.15${}^{\circ}$ |

Filter | MAPE q${}_{1}$ | MAPE q${}_{2}$ | MAPE q${}_{3}$ | MAPE q${}_{4}$ | Average (sd) |
---|---|---|---|---|---|

CF GD | 53.45% | 61.24% | 68.03% | 61.12% | 60.96 ± 5.96% |

CF GN | 50.12% | 56.30% | 65.18% | 56.83% | 57.11 ± 6.18% |

Kalman GD | 52.54% | 61.18% | 68.25% | 62.24% | 61.05 ± 6.47% |

Kalman GN | 51.78% | 62.13% | 68.34% | 60.08% | 60.58 ± 6.84% |

Madgwick | 51.43% | 58.97% | 65.05% | 57.91% | 58.34 ± 5.58% |

Filter | MAPE q${}_{1}$ | MAPE q${}_{2}$ | MAPE q${}_{3}$ | MAPE q${}_{4}$ | Average (sd) |

CF GD Abs | 9.20% | 9.83% | 7.53% | 7.05% | 8.40 ± 1.32% |

CF GN Abs | 3.02% | 3.03% | 3.49% | 2.27% | 2.95 ± 0.51% |

Kalman GD Abs | 9.95% | 12.35% | 9.74% | 10.63% | 10.67 ± 1.18% |

Kalman GN Abs | 9.63% | 11.62% | 9.32% | 8.84% | 9.85 ± 1.22% |

Madgwick Abs | 4.54% | 5.65% | 4.37% | 3.52% | 4.52 ± 0.88% |

Filter | RMSE q${}_{1}$ | RMSE q${}_{2}$ | RMSE q${}_{3}$ | RMSE q${}_{4}$ | Average (sd) |

CF GD | 0.69 | 0.73 | 0.80 | 0.71 | 0.73 ± 0.04 |

CF GN | 0.67 | 0.73 | 0.80 | 0.70 | 0.73 ± 0.04 |

Kalman GD | 0.66 | 0.73 | 0.80 | 0.71 | 0.73 ± 0.05 |

Kalman GN | 0.66 | 0.74 | 0.80 | 0.70 | 0.73 ± 0.05 |

Madgwick | 0.68 | 0.74 | 0.79 | 0.70 | 0.73 ± 0.04 |

Filter | RMSE q${}_{1}$ | RMSE q${}_{2}$ | RMSE q${}_{3}$ | RMSE q${}_{4}$ | Average (sd) |

CF GD Abs | 0.14 | 0.30 | 0.09 | 0.10 | 0.11 ± 0.02 |

CF GN Abs | 0.05 | 0.04 | 0.04 | 0.03 | 0.04 ± 0.01 |

Kalman GD Abs | 0.11 | 0.14 | 0.11 | 0.12 | 0.11 ± 0.01 |

Kalman GN Abs | 0.11 | 0.13 | 0.10 | 0.10 | 0.11 ± 0.01 |

Madgwick Abs | 0.05 | 0.06 | 0.05 | 0.04 | 0.05 ± 0.01 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

de Almeida, T.F.; Morya, E.; Rodrigues, A.C.; de Azevedo Dantas, A.F.O.
Development of a Low-Cost Open-Source Measurement System for Joint Angle Estimation. *Sensors* **2021**, *21*, 6477.
https://doi.org/10.3390/s21196477

**AMA Style**

de Almeida TF, Morya E, Rodrigues AC, de Azevedo Dantas AFO.
Development of a Low-Cost Open-Source Measurement System for Joint Angle Estimation. *Sensors*. 2021; 21(19):6477.
https://doi.org/10.3390/s21196477

**Chicago/Turabian Style**

de Almeida, Túlio Fernandes, Edgard Morya, Abner Cardoso Rodrigues, and André Felipe Oliveira de Azevedo Dantas.
2021. "Development of a Low-Cost Open-Source Measurement System for Joint Angle Estimation" *Sensors* 21, no. 19: 6477.
https://doi.org/10.3390/s21196477