Algorithm 1. Pseudo code for turning start and end detection. |
01: #Data Access 02: for each IMU attachment #head(HD), Neck(C7), L5, Ankles(LA,RA) 03: store calibrated ω, a, m 04: end for 05: #Data Filtering: Noise & Drift Removal 06: Access ω 07: Compensation Algorithm: for HD, C7, L5 08: Access ω, a, m 09: Kalman Filtering (KF) Algorithm: for Ankles (LA,RA) 10: #Every possible body segment rotation around VT 11: Access VT of ω 12: Zero-Crossing: for HD, C7, L5, Ankles 13: #Orientation Estimation 14: Integration ω VT to get Yaw: for HD, C7, L5 15: Sensor fusion with KF to Euler to Yaw: for Ankles 16: #Final Turn Detection and Estimation for HD, C7, L5 17: Yaw angle (ᴪ) extraction based on zero-crossing 18: for every ᴪ 19: #Gradual Turns Combination 20: if ᴪ > 10° and for next consecutive turns if intra turn 21: duration < 0.5 s and ᴪ > 10° and same Direction 22: Combine these gradual turns 23: end 24: #Turns from HD & C7 25: if turn angle (θ) ≥ 30° and 0.5 s ≤ turn duration < 10 s 26: Save turn start and end 27: Save final gradual turn magnitude vector 28: end 29: #Turns from L5 30: if turn angle (θ) ≥ 90° and 0.5 s ≤ turn duration < 10 s 31: Save turn start and end 32: Save final gradual turn magnitude vector 33: end 34: end for 35: #Turn Transition and Estimation from Ankles (LA, RA) 36: for every turn from L5 37: Access the turn start and turn end from L5 38: Access the turn direction from L5 39: #Inner and outer turn detection to overcome direction biases 40: if L5 direction is right 41: Inner turn = RA 42: Outer turn = LA 43: else (L5 direction is left) 44: Outer turn = RA 45: Inner turn = LA 46: end 47: end for 48: #Final turn transition from Ankles 49: for angles from Inner and Outer turn 50: if inner turn angle ≥ 30° 51: save the turn start and turn end 52: save the turn magnitude vector 53: end 54: if outer turn angle ≥ 30° 55: save the turn start and turn end 56: save the turn magnitude vector 57: end 58: end for #Turning features extraction based on turn start and end time |