One of the most useful and impressive maneuvers in Rocket League is the aerial hit, where a car changes its orientation and feathers the boost in such a way that it intercepts the ball. Although it takes most people a while to develop intuition about how to aerial successfully, we will see that it is a very simple mechanic to implement for a bot. In particular, the following description will allow us to quantitatively determine:
if the car can aerial to a certain point in a given amount of time
how much boost it would take to reach that point
how to control the car to carry out the aerial maneuver
Let
For simplicity, we will assume that the car has already left the ground, so that we can focus our attention on just the dynamics of aerials.
The car's motion is described by an ordinary differential equation that includes contributions due to boost and gravity, and initial conditions:
where
Because the original differential equation is separable, we can directly integrate twice to get
Now, we demand that the intersection condition is satisfied:
Rearrange terms to group all the things we can control on the left side, and everything else on the right:
Although this expression is very general, it isn't immediately obvious how to use it to determine our controls. What if we assumed that the car did the following:
take some amount of time,
keep facing that direction, and boost with some constant acceleration for
More rigorously:
If we put these expressions into the double integral above and simplify, we get:
Dividing through by some constants gives us the working equation:
Upon closer inspection, we see that each side of the working equation above has the dimension of acceleration. This means that we can interpret the right-hand side as the acceleration needed to arrive at target
This means that
How can we tell if
is reachable by this maneuver?
Check if
How much boost will I need to complete this maneuver?
If we know the average acceleration,
How do I feather boost to produce the right average acceleration?
Keep a running counter for the boost, and do something like this:
xxxxxxxxxx
class Aerial:
def __init__(self):
self.boost_counter = 0.0
self.B_max = 1000.0
...
def get_output():
...
# compute A, B_0
A = ...
B_0 = norm(A)
use_boost = 0
# set the boost in such a way that its duty cycle
# approximates the desired average boost ratio
use_boost -= round(self.boost_counter)
self.boost_counter += B_0 / self.B_max
use_boost += round(self.boost_counter)
self.controls.boost = 1 if use_boost else 0
...
How do I make my car turn to the correct direction,
?
See: https://github.com/samuelpmish/RLUtilities/blob/develop/src/mechanics/reorient.cc
How do I freestyle with my bot?
To make contact with the ball, you only need to face the front of the car in the correct direction, meaning you can keep rolling as much as you want once the front direction is aligned.
Additionally, you can boost more than the average acceleration to make the necessary course correction in less time. Once the necessary acceleration is close to zero, your car is already on a "collision course", so you can stop boosting and just spin around in any direction you want.
To hit an aerial, use the working equation below to find the acceleration magnitude and direction required to make contact.
where