smish.dev
inverse_aerial_control

This is a continuation of a previous post, to demonstrate how to solve the inverse problem of determining user input from trajectories.

Problem Statement

Say we know that, at a particular instant in time, a user was controlling a vehicle in the air (without being hit by another car, or air dodging). Is it possible to use information about the car's dynamic state to determine what inputs the users issued?

Let's take a look: from the previous post, we have the following update procedure for the angular velocity:

ω(t+Δt):=ω(t)+τΔt

If we knew what the beginning and end step values of ω were, then we know what τ must have been:

τ=ω(t+Δt)ω(t)Δt

furthermore, by using our expression for τ in the other post, we can say that

τ=Θ(t)(Tu+D(u)Θ(t)ω(t))

where u is the vector of user inputs (roll, pitch, yaw) that we seek. The definition of D(u) involves absolute values of components of u, making the equations nonlinear:

Trur=τrDrωrTpupDp|up|=τpDpωpTyuyDy|uy|=τyDyωywhereτ~=[τrτpτy]=Θτ,ω~=[ωrωpωy]=Θω

Thankfully, they are decoupled, so they can be solved individually:

Roll:

ur=τrDrωrTr

Pitch:

up=τpDpωpTp+sgn(τpDpωp)ωpDp

Yaw:

uy=τyDyωyTysgn(τyDyωy)ωyDy

Where sgn() is the signum function. Ideally, these values will always be in the range (-1, 1), but to get the best admissible input in weird cases, do the following as well:

ur:=urmin(1.0,1|ur|)up:=upmin(1.0,1|up|)uy:=uymin(1.0,1|uy|)

Dealing with Maximum Angular Speed

If the norm of angular velocity exceeds 5.5, Rocket League scales it back down, until it is 5.5. How does this affect our ability to guess the inputs of a trajectory?

In short, this means there will be more than one net torque τ that produces identical end-step angular velocities. As a result, there can be cases where there are infinitely many possible inputs that produce the same aerial trajectory. The procedure described above will still work, and will find the inputs that produce the torque of minimum magnitude that yields the appropriate end-step angular velocity!

Example Problem

These examples show how well the recovered user input (dashed lines) compares to the exact values (solid lines). The trace in red is the norm of the angular velocity-- note that when it hits 5.5, the inputs do not coincide. However, it is the case that the exact inputs and the recovered would still have the same effect on the car.

An example where angular velocities do not clip shows almost exact agreement:

Possible Implementation