Skip to content

dew.rl.quadrotor

A racing quadrotor’s physics in JAX, one drone at a time (vmap for a batch), every parameter drawn per episode for transfer from simulation.

The drone is a five-inch FPV racer lifting about 12 times its weight, as Flightmare’s and L2F’s racer does (uzh-rpg/flightmare flightlib/configs/quadrotor_env.yaml and rl_tools rl/environments/l2f/parameters/dynamics/ flightmare.h: 0.73 kg on arms of 0.17 m, its thrust map lifting 21.7 N a rotor at its top speed, 12.1 times its weight), a rigid body under four rotors as Kaufmann, Bauersfeld and Scaramuzza model one (ICRA 2022, arXiv 2202.10796, Eq 1-3): its mass Flightmare’s 0.73 kg; its inertia Kaufmann’s measured 5-inch racer’s (Table II, diag(2.5, 2.1, 4.3) g m^2 at 0.768 kg) at this mass, diag(2.38, 2.0, 4.09) g m^2; each rotor’s thrust c_l w^2 with Kaufmann’s c_l = 1.563e-6 N s^2 (Flightmare’s quadratic term 1.33e-6, SkyDreamer’s 1.55e-6) and its yaw torque c_d w^2 with c_d = 1.909e-8 N m s^2; its rotors in an X, their order and spins L2F’s (front right, rear right, rear left, front left; yaw torques -, +, -, +; rl/environments/l2f/multirotor.h). Its top speed, 3700 rad/s, is the speed at which those rotors lift 11.95 times its weight; the randomization (mass, coefficients, top speed, and the battery’s charge at the start) spans 8.4 to 13.3.

Each rotor’s speed follows its steady speed through a first-order lag (NeuroBEM 33 ms, Agilicious 39.1 ms, Ferede et al. arXiv 2504.21586 40 ms); its steady speed is its ESC duty times its top speed times the battery’s voltage over its full charge’s (Swift’s Methods Eq 6 makes the steady speed a function of voltage and command; a DC motor’s speed is proportional to its voltage). The battery is cells LiPo cells: each cell’s open-circuit voltage falls from its charge at the start as the pack discharges, and its internal resistance sags it under the motors’ current (Bauersfeld and Scaramuzza, RA-L 2022, Eq 10-16: a resistance of at least 4.5 mOhm a cell), the current the rotors’ shaft power, sum c_d w^3, over efficiency (an assumption: no source states a 5-inch drive’s).

The flight controller is Betaflight’s in form (L2F’s rate controller, rl/environments/l2f/operations_generic.h 132-190), run every physics step: a PD loop on the body rates to angular accelerations, times the nominal inertia, then a mixer to each rotor’s thrust with the commanded collective, then each rotor’s duty from the nominal thrust map. Its gains, 100 per second and 2 (the derivative on the measured rate’s change over a physics step of 1/240 s), give a 90% rise in 54 to 62 ms with at most 8% overshoot over the motor lags drawn (a step response computed for this choice; no source publishes a racer’s gains in these units).

The air resists the body: rotor drag along the body’s x and y, proportional to the rotors’ summed speed and the body’s velocity (Ferede et al. Eq 2; SkyDreamer, arXiv 2510.14783, Sec II-D, k = 5.37e-5 N s / m rad), a quadratic drag along x and y (SkyDreamer Table II: 4.10e-3 and 1.51e-2 N s^2 / m^2), and a linear drag along z (Kaufmann Table II: 0.15 N s / m). Near the ground the rotors lift more (Cheeseman and Bennett: by 1 / (1 - s (R / 4z)^2), its strength s from 0.75, Garofano-Soldado et al. 2022’s measured, to 1, for 5-inch rotors of R = 63.5 mm). Each episode adds a constant force and moment (SkyDreamer Table III: up to 2 m/s^2 and 2 rad/s^2), and every control step’s duties are noised (SkyDreamer’s 0.2 of the normalized command).

Every drawn quantity scales its spread about nominal by ramp, from 0 (the nominal drone, no disturbance) to 1, a curriculum. The world frame is x forward, y left, z up; the body frame forward, left, up.

NameSummary
ARMA rotor’s offset along x and y from the centre, metres: Flightmare’s 0.17 m arm in an X.
GRAVITYThe acceleration of gravity, m/s^2.
POSITIONSThe rotors’ x and y in the body frame: front right, rear right, rear left, front left (L2F’s order).
SPINSEach rotor’s yaw torque’s sign per unit of its drag torque (L2F’s).
BodyOne drone’s drawn parameters for an episode (Quadrotor’s, each its own), its battery’s charge at the start and resistance, and its constant disturbance: the force (N, world frame) and moment (N m, body frame).
FlightOne drone’s state: position and velocity (world frame, m and m/s), orientation the body-to-world rotation as a unit quaternion (w, x, y, z), angular_velocity the body rates (rad/s), each rotor’s speed (rad/s), the charge drawn from the battery (Ah), the cell’s voltage under the last load (V), and the body rates the flight controller last measured, a physics step before.
QuadrotorThe nominal racer and each parameter’s randomization (a drawn value is nominal times a factor uniform within 1 +- spread, or uniform in its range, each spread times the ramp): its mass (kg), inertia diagonal (kg m^2), rotor thrust and drag coefficients thrust_coefficient and drag_coefficient, top_speed and idle_speed (rad/s), motor_lag range (s), rotor drag rotor_drag (N s / m rad), quadratic drag quadratic_drag along body x and y (N s^2 / m^2), linear drag vertical_drag along body z (N s / m), ground effect’s ground_effect strength range and rotor rotor_radius (m); the battery’s cells, each cell’s charge at the start charged (V) and full full_voltage, discharge (V over the pack’s charge), resistance range (Ohm a cell), capacity (Ah) and the drive’s efficiency; the constant bias_force (m/s^2) and bias_moment (rad/s^2) at most, duty_noise at most; the rate controller’s rate_gain (1/s) and rate_damping; and the physics’ substeps a control step.
drawn_bodyA drone’s parameters for an episode (Body), each spread about nominal by ramp’s share of its randomization.
dutiesThe flight controller’s ESC duties [4] in [0, 1] for a collective thrust (N) and body rates (rad/s), and the rates it measured: the rate loop’s angular accelerations times the nominal inertia, mixed with the collective into each rotor’s thrust, each turned into a duty by the nominal thrust map at full charge.
flownA drone’s state after a control step of 1 / hz seconds under a collective thrust (N) and body rates (rad/s), and its path [substeps + 1, 3] (its positions before the step and after each physics step).
hoveringA drone at rest at position and orientation, its rotors at the speed that holds its weight, its battery as charged.
rotationThe body-to-world rotation matrix [3, 3] of a unit quaternion (w, x, y, z).

attribute source

ARM = 0.17 * 0.5 ** 0.5

A rotor’s offset along x and y from the centre, metres: Flightmare’s 0.17 m arm in an X.

attribute source

GRAVITY = 9.81

The acceleration of gravity, m/s^2.

attribute source

POSITIONS = ((ARM, -ARM), (-ARM, -ARM), (-ARM, ARM), (ARM, ARM))

The rotors’ x and y in the body frame: front right, rear right, rear left, front left (L2F’s order).

attribute source

SPINS = (-1.0, 1.0, -1.0, 1.0)

Each rotor’s yaw torque’s sign per unit of its drag torque (L2F’s).

dataclass source

class Body()

One drone’s drawn parameters for an episode (Quadrotor’s, each its own), its battery’s charge at the start and resistance, and its constant disturbance: the force (N, world frame) and moment (N m, body frame).

def thrust_to_weight(quadrotor: Quadrotor) -> jax.Array

Its full thrust over its weight at its charge at the start.

dataclass source

class Flight()

One drone’s state: position and velocity (world frame, m and m/s), orientation the body-to-world rotation as a unit quaternion (w, x, y, z), angular_velocity the body rates (rad/s), each rotor’s speed (rad/s), the charge drawn from the battery (Ah), the cell’s voltage under the last load (V), and the body rates the flight controller last measured, a physics step before.

dataclass source

class Quadrotor(
mass: float = 0.73,
mass_spread: float = 0.04,
inertia: tuple[float, float, float] = (0.00238, 0.002, 0.00409),
inertia_spread: float = 0.3,
thrust_coefficient: float = 1.563e-06,
drag_coefficient: float = 1.909e-08,
coefficient_spread: float = 0.02,
top_speed: float = 3700.0,
top_spread: float = 0.02,
idle_speed: float = 150.0,
motor_lag: tuple[float, float] = (0.02, 0.06),
rotor_drag: float = 5.37e-05,
quadratic_drag: tuple[float, float] = (0.0041, 0.0151),
vertical_drag: float = 0.15,
drag_spread: float = 0.3,
ground_effect: tuple[float, float] = (0.75, 1.0),
rotor_radius: float = 0.0635,
cells: int = 4,
charged: tuple[float, float] = (3.7, 4.2),
full_voltage: float = 4.2,
discharge: float = 0.6,
resistance: tuple[float, float] = (0.003, 0.012),
capacity: float = 1.5,
efficiency: float = 0.75,
bias_force: float = 2.0,
bias_moment: float = 2.0,
duty_noise: float = 0.2,
rate_gain: float = 100.0,
rate_damping: float = 2.0,
substeps: int = 4,
)

The nominal racer and each parameter’s randomization (a drawn value is nominal times a factor uniform within 1 +- spread, or uniform in its range, each spread times the ramp): its mass (kg), inertia diagonal (kg m^2), rotor thrust and drag coefficients thrust_coefficient and drag_coefficient, top_speed and idle_speed (rad/s), motor_lag range (s), rotor drag rotor_drag (N s / m rad), quadratic drag quadratic_drag along body x and y (N s^2 / m^2), linear drag vertical_drag along body z (N s / m), ground effect’s ground_effect strength range and rotor rotor_radius (m); the battery’s cells, each cell’s charge at the start charged (V) and full full_voltage, discharge (V over the pack’s charge), resistance range (Ohm a cell), capacity (Ah) and the drive’s efficiency; the constant bias_force (m/s^2) and bias_moment (rad/s^2) at most, duty_noise at most; the rate controller’s rate_gain (1/s) and rate_damping; and the physics’ substeps a control step.

nominal_thrust: float

The nominal drone’s full thrust at full charge, N.

function source

def drawn_body(quadrotor: Quadrotor, key: jax.Array, ramp: jax.Array) -> Body

A drone’s parameters for an episode (Body), each spread about nominal by ramp’s share of its randomization.

function source

def duties(
quadrotor: Quadrotor,
flight: Flight,
collective: jax.Array,
rates: jax.Array,
dt: float,
) -> tuple[jax.Array, jax.Array]

The flight controller’s ESC duties [4] in [0, 1] for a collective thrust (N) and body rates (rad/s), and the rates it measured: the rate loop’s angular accelerations times the nominal inertia, mixed with the collective into each rotor’s thrust, each turned into a duty by the nominal thrust map at full charge.

function source

def flown(
quadrotor: Quadrotor,
body: Body,
flight: Flight,
collective: jax.Array,
rates: jax.Array,
key: jax.Array,
hz: float,
ramp: jax.Array,
) -> tuple[Flight, jax.Array]

A drone’s state after a control step of 1 / hz seconds under a collective thrust (N) and body rates (rad/s), and its path [substeps + 1, 3] (its positions before the step and after each physics step). Each physics step the flight controller sets the duties (duties, Betaflight’s loop runs far faster than a policy), noised by ramp’s share of duty_noise drawn once a control step; the rotors move toward their steady speeds, the body flies by semi-implicit Euler and the battery drains.

function source

def hovering(
quadrotor: Quadrotor,
body: Body,
position: jax.Array,
orientation: jax.Array,
) -> Flight

A drone at rest at position and orientation, its rotors at the speed that holds its weight, its battery as charged.

function source

def rotation(orientation: jax.Array) -> jax.Array

The body-to-world rotation matrix [3, 3] of a unit quaternion (w, x, y, z).