A 3D-Printed Knee Wearable Goniometer with a Mobile-App Interface for Measuring Range of Motion and Monitoring Activities

Wearable technology has been developed in recent years to monitor biomechanical variables in less restricted environments and in a more affordable way than optical motion capture systems. This paper proposes the development of a 3D printed knee wearable goniometer that uses a Hall-effect sensor to measure the knee flexion angle, which works with a mobile app that shows the angle in real-time as well as the activity the user is performing (standing, sitting, or walking). Detection of the activity is done through an algorithm that uses the knee angle and angular speeds as inputs. The measurements of the wearable are compared with a commercial goniometer, and, with the Aktos-t system, a commercial motion capture system based on inertial sensors, at three speeds of gait (4.0 km/h, 4.5 km/h, and 5.0 km/h) in nine participants. Specifically, the four differences between maximum and minimum peaks in the gait cycle, starting with heel-strike, were compared by using the mean absolute error, which was between 2.46 and 12.49 on average. In addition, the algorithm was able to predict the three activities during online testing in one participant and detected on average 94.66% of the gait cycles performed by the participants during offline testing.


Introduction
The maneuverability of a joint within its Range of Motion (ROM) is an indicator of functional performance in the human body. This functional performance can be used for assessment in rehabilitation, identifying pathologies, etc. Passive ROM (PROM) involves when an external force moves the joint, while Active ROM (AROM) involves when the movement occurs due to contraction of the muscles. For measuring the PROM, medical professionals commonly use goniometers [1], while, during AROM, motion capture systems able to measure the functional ROM variables in real-time must be necessary. Optical motion systems involve cameras and markers; they are the gold standard for measuring kinematic variables but involve costs and time to get ready. Due to this limitation, the use of wearable technology as motion capture systems has been promoted [2][3][4][5][6], as they have the potential to measure kinematic parameters during daily activities and in less restricted environments due to their portability, allowing continuous monitoring of the joint [4,5].
Companies and academic institutions have been developing wearables for motion capture purposes. In the case of companies, Biometrics Ltd. developed flexible goniometers by using resistive transducers, and their goniometer can measure the angles of the knee, ankle, and wrist [7]. Other examples are the Aktos-t system developed by MYON [8] and the MVN Analyze system [9] of XSens (https://www.xsens.com/, accessed on 15 August 2021); these systems use Inertial Measurement Units (IMUs) and have their specialized software. In the case of academic institutions, diverse systems using potentiometers [10], IMUs [11,12], Hall-effect sensors [13], and knitted piezoresistive fabric technology [14] were developed. of the wearable need improvement. The purpose of the final design of the wearable is to be considered as an alternative to assess and monitor long-time activities in the healthcare and industrial sector as a quick, affordable, and specialized tool; and to motivate the integration of 3D-printing wearable technology and algorithms for movement analysis by using a lower quantity of sensors.

Wearable Description
The development of the wearable involved mechanical design, electronic design, and programming. As mentioned in the previous section, this wearable of this study is an improvement of a previous one developed by the authors [21]. The improvements of the current wearable compared to the older are its compacter design, the implementation of an algorithm for activity recognition, and transmission of the joint angle to an Android device.

Mechanical Design
The wearable presents one degree of freedom with two arms, one for the shank and another for the thigh as shown in Figure 1a. For the material's features, it was considered simple to manufacture, lightweight, and low-cost; therefore, the pieces were 3D-printed in ABS (Crear 4d SAC., Lima, Peru) using Ultimaker 3 Extended, although it can also be printed with PLA or other similar materials with the characteristics explained. The sensor and the electronic components are embedded inside the shank arm structure, which is composed of the cover and the base as shown in Figure 1a. The thigh arm is assembled to the shank arm by using a novel mechanism that was developed for the first design [21]. This mechanism, shown in Figure 1b, allows the wearable to be assembled and disassembled when the thigh arm and shank arm form an angle of 180 • (Figure 1c), which is not possible for human motion; therefore, the wearable will not disassemble when the user is wearing it. The rotation axis of the wearable is aligned to the one of the knee flexion/extension, and to place the wearable on the user, Velcro combined with straps and elastic bands were used for each arm, so they attach to the lower limb of the user as shown in Figure 2a with an Aktos-t system while participants walked at three different speeds wearing both systems. The wearable presents one degree of freedom and has specific dimensions; therefore, improvements are expected as the knee joint presents more than one degree of freedom [24] and personalization may be needed for specific sizes of subjects. Moreover, the objective of the comparisons performed in this study is to get an idea of which aspects of the wearable need improvement. The purpose of the final design of the wearable is to be considered as an alternative to assess and monitor long-time activities in the healthcare and industrial sector as a quick, affordable, and specialized tool; and to motivate the integration of 3D-printing wearable technology and algorithms for movement analysis by using a lower quantity of sensors.

Wearable Description
The development of the wearable involved mechanical design, electronic design, and programming. As mentioned in the previous section, this wearable of this study is an improvement of a previous one developed by the authors [21]. The improvements of the current wearable compared to the older are its compacter design, the implementation of an algorithm for activity recognition, and transmission of the joint angle to an Android device.

Mechanical Design
The wearable presents one degree of freedom with two arms, one for the shank and another for the thigh as shown in Figure 1a. For the material's features, it was considered simple to manufacture, lightweight, and low-cost; therefore, the pieces were 3D-printed in ABS (Crear 4d SAC., Lima, Peru) using Ultimaker 3 Extended, although it can also be printed with PLA or other similar materials with the characteristics explained. The sensor and the electronic components are embedded inside the shank arm structure, which is composed of the cover and the base as shown in Figure 1a. The thigh arm is assembled to the shank arm by using a novel mechanism that was developed for the first design [21]. This mechanism, shown in Figure 1b, allows the wearable to be assembled and disassembled when the thigh arm and shank arm form an angle of 180° (Figure 1c), which is not possible for human motion; therefore, the wearable will not disassemble when the user is wearing it. The rotation axis of the wearable is aligned to the one of the knee flexion/extension, and to place the wearable on the user, Velcro combined with straps and elastic bands were used for each arm, so they attach to the lower limb of the user as shown in Figure 2a (a) CAD model of the knee wearable; (b) mechanical attachment pattern: 1-shank arm pattern, 2-thigh arm pattern; (c) assembly process of the wearable goniometer: (1,2) the base and the thigh arm are connected in the specific position (3,4) and the thigh arm is rotated 180° to allow the placement of the cover.  (3,4) and the thigh arm is rotated 180 • to allow the placement of the cover.

Electronic Design
The magnetic rotatory encoder AS5048B (AMS AG) was used for joint angle measurements. The data are read and processed by the microcontroller Atmega328 (Atmel) and sent via Bluetooth communication with a frequency of 100 Hz to an Android device or a personal computer. This frequency was considered because it is enough for kinematic variables during gait analysis as it allows an appreciation of how the variables change during one gait cycle. The microcontroller and the Bluetooth are integrated into the commercial electronic board Beetle Bee, which was developed by DFROBOT. The system is energized by a Lithium-Ion Polymer (LiPo) 3.7 V 1200 mAh battery, whose voltage is amplified and regulated to 5 V through the Powerboost 1000 C (Adafruit Industries), which also allows the recharging of the battery. To avoid the use of cables, the components were integrated into an electronic board made of fiberglass. Figure 3 shows the interaction of the elements; it can be appreciated that the angular speed is calculated from the angle to predict the user's activity, and this variable is obtained from the knee angle and the sample time.
The magnetic rotatory encoder AS5048B (AMS AG) was used for joint angle measurements. The data are read and processed by the microcontroller Atmega328 (Atmel) and sent via Bluetooth communication with a frequency of 100 Hz to an Android device or a personal computer. This frequency was considered because it is enough for kinematic variables during gait analysis as it allows an appreciation of how the variables change during one gait cycle. The microcontroller and the Bluetooth are integrated into the commercial electronic board Beetle Bee, which was developed by DFROBOT. The system is energized by a Lithium-Ion Polymer (LiPo) 3.7 V 1200 mAh battery, whose voltage is amplified and regulated to 5 V through the Powerboost 1000 C (Adafruit Industries), which also allows the recharging of the battery. To avoid the use of cables, the components were integrated into an electronic board made of fiberglass. Figure 3 shows the interaction of the elements; it can be appreciated that the angular speed is calculated from the angle to predict the user's activity, and this variable is obtained from the knee angle and the sample time.   The magnetic rotatory encoder AS5048B (AMS AG) was used for joint angle measurements. The data are read and processed by the microcontroller Atmega328 (Atmel) and sent via Bluetooth communication with a frequency of 100 Hz to an Android device or a personal computer. This frequency was considered because it is enough for kinematic variables during gait analysis as it allows an appreciation of how the variables change during one gait cycle. The microcontroller and the Bluetooth are integrated into the commercial electronic board Beetle Bee, which was developed by DFROBOT. The system is energized by a Lithium-Ion Polymer (LiPo) 3.7 V 1200 mAh battery, whose voltage is amplified and regulated to 5 V through the Powerboost 1000 C (Adafruit Industries), which also allows the recharging of the battery. To avoid the use of cables, the components were integrated into an electronic board made of fiberglass. Figure 3 shows the interaction of the elements; it can be appreciated that the angular speed is calculated from the angle to predict the user's activity, and this variable is obtained from the knee angle and the sample time.

Mobile Application Interface
An application in Android OS was developed through Android Studio to display the knee angle and activity name in real time. This app allows the setup of the knee which will be measured (left or right) and zero position (knee fully extended). Once these parameters are configured, the app shows the angle and the activity in real time. The configuration can be reset at any moment.

Algorithm for Activity Detection
The algorithm for activity detection (standing, sitting, and walking) is based in a finite state machine that uses the angular position (θ n ) and angular speed (ω n ) of the knee joint. The angular position is obtained by applying a median filter to the eight last angles provided by the sensor, and the angular speed is obtained by dividing the difference of two consecutive filtered positions (θ n −θ n−1 ) by the sample time ∆t = 10 ms.
The finite state machine consists of five states (S 0 , S 1 , S 2 , S 3 , S 4 ), which each of them representing a pattern and situation. These states were used to differentiate between standing, sitting, and walking. The system is initially on the state S 0 , which means that the user is not doing an activity that involves movement; during the sequence of states S 1 , S 2 , S 3 and S 4 , the user is doing the activity of walking.
The detection of standing and sitting activity occurs only during the state S 0 . During this state, the angles provided during the last second (100 samples) are compared with the angles 20 • and 70 • . If the angles are less than 20 • , the user is standing; on the other hand, if the angle is more than 70 • , the user is sitting. The angular speed was not considered for the detection of these activities.
For the sequence of states S 1 , S 2 , S 3 , and S 4 , the maximum and minimum peaks of knee flexion angle during the gait cycle were analyzed. The change of the knee angle during one cycle of walking activity presents four concavities, two concaves up and two concaves down, which represent the peaks of extension and flexion, respectively. The values during these situations can be considered as local maximum for concave down, or local minimum for concave up. Therefore, the local maximum (θ max ), and local minimum (θ min ) in one cycle were analyzed for the detection of the activity and transition of states. To obtain those values, the system evaluates the sign of the angular speed (ω n ) and compares the current angular position (θ n ) with the two previous values (θ n−1 , θ n−2 ). For instance, to find θ max , the sign of ω n should be positive, and θ n should be increasing (θ n > θ n−1 ); once it stops increasing (θ n+1 < θ n ), the final value of θ n is assigned to θ max . Similarly, to find θ min , ω n should be negative and θ n should be decreasing (θ n < θ n−1 ), and the value of θ n is assigned to θ min when θ n+1 > θ n . Figure 4 shows the results of the algorithm applied to a set of data. It can be appreciated that the values of θ max (blue dashed line) and θ min (red dashed line) do not change until another local maximum/minimum is detected.

Algorithm for Activity Detection
The algorithm for activity detection (standing, sitting, and walking) is based nite state machine that uses the angular position (θn) and angular speed (ωn) of th joint. The angular position is obtained by applying a median filter to the eight las provided by the sensor, and the angular speed is obtained by dividing the differ two consecutive filtered positions (θn−θn−1) by the sample time Δt = 10 ms.
The finite state machine consists of five states (S0, S1, S2, S3, S4), which each o representing a pattern and situation. These states were used to differentiate b standing, sitting, and walking. The system is initially on the state S0, which means user is not doing an activity that involves movement; during the sequence of state S3 and S4, the user is doing the activity of walking.
The detection of standing and sitting activity occurs only during the state S0. this state, the angles provided during the last second (100 samples) are compared w angles 20° and 70°. If the angles are less than 20°, the user is standing; on the othe if the angle is more than 70°, the user is sitting. The angular speed was not conside the detection of these activities.
For the sequence of states S1, S2, S3, and S4, the maximum and minimum peaks flexion angle during the gait cycle were analyzed. The change of the knee angle one cycle of walking activity presents four concavities, two concaves up and two co down, which represent the peaks of extension and flexion, respectively. The values these situations can be considered as local maximum for concave down, or local mi for concave up. Therefore, the local maximum (θmax), and local minimum (θmin) cycle were analyzed for the detection of the activity and transition of states. To those values, the system evaluates the sign of the angular speed (ωn) and compa current angular position (θn) with the two previous values (θn−1, θn−2). For instance θmax, the sign of ωn should be positive, and θn should be increasing (θn > θn−1); once increasing (θn+1 < θn), the final value of θn is assigned to θmax. Similarly, to find should be negative and θn should be decreasing (θn < θn−1), and the value of θn is a to θmin when θn+1 > θn. Figure 4 shows the results of the algorithm applied to a set It can be appreciated that the values of θmax (blue dashed line) and θmin (red dash do not change until another local maximum/minimum is detected.  The initiation of movement involves the transition from S 0 to S 1 , which is evaluated through θ max , θ min , and ω n . Firstly, it is compared if ω n is higher than 120 • /s. Then, it is evaluated if θ max has changed while θ min is kept constant. The ranges in which θ max and θ min are compared are [ are satisfied, the state changes to S 1 . This logic is represented by "Conditions for S1" in Figure 5b.

Figure 5b.
For detection of the walking activity, the changes of θmax and θmin are evaluated during the sequence of states S1, S2, S3, and S4. The sequence of angles is defined as θ1, θ2, θ3 and θ4, which should stay in the range of [30°, 70°], [−5°, 15°], [0°, 30°], and [−10°,15°], respectively, in order to complete a cycle of walking. These values were set after observing the data obtained from the wearable. The angles θ1 and θ3 are maximum angles (peak in flexion), while θ2 and θ4 are minimum angles (peak in extension). Figure 5a shows how the states change during the activity of walking, and the transition from one state to another occurs when there is a change in the value of θmax or θmin depending on the state.
(a) (b) Figure 5. (a) States and maximum/minimum angles during the activity of walking; (b) sequence of states S0, S1, S2, S3, and S4 with their respective condition for change, the detection of the walking activity occurs when a transition from S4 to S1 occurs.
As observed in Figure 5b, the sequence of states is evaluated by specific conditions, and, if one of the conditions is not satisfied, the wrong angle changed or the angle is not in the range, the system returns to the state S0. In addition, if the system stays in one state of movement (S1, S2, S3, or S4) for more than 2 s, it is returned to the state S0. The detection of one gait cycle is done by the transition from S4 to S1.

Participants
For the testing of AROM, nine healthy participants (7 males, 2 females, 67.39 ± 10.83 kg, 163.44 ± 5.85 cm) used the wearable. They were asked if they did not present any gait disorder; however, no clinical test to confirm any pathology that could affect gait was taken. The participants were considered due to their different heights and weights, as it could give an idea of how the error changed during AROM, and how the algorithm could detect the activity of walking with the current design of the wearable.

Comparison with a Commercial Goniometer
A commercial goniometer was placed parallel to the wearable as shown in Figure 6a. Double contact tape was used to keep both goniometers aligned, allowing the goniometer and wearable to move together. The information of the wearable, which is shown on the Android device, is compared to the measurement of the goniometer. For this test, the information of the wearable was sent to the Android device, so it was not stored. For detection of the walking activity, the changes of θ max and θ min are evaluated during the sequence of states S 1 , S 2 , S 3 , and S 4 . The sequence of angles is defined as θ 1 , θ 2 , θ 3 and θ 4 , which should stay in the range of [ respectively, in order to complete a cycle of walking. These values were set after observing the data obtained from the wearable. The angles θ 1 and θ 3 are maximum angles (peak in flexion), while θ 2 and θ 4 are minimum angles (peak in extension). Figure 5a shows how the states change during the activity of walking, and the transition from one state to another occurs when there is a change in the value of θ max or θ min depending on the state.
As observed in Figure 5b, the sequence of states is evaluated by specific conditions, and, if one of the conditions is not satisfied, the wrong angle changed or the angle is not in the range, the system returns to the state S 0 . In addition, if the system stays in one state of movement (S 1 , S 2 , S 3 , or S 4 ) for more than 2 s, it is returned to the state S 0 . The detection of one gait cycle is done by the transition from S 4 to S 1 .

Participants
For the testing of AROM, nine healthy participants (7 males, 2 females, 67.39 ± 10.83 kg, 163.44 ± 5.85 cm) used the wearable. They were asked if they did not present any gait disorder; however, no clinical test to confirm any pathology that could affect gait was taken. The participants were considered due to their different heights and weights, as it could give an idea of how the error changed during AROM, and how the algorithm could detect the activity of walking with the current design of the wearable.

Comparison with a Commercial Goniometer
A commercial goniometer was placed parallel to the wearable as shown in Figure 6a. Double contact tape was used to keep both goniometers aligned, allowing the goniometer and wearable to move together. The information of the wearable, which is shown on the Android device, is compared to the measurement of the goniometer. For this test, the information of the wearable was sent to the Android device, so it was not stored. toelectronic motion capture system (Vicon Motion Systems, Oxford, UK) and compared the root mean squared error (RMSE), in which they found that the accuracy of measuring the knee was between acceptable (RMSE < 5°) and tolerable (RMSE < 10°).
The sampling frequency of the Aktos-t system was 200 Hz. To avoid sliding of the wearable in the users, they were asked to wear short or thigh pants depending on their preference. To compare the AROM measurements from the wearable and the Aktos-t system, the differences between the peaks of knee flexion and extension obtained by both systems were compared. This approach was used to avoid the effect of different systems of references used during the measurements in each system. During the gait cycle, there are two peaks of flexion: foot-flat and mid-swing, and two peaks of extension: heel-raise and heelstrike, which gives a total of four differences for one cycle. The four differences will be tagged as A1, A2, A3, and A4, and they are calculated as the absolute difference of two peaks that are next to each other. In that sense, A1 will be the absolute difference between heel-strike and foot-flat, A2 the absolute difference between foot-flat and heel-raise, A3 the absolute difference between heel-raise and mid-swing, and A4 the difference between mid-swing and heel-strike of the next cycle. An illustration of the four peaks of the gait cycle and how the differences are calculated is shown in Figure 7.

Testing of AROM Measurement
The participants were asked to wear the wearable while walking in a treadmill at 4 km/h, 4.5 km/h, and 5 km/h for 20 s. All participants performed the gait activity without the need of any assistive device. The data were transmitted to a computer via serial communication at 100 Hz and read and stored through a program developed on Matlab (MathWorks, Inc., Natick, MA, USA). The data of the wearable were compared to the data provided by an Aktos-t IMU system (Myon AG), in which one IMU was placed in the thigh and another in the shank of the subjects as shown in Figure 6b. This Aktos-t system has been tested for gait analysis by Bessone et al. [25]; they compared it with a Vicon optoelectronic motion capture system (Vicon Motion Systems, Oxford, UK) and compared the root mean squared error (RMSE), in which they found that the accuracy of measuring the knee was between acceptable (RMSE < 5 • ) and tolerable (RMSE < 10 • ).
The sampling frequency of the Aktos-t system was 200 Hz. To avoid sliding of the wearable in the users, they were asked to wear short or thigh pants depending on their preference.
To compare the AROM measurements from the wearable and the Aktos-t system, the differences between the peaks of knee flexion and extension obtained by both systems were compared. This approach was used to avoid the effect of different systems of references used during the measurements in each system. During the gait cycle, there are two peaks of flexion: foot-flat and mid-swing, and two peaks of extension: heel-raise and heel-strike, which gives a total of four differences for one cycle. The four differences will be tagged as A1, A2, A3, and A4, and they are calculated as the absolute difference of two peaks that are next to each other. In that sense, A1 will be the absolute difference between heel-strike and foot-flat, A2 the absolute difference between foot-flat and heel-raise, A3 the absolute difference between heel-raise and mid-swing, and A4 the difference between mid-swing and heel-strike of the next cycle. An illustration of the four peaks of the gait cycle and how the differences are calculated is shown in Figure 7.
For each user, Mean Absolute Error (MAE) for each difference during the first six gait cycles was calculated. Therefore, a total of four MAE for one user walking at a specific speed was obtained. Then, for each difference and speed, the average of all the user's MAE was calculated to get an estimation of the error of the wearable. In addition, to observe the variability for the error, the Mean Absolute Deviation (MAD) was calculated for each user in different speeds, similarly to the logic used for the MAE. For each user, Mean Absolute Error (MAE) for each difference during th cycles was calculated. Therefore, a total of four MAE for one user walking speed was obtained. Then, for each difference and speed, the average of all th was calculated to get an estimation of the error of the wearable. In additio the variability for the error, the Mean Absolute Deviation (MAD) was calcu user in different speeds, similarly to the logic used for the MAE.

Online Testing
To test the algorithm in real-time or online, one person (male, 54.9 kg, formed the activities of standing, sitting, and walking. The activity performe was shown in the Android device.

Offline Testing
Detection of the activity of walking was tested in the data acquired d comparison. During the procedure, it was found that the offset in some use correctly, as the knee angles were around 100°-360° when it should be ze the first angle of the analyzed data was set up, which represents heel-strike, t ing the rest of each participant curve to the new system of reference. Sim AROM test, the algorithm was only tested in the first six gait cycles.
To evaluate how well the algorithm detected the activity of walking, was obtained by dividing the number of detected gait cycles by the total passed through the algorithm. It is important to mention that a gait cycle each time a transition from S4 to S1 occurred.

Online Testing
To test the algorithm in real-time or online, one person (male, 54.9 kg, 1.63 cm) performed the activities of standing, sitting, and walking. The activity performed by the user was shown in the Android device.

Offline Testing
Detection of the activity of walking was tested in the data acquired during AROM comparison. During the procedure, it was found that the offset in some users was set incorrectly, as the knee angles were around 100 • -360 • when it should be zero. Therefore, the first angle of the analyzed data was set up, which represents heel-strike, to zero, adapting the rest of each participant curve to the new system of reference. Similarly, to the AROM test, the algorithm was only tested in the first six gait cycles.
To evaluate how well the algorithm detected the activity of walking, the efficiency was obtained by dividing the number of detected gait cycles by the total of cycles that passed through the algorithm. It is important to mention that a gait cycle was detected each time a transition from S4 to S1 occurred.

Comparison with a Commercial Goniometer
Four measurements (0 • , 30 • , 60 • and 90 • ) were taken from the wearable and the goniometer. Both values were similar with a precision of 1 • , which is the one presented by the commercial goniometer. Figure 8 shows the comparison for the four angles, and the value of the wearable is shown in the Android app. and standard deviations of the MAE for different walking speeds.
MAE shows that the error of the wearable varies for different subjects. For instance, subjects 1, 4, 5, and 8, as shown in Table 2, presented an error lower than 10°, while the rest of the subjects presented errors around 10°-20°, specifically for the A4. In addition, the MAD shows that there is variability in the error less than 2° as observed in Table 2. Details about the MAE and MAD of each subject at different speeds can be observed in Tables A1 and A2, respectively, both located in Appendix A.   Figure 8. Results of the comparison between wearable and commercial goniometer.

AROM Measurement
The variation between the wearable and the Aktos-t IMUs was higher when comparing the angle between mid-swing and heel-strike (A 4 ). The minor difference was observed when comparing the angle between foot-flat and heel rise (A 2 ). Table 1 shows the averages and standard deviations of the MAE for different walking speeds.  Table 2, presented an error lower than 10 • , while the rest of the subjects presented errors around 10 • -20 • , specifically for the A 4 . In addition, the MAD shows that there is variability in the error less than 2 • as observed in Table 2. Details about the MAE and MAD of each subject at different speeds can be observed in Tables A1 and A2, respectively, both located in Appendix A.   Figure 9 shows the detection of standing, sitting, and walking in real time. During the tests, the activity "walking" was commonly detected after the user performed the third step, which means it may be necessary to perform adjustments to reduce the communication time between the wearable and the Android device. However, once this activity was detected, it was shown on the Android device until the person stopped walking.  Figure 9 shows the detection of standing, sitting, and walking in real time. During the tests, the activity "walking" was commonly detected after the user performed the third step, which means it may be necessary to perform adjustments to reduce the communication time between the wearable and the Android device. However, once this activity was detected, it was shown on the Android device until the person stopped walking.

Offline Testing
The algorithm for walking was tested in the data obtained for the comparison of AROM. As observed in Table 3, the algorithm detected most of the cycles with an accuracy of 94%, 96%, and 94% for the speeds of 4.0 km/h, 4.5 km/h, and 5 km/h, respectively.

Offline Testing
The algorithm for walking was tested in the data obtained for the comparison of AROM. As observed in Table 3, the algorithm detected most of the cycles with an accuracy of 94%, 96%, and 94% for the speeds of 4.0 km/h, 4.5 km/h, and 5 km/h, respectively.

Discussion
A novel wearable made of 3D printing material was developed for measuring the knee AROM and detecting activities. This wearable attaches to different sizes of the lower limbs of the user through a novel textile made of Velcro straps and elastic bands. A user interface was implemented, which allows the observation of the angle and the activity in real time.
During the comparison between the wearable and the commercial goniometer, there was no difference in the measurements between both devices. Therefore, the wearable can measure similar values that a commercial goniometer has. In addition, during the comparisons, the values of the wearable ended with 0.00 • , suggesting that the device can provide an accuracy of two decimals. During the comparison of AROM, the greatest and smaller errors occurred during the comparisons of A 4 and A 2 , respectively, which may suggest that the error increases with the movement of the angle. One possible cause might be the misalignment between the wearable and the knee joint, which may occur due to the translation, sliding, and rotation of the femur during the movement of flexion. For instance, the literature suggests that the knee presents two centers of rotation located in the femur [24]: Extension Facet Center (EFC) and Flexion Facet Center (FFC), which changes depending on the knee flexion angle. For instance, previous studies have demonstrated that the FFC moves around 30 mm on the lateral side and 10 mm on the medial side during flexion [26], which suggests that the knee rotates around a vertical axis located in the medial side during the movement of flexion [24]. Moreover, it was found that, during the activity of walking, this vertical axis is located in the lateral side, suggesting that the rotation of the knee may change depending on the performed activity [27]. These findings suggest that a more specialized mechanism may be necessary to adapt to the movement of the knee flexion axis during the activity of walking that may be considered for future designs of the wearable.
Moreover, the order of the errors from smaller to greatest is A 2 -A 3 -A 1 -A 4 , which shows that, even though A 3 is greater than A 1 , it presented a smaller error. This suggests that the error does not only depend on the amplitude of the ROM but other factors. One factor why the error is greater in A 1 and A 4 may be the impact during heel-strike, which occurs between the phases in which both values are taken (see Figure 7). Previous literature has stated that the legs absorb most of the vibrations during heel-strike [28]; in addition, part of the vibrations are absorbed by the meniscus of the knee [29]. Therefore, it is possible that these vibrations misaligned the wearable and increased the error of the angle. Furthermore, this vibration might have increased as the subjects were not wearing shoes during the trials, and previous research has found that the loading rate of the ground reaction forces increased when the participants were not wearing shoes [30]. This suggests that future designs should consider mechanisms for the compensation of vibrations and opens the possibility to study the effect of vibrations in the system.
The error varied between different participants even though a design of straps and elastic bands was considered to adapt the connection of the wearable to a different radius of thigh and shank. Therefore, it may also be necessary to adapt the design of the structure for different sizes of participants, in a way that it adapts to the geometry of their leg or anthropometric measurements. It is also important to point out that, during the design, the wearable was continuously tested in a male ectomorph subject whose characteristics were 54.9 kg and 1.63 cm; therefore, it may be possible that the wearable measures better in subjects with similar size.
The error presented variability smaller than 2 • , as observed in the MAD. This variability may be related to the displacement of the offset during trials, which may occur due to sensor drift (Aktos-t IMUs and wearable Hall effect sensor) or the misalignment of the wearable during each step of the trial. However, as the time of the trial is short, it is possible that the main reason of displacement is misalignment.
The activity of walking was detected, during online and offline tests, by using the proposed finite state machine algorithm. The algorithm used a large range of angles in the conditionals because the reliability of the device still needs to be assessed, a test that will be performed once the design of the wearable is improved to avoid misalignments during its use. However, the results show that the use of finite state machine algorithms to detect the activity of walking is an adequate alternative. Once the design is validated, this algorithm can be integrated with machine learning techniques to personalize the range of angles for each subject. Moreover, detection of sitting and standing was tested in just one person. Nevertheless, as their logic of detection in the algorithm just involved the comparison of angular values in a specific range; expectations are that the algorithm could detect both activities correctly in more subjects once the device presents validated reliability.
There are limitations of this study that should be acknowledged. Firstly, one design of the wearable in all participants was used, and even though the straps were designed to adapt for different sizes, it may also be necessary to take into consideration the size of the structure. This consideration should be taken in conjunction with a mechanism that could adapt to the movement of the knee flexion axis during gait. In addition, although it was checked that all participants walked without problems, it may also be necessary to take clinical tests to make sure that they did not present any disease or condition that may have affected their gait during the tests. Furthermore, the comparison was done with an Aktos-t IMU system, which, according to literature [25], presents an RMSE less than 5 • and 10 • measuring lower limbs activity when compared to a Vicon Motion Capture System. Future development of the wearable is expected to save data through the Android device or the wearable controller, which would allow storage of data from daily activities without the need of being connected to a computer, giving more portability. In addition, the use of this data could allow evaluation of the evolution of treatment in patients, statistical studies which involve gait analysis in different groups, improve capacities of functional ROM through training, or evaluation of functional ROM in workers during labor activities.

Conclusions
This wearable did not present differences in its measurements during comparison to a commercial goniometer. The values in AROM presented differences compared to the values provided by the Aktos-t IMU system, and it may be necessary to consider the tibiofemoral movement and the sliding [24,26] to improve the design. Moreover, it was possible to develop an algorithm that could detect three activities (sitting, standing, and walking) by only considering the knee flexion angle and angular speed. The range of maximum/minimum values used in the algorithm was large, as the reliability of measurements still needs to be assessed. Furthermore, the technical specifications of the device serve as an illustration to develop 3D-printing wearable technology for motion assessment. Finally, this wearable serves as the first concept of one final design that does not intend to replace optical motion capture systems, but to be used as a quick assessment tool for health practitioners or researchers to provide an initial quantifiable measurement of knee flexion angle for possible diagnosis of pathologies, or monitoring gait patterns during rehabilitation, for example, in patients with knee injuries such as meniscal tears, fractures, and ligament injuries, especially in a context where the time of consultation, cost, or space is limited.  Informed Consent Statement: Informed consent was obtained from all subjects involved in the study.

Data Availability Statement:
The data presented in this study are available on request from the corresponding author.

Acknowledgments:
We would like to thank Blanca Perez for her help in the electronic design of the wearable. We would also like to thank to the members of the Laboratory of Biomechanics and Applied Robotics of the Pontificia Universidad Católica del Perú for their support in the study.

Conflicts of Interest:
The authors declare no conflict of interest.