The soonest contact
function estimates the time a specific player needs to get to the freely moving ball (i.e., when the robot can cross the ball trajectory).
It takes into consideration the ball state (position and velocity), and a robot state (position and max speed).
If the robot cannot get to the ball before it hits the wall, the function can be configured to take into consideration the ball bounces and calculate intersection time after the ball bounced.
Assumptions: The ball is moving with uniform linear motion until it bounces from the field side
Inputs: Robot state, Ball state, Field size
Output: The earliest time when the robot can intersect with the ball trajectory.
- Ball trajectory is defined as a time parametric function (straight line:
x(t) and y(t)
). - Robot possible position is defined as a time parametric function (circle:
radios = max_speed * t
,x(t)
andy(t)
) - The mentioned equations are solved to find the tangent of ball trajectory (line) to robot possible position (circle)
- If the time solution is negative or complex:
- Find trajectory after the ball bounce
- Go back to point 3
The visualisations of time solutions (before the first bounce) are presented in Figure 1 and Figure 2, both with different initial ball velocities.
Figure 1: Time solutions (colour) for robots in different initial position (x and y field position) for ball moving with constant velocity (vx > 0, vy = 0) (reduced to solutions found before first bounce).
Figure 2: Time solutions (colour) for robots in different initial position (x and y field position) for ball moving with constant velocity (vx > 0, vy < 0) (reduced to solutions found before first bounce).