@@ -215,16 +215,29 @@ fn is_free_kick_pose(
215
215
) -> Option < GlobalFieldSide > {
216
216
let left_shoulder_to_hand =
217
217
keypoints. left_shoulder . point . coords ( ) - keypoints. left_hand . point . coords ( ) ;
218
+ let left_shoulder_to_feet =
219
+ keypoints. left_shoulder . point . coords ( ) - keypoints. left_foot . point . coords ( ) ;
220
+ let left_arm_rotation =
221
+ Rotation2 :: rotation_between ( left_shoulder_to_hand, left_shoulder_to_feet) ;
222
+
218
223
let right_shoulder_to_hand =
219
224
keypoints. right_shoulder . point . coords ( ) - keypoints. right_hand . point . coords ( ) ;
225
+ let right_shoulder_to_feet =
226
+ keypoints. right_shoulder . point . coords ( ) - keypoints. right_foot . point . coords ( ) ;
227
+ let right_arm_rotation =
228
+ Rotation2 :: rotation_between ( right_shoulder_to_hand, right_shoulder_to_feet) ;
229
+
220
230
let arm_rotation_difference =
221
- Rotation2 :: rotation_between ( left_shoulder_to_hand, right_shoulder_to_hand) . angle ( ) ;
222
- if free_kick_signal_angle_range. contains ( & arm_rotation_difference. abs ( ) ) {
223
- if arm_rotation_difference. is_sign_positive ( ) {
224
- Some ( GlobalFieldSide :: Away )
225
- } else {
226
- Some ( GlobalFieldSide :: Home )
227
- }
231
+ Rotation2 :: rotation_between ( left_shoulder_to_hand, right_shoulder_to_hand) ;
232
+ let is_free_kick_pose =
233
+ free_kick_signal_angle_range. contains ( & arm_rotation_difference. angle ( ) . abs ( ) ) ;
234
+ if is_free_kick_pose && free_kick_signal_angle_range. contains ( & left_arm_rotation. angle ( ) . abs ( ) )
235
+ {
236
+ Some ( GlobalFieldSide :: Away )
237
+ } else if is_free_kick_pose
238
+ && free_kick_signal_angle_range. contains ( & right_arm_rotation. angle ( ) . abs ( ) )
239
+ {
240
+ Some ( GlobalFieldSide :: Home )
228
241
} else {
229
242
None
230
243
}
0 commit comments