@@ -664,43 +664,65 @@ fn am_better_striker(
664664 field_dimensions : & FieldDimensions ,
665665 role_assignments_speeds : & RoleAssignmentsSpeeds ,
666666) -> bool {
667+ println ! ( "starting calculation" ) ;
667668 let relative_ball = current_pose. inverse ( ) * origin_pose * spl_message_ball_position. relative_position ;
668669 // Distance calculation
669670 let our_distance = relative_ball. coords . norm ( ) ;
670671 let other_distance = spl_message_ball_position. relative_position . coords . norm ( ) ;
672+ println ! ( "{our_distance} our distance to the ball" ) ;
673+ println ! ( "{other_distance} other distance to the ball" ) ;
671674 // Angle calculation
672675 let ball_to_us = Vector2 :: new ( relative_ball. x , relative_ball. y ) ;
673676 let ball_to_other = Vector2 :: new ( spl_message_ball_position. relative_position . x , spl_message_ball_position. relative_position . y ) ;
674677 let forward = Vector2 :: x ( ) ;
675678 let our_first_angle = forward. angle ( & ball_to_us) ;
676679 let other_first_angle = forward. angle ( & ball_to_other) ;
677680
681+ println ! ( "{our_first_angle} our angle to the ball-us line" ) ;
682+ println ! ( "{other_first_angle} other angle to the ball-other line" ) ;
683+
678684 let opponent_goal_center_us = current_pose. inverse ( ) * Vector2 :: new ( field_dimensions. length / 2.0 , 0.0 ) ;
679685 let opponent_goal_center_other = origin_pose. inverse ( ) * Vector2 :: new ( field_dimensions. length / 2.0 , 0.0 ) ;
680686
687+ // println!("{opponent_goal_center_us.norm()} our distance to the goal");
688+ // println!("{opponent_goal_center_other.norm()} other distance to the goal");
689+
681690 let ball_to_goal_us = opponent_goal_center_us - ball_to_us;
682691 let ball_to_goal_other = opponent_goal_center_other - ball_to_other;
683692
693+ // println!("{ball_to_goal_us.norm()} our percieved distance ball and goal");
694+ // println!("{ball_to_goal_other.norm()} other percieved distance ball and goal");
695+
684696 let our_ball_to_our_goal = ball_to_us. angle ( & opponent_goal_center_us) ;
685697 let other_ball_to_other_goal = ball_to_other. angle ( & opponent_goal_center_other) ;
686698
699+ println ! ( "{our_ball_to_our_goal} our shortest angle between the ball-us line and the us-goal line" ) ;
700+ println ! ( "{other_ball_to_other_goal} other shortest angle between the ball-us line and the other-goal line" ) ;
701+
687702 let mut our_second_angle: f32 = ball_to_us. angle ( & ball_to_goal_us) ;
688703 if our_ball_to_our_goal > 0.5 * PI {
689- our_second_angle -= PI ;
704+ println ! ( "changing our second angle to be -180 degrees" ) ;
705+ our_second_angle = PI - our_second_angle;
690706 }
691707
692708 let mut other_second_angle = ball_to_other. angle ( & ball_to_goal_other) ;
693709 if other_ball_to_other_goal > 0.5 * PI {
694- other_second_angle -= PI ;
710+ println ! ( "changing other second angle to be -180 degrees" ) ;
711+ other_second_angle = PI - other_second_angle;
695712 }
696713
714+ println ! ( "{our_second_angle} our shortest angle between the ball-us line and the ball-goal line" ) ;
715+ println ! ( "{other_second_angle} other shortest angle between the ball-us line and the ball-goal line" ) ;
716+
697717 // Creating the overall score
698718 // m/s: 0.175
699719 // 2pi turn (first, around own axis): 8 sec.
700720 // 2pi turn (second, around ball): 12 sec (estimate).
701721 // 1 turn equals 1.4 meters
702722 let our_estimated_time: f32 = ( our_first_angle / ( 2.0 * PI ) ) * role_assignments_speeds. rotation_axis_time + ( our_second_angle / ( 2.0 * PI ) ) * role_assignments_speeds. rotation_ball_time + our_distance * role_assignments_speeds. walking_speed ;
703723 let other_estimated_time: f32 = ( other_first_angle / ( 2.0 * PI ) ) * role_assignments_speeds. rotation_axis_time + ( other_second_angle / ( 2.0 * PI ) ) * role_assignments_speeds. rotation_ball_time + other_distance * role_assignments_speeds. walking_speed ;
724+ println ! ( "{our_estimated_time} our estimated time" ) ;
725+ println ! ( "{other_estimated_time} our estimated time" ) ;
704726 return our_estimated_time < other_estimated_time;
705727
706728}
0 commit comments