Skip to content
LumenaryAcademy
Systems 70 min

Aerial robots

Four propellers, no wings, and an unstable machine that a computer keeps upright hundreds of times a second. Thrust and motor mixing, cascaded flight control, attitude estimation, flight stacks, navigation with and without GNSS, fixed wings and VTOL, and flying within the law.

Code tested · 5AI-draftedAwaiting review by a roboticist

Your guides: Chloe · The Builder, Margaret · The Experimenter, Gideon · The Safety Engineer

MotivationH

A machine that is always falling

Flying robots have quietly become ordinary. Since 2016 Zipline's fixed-wing drones have delivered blood and medicines to hospitals in Rwanda, and later in Ghana and other countries; spraying drones from companies such as DJI and XAG treat fields across China and Southeast Asia; surveyors map quarries and building sites from the air; inspectors fly along power lines, wind turbines and bridges instead of climbing them. In April 2021 NASA's Ingenuity helicopter made the first powered, controlled flight on another planet, and went on to fly 72 times on Mars.

A quadrotor is mechanically almost trivial: four motors, four propellers, a battery and a small computer. Everything difficult is in the software. With its motors at constant speed it does not hover; it tips over within a fraction of a second. It is underactuated (four motors, six degrees of freedom), so it cannot move sideways without first tilting; it carries perhaps twenty minutes of energy; and it must estimate which way is up from sensors that vibrate with the motors.

This lesson builds a quadrotor from the propellers up: how four thrusts become a force and three torques, how a cascade of controllers turns "go there" into motor commands, how the flight controller knows its attitude, and how real autopilots, navigation and regulation fit around them. It uses the rotations of Rotations and quaternions, the PID loops of Feedback and PID and the filters of Kalman filters.

DefinitionsH

Thrust, torque and motor mixing

A spinning propeller pushes air down and is pushed up. Over a quadrotor's working range, its thrust and the drag torque that resists its rotation both grow with the square of its angular speed ωi\omega_i:

fi=kf ωi2,qi=km ωi2.f_i = k_f\,\omega_i^2, \qquad q_i = k_m\,\omega_i^2 .

The constants depend on the propeller's size and pitch and on air density, and are measured on a thrust stand. The four thrusts all point along the body's zz axis, so they add up to one total thrust TT. Because they act at different places, they also twist the body: more thrust on the left than the right rolls it, more at the back than the front pitches it nose down. Yaw is subtler. Each motor's drag torque twists the body the opposite way to its propeller's spin, so two propellers spin clockwise and two anticlockwise, and their drag torques cancel in hover. Speed up the clockwise pair and slow the anticlockwise pair, keeping total thrust fixed, and the body yaws.

1234x (forward)yCW: 1, 3ACW: 2, 4
A quadrotor in the X layout, seen from above, nose up the page. Motors 1 and 3 spin clockwise and 2 and 4 anticlockwise, so their drag torques cancel in hover. The body axes follow the ROS convention: x forward, y left, z up out of the page. Each motor sits a distance a from the centre along both x and y.

Definition— Mixing matrix

With motors 1–4 at front-left, front-right, rear-right and rear-left, each a distance aa from the centre along both axes, and γ=km/kf\gamma = k_m/k_f, the total thrust and the torques about the body axes are

(Tτxτyτz)=(1111a−a−aa−a−aaaγ−γγ−γ)(f1f2f3f4).\begin{pmatrix} T \\ \tau_x \\ \tau_y \\ \tau_z \end{pmatrix} = \begin{pmatrix} 1 & 1 & 1 & 1 \\ a & -a & -a & a \\ -a & -a & a & a \\ \gamma & -\gamma & \gamma & -\gamma \end{pmatrix} \begin{pmatrix} f_1 \\ f_2 \\ f_3 \\ f_4 \end{pmatrix}.

The flight controller decides the thrust and torques it wants and inverts this matrix to get the four motor thrusts, then the speeds ωi=fi/kf\omega_i = \sqrt{f_i/k_f}. This step is called mixing.

The program builds the matrix for a 1.5 kg quadrotor with 10-inch propellers on 225 mm arms, mixes a few commands, and estimates how long it can hover.

python
import numpy as np

m, g = 1.5, 9.81                  # mass (kg), gravity (m/s^2)
arm = 0.225                       # distance from the centre to each motor (m)
a = arm / np.sqrt(2)              # X layout: each motor is a along x and a along y
kf = 1.0e-5                       # thrust per (rad/s)^2, N
km = 1.6e-7                       # drag torque per (rad/s)^2, N m
gamma = km / kf                   # torque-to-thrust ratio (m)

# Motors 1..4: front-left, front-right, rear-right, rear-left. Body axes: x forward, y left, z up.
# Spin seen from above: 1 and 3 clockwise, 2 and 4 anticlockwise. A propeller's drag torque
# twists the body the opposite way, so clockwise props push the body's yaw anticlockwise (+z).
M = np.array([[1,       1,       1,       1],         # total thrust
              [a,      -a,      -a,       a],         # roll torque  tau_x = sum of y_i f_i
              [-a,     -a,       a,       a],         # pitch torque tau_y = -sum of x_i f_i
              [gamma, -gamma,  gamma,  -gamma]])      # yaw torque from propeller drag
Minv = np.linalg.inv(M)

def motor_speeds(T, tx, ty, tz, f_max=8.0):
    """Wanted thrust (N) and torques (N m) -> per-motor thrusts, speeds (rad/s), and whether any saturate."""
    f = Minv @ np.array([T, tx, ty, tz])
    sat = bool(np.any(f < 0) or np.any(f > f_max))
    return f, np.sqrt(np.clip(f, 0, f_max) / kf), sat

print(f"torque-to-thrust ratio gamma = {1000 * gamma:.1f} mm;  thrust-to-weight = {4 * 8.0 / (m * g):.2f}")
for name, cmd in [("hover", (m * g, 0, 0, 0)),
                  ("hover + roll 0.3 N m", (m * g, 0.3, 0, 0)),
                  ("hover + yaw 0.1 N m", (m * g, 0, 0, 0.1)),
                  ("climb + roll 1.5 N m", (25.0, 1.5, 0, 0))]:
    f, w, sat = motor_speeds(*cmd)
    print(f"{name:22} thrusts {np.round(f, 2)} N   speeds {np.round(w * 60 / (2 * np.pi)).astype(int)} rpm"
          + ("   SATURATED" if sat else ""))

# Ideal hover power from momentum theory, P = T^1.5 / sqrt(2 rho A), per rotor.
rho, radius = 1.225, 0.127        # sea-level air density (kg/m^3), 10-inch propeller radius (m)
A = np.pi * radius ** 2
T1 = m * g / 4
P_ideal = 4 * T1 ** 1.5 / np.sqrt(2 * rho * A)
P_real = P_ideal / 0.65 / 0.80   # figure of merit of a good small propeller; motor and ESC efficiency
energy_wh = 14.8 * 5.0 * 0.8      # 4-cell 5 Ah battery, using 80% of it
print(f"\nideal hover power {P_ideal:.0f} W, realistic about {P_real:.0f} W "
      f"-> hover time about {60 * energy_wh / P_real:.0f} min on a {14.8 * 5.0:.0f} Wh battery")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

In hover each motor carries a quarter of the weight, 3.68 N, at about 5,800 rpm. A roll torque of 0.3 N m needs only a modest split, 4.15 N on the left against 3.21 N on the right. Yaw is expensive: because γ\gamma is just 16 mm, a yaw torque of 0.1 N m needs thrusts of 5.24 and 2.12 N, far more differential than rolling, which is why quadrotors yaw sluggishly and why flight controllers give yaw the lowest priority when the motors run out of range. The last command asks for more than the motors can give, and one pair saturates at its 8 N limit: the controller must then decide what to give up, and a good mixer keeps roll and pitch (which keep it upright) at the expense of climb rate and yaw.

Worked examplesH

Cascaded control of a planar quadrotor

Strip the quadrotor down to a slice: a vehicle in the vertical yy–zz plane with one rotation, the roll angle ϕ\phi, a total thrust u1u_1 along its body axis and a roll torque u2u_2. Newton's laws give

y¨=−u1msin⁡ϕ,z¨=u1mcos⁡ϕ−g,ϕ¨=u2I.\ddot y = -\frac{u_1}{m}\sin\phi, \qquad \ddot z = \frac{u_1}{m}\cos\phi - g, \qquad \ddot\phi = \frac{u_2}{I}.

Three coordinates, two inputs: the vehicle can only push along its own axis, so to move sideways it must first tilt. This structure suggests the controller. An outer position loop decides what acceleration the vehicle needs, y¨d\ddot y_d and z¨d\ddot z_d, from its position and velocity errors. To produce that acceleration the thrust must point in the direction (y¨d,z¨d+g)(\ddot y_d, \ddot z_d + g), which fixes both the tilt to command, ϕc=−arctan⁡(y¨d/(g+z¨d))\phi_c = -\arctan\big(\ddot y_d / (g + \ddot z_d)\big), and the thrust, u1=m(g+z¨d)/cos⁡ϕu_1 = m(g + \ddot z_d)/\cos\phi. An inner attitude loop then computes the torque u2u_2 that drives ϕ\phi to ϕc\phi_c. Both loops here are PD controllers, with natural frequencies ωpos\omega_\text{pos} and ωatt\omega_\text{att}.

positioncontrollerattitudecontrollermixermotors andvehicleestimatortargettilt, thrusttorquesspeedsIMU, GNSS, cameraattitudeposition, velocity
The cascade inside a multirotor flight controller. Each loop treats the faster loop inside it as an ideal actuator: the position loop asks for an acceleration, the attitude loop delivers the tilt that produces it, the mixer turns thrust and torques into motor speeds. The estimator closes every loop from the sensors.

The program flies the planar quadrotor from the origin to a point 2 m across and 1 m up, first with an attitude loop more than ten times faster than the position loop, then with slower and slower attitude loops.

python
import numpy as np

m, g, I = 1.5, 9.81, 0.02          # mass (kg), gravity, roll inertia (kg m^2)
u1_max, u2_max = 32.0, 1.5         # thrust limit (N) and roll-torque limit (N m) from the motors
tilt_max = np.radians(30)          # the position loop may ask for at most 30 degrees of tilt

def fly(w_att, w_pos=1.5, zeta=0.9, T=8.0, dt=0.001, target=(2.0, 1.0)):
    """Planar quadrotor: state y, z (m), phi (rad) and their rates. Cascaded PD:
    position loop (natural frequency w_pos) -> wanted tilt and thrust -> attitude loop (w_att) -> torque."""
    kp, kd = w_pos ** 2, 2 * zeta * w_pos           # outer (position) gains
    kpa, kda = w_att ** 2, 2 * zeta * w_att         # inner (attitude) gains
    y = z = phi = vy = vz = om = 0.0
    log, max_tilt, max_y = [], 0.0, 0.0
    for k in range(int(round(T / dt))):
        # Outer loop: the accelerations we want, from position and velocity errors.
        ay = kp * (target[0] - y) - kd * vy
        az = kp * (target[1] - z) - kd * vz
        phi_cmd = np.clip(-np.arctan2(ay, g + az), -tilt_max, tilt_max)   # tilt to point the thrust
        u1 = np.clip(m * (g + az) / np.cos(phi), 0.0, u1_max)
        # Inner loop: torque to reach the commanded tilt.
        u2 = np.clip(I * (kpa * (phi_cmd - phi) - kda * om), -u2_max, u2_max)
        # Dynamics: thrust along the body z axis, tilted by phi.
        vy += -u1 / m * np.sin(phi) * dt
        vz += (u1 / m * np.cos(phi) - g) * dt
        om += u2 / I * dt
        y += vy * dt; z += vz * dt; phi += om * dt
        max_tilt, max_y = max(max_tilt, abs(phi)), max(max_y, y)
        if k % 1000 == 999:
            log.append((round((k + 1) * dt), y, z, np.degrees(phi)))
    return log, np.degrees(max_tilt), max_y, y

log, tilt, _, _ = fly(w_att=20.0)
print("inner loop 20 rad/s, outer 1.5 rad/s: fly from (0, 0) to (2, 1) m")
print("  t (s)    y (m)    z (m)    roll (deg)")
for t, y, z, ph in log:
    print(f"  {t:4d}   {y:6.3f}   {z:6.3f}   {ph:8.2f}")
print(f"largest tilt {tilt:.1f} deg")

print("\ninner loop   furthest y   y after 4 s   y after 8 s   largest tilt")
for w_att in [20.0, 8.0, 4.0, 2.5]:
    log, tilt, y_max, y_end = fly(w_att)
    print(f"{w_att:5.1f} rad/s   {y_max:7.3f} m    {log[3][1]:7.3f} m     {y_end:7.3f} m     {tilt:6.1f} deg")
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

With a fast inner loop the vehicle tilts by up to 18° to start moving, tilts back to brake, and arrives within a centimetre in four seconds without overshoot, behaving almost exactly like the outer loop's design. Slow the inner loop to 8 rad/s and nothing much changes. At 4 rad/s, under three times the outer loop's speed, the vehicle overshoots to 2.17 m, because by the time the tilt arrives the position loop has already asked for something else. At 2.5 rad/s the two loops fight: the vehicle swings out to 3.6 m and back, is at 0.24 m after eight seconds, and never settles. The rule of thumb in flight-controller design is that each inner loop should be roughly five to ten times faster than the loop around it, so that the outer loop can treat it as instantaneous.

ComputationC

Knowing which way is up

The attitude loop is only as good as its measurement of ϕ\phi. A flight controller has a small IMU: a three-axis gyroscope, which measures angular velocity, and a three-axis accelerometer, which measures specific force, the acceleration minus gravity, in the body frame. Neither measures attitude directly.

  • Integrating the gyroscope gives attitude changes that are smooth and accurate over a second, but its small bias (a constant offset) integrates into an error that grows without limit.
  • A body at rest feels gravity pushing up through its supports, so the accelerometer then points along "up" in the body frame, and its direction gives the tilt. That is right on average but noisy (motor vibration), and wrong whenever the body accelerates.

Their errors live at opposite ends of the spectrum, so a complementary filter blends them: high-pass the gyroscope's integrated angle, low-pass the accelerometer's, and add. In discrete time, with step Δt\Delta t,

ϕ^k=α (ϕ^k−1+ωk Δt)+(1−α) ϕacc,k,τ=α Δt1−α,\hat\phi_k = \alpha\,\big(\hat\phi_{k-1} + \omega_k\,\Delta t\big) + (1 - \alpha)\,\phi_{\text{acc},k}, \qquad \tau = \frac{\alpha\,\Delta t}{1 - \alpha},

where τ\tau is the crossover time constant: the gyroscope is trusted for changes faster than τ\tau, the accelerometer for slower ones. The program simulates a 200 Hz IMU on a platform that rocks and sways (a gyroscope bias of 1°/s and noise, and an accelerometer with motor-like vibration and a sideways acceleration), runs filters with several time constants, and then runs the same filter on a multirotor.

python
import numpy as np

rng = np.random.default_rng(7)           # fixed seed: the same "noisy" sensors every run
dt, T, g = 0.005, 30.0, 9.81             # 200 Hz IMU, 30 s of data
t = np.arange(0.0, T, dt)

# The truth: a platform rocking in roll while swaying sideways (angles in rad), like a flight
# controller on a test rig or the body of a walking robot.
phi = np.radians(15) * np.sin(2 * np.pi * 0.3 * t) + np.radians(5) * np.sin(2 * np.pi * 1.1 * t)
rate = np.gradient(phi, dt)
a_side = 0.8 * np.sin(2 * np.pi * 0.2 * t)        # sideways acceleration in the world (m/s^2)

# The gyroscope: true rate + a constant bias of 1 deg/s + white noise.
gyro = rate + np.radians(1.0) + rng.normal(0.0, np.radians(0.5), t.size)
# The accelerometer measures specific force (acceleration minus gravity) in the body frame,
# plus vibration from the motors. Its tilt estimate is right only when the vehicle is not accelerating.
f_y_world, f_z_world = a_side, np.full_like(t, g)
f_y_body = np.cos(phi) * f_y_world + np.sin(phi) * f_z_world
f_z_body = -np.sin(phi) * f_y_world + np.cos(phi) * f_z_world
f_y_body += rng.normal(0.0, 1.5, t.size)
f_z_body += rng.normal(0.0, 1.5, t.size)
phi_acc = np.arctan2(f_y_body, f_z_body)

def complementary(alpha, tilt_from_acc=phi_acc):
    est = np.empty_like(t)
    e = tilt_from_acc[0]
    for k in range(t.size):
        e = alpha * (e + gyro[k] * dt) + (1 - alpha) * tilt_from_acc[k]
        est[k] = e
    return est

def report(name, est):
    err = np.degrees(est - phi)
    print(f"{name:40} RMS error {np.sqrt(np.mean(err ** 2)):6.2f} deg   error at 30 s {err[-1]:+7.2f} deg")

report("gyroscope only, from the true start", phi[0] + np.cumsum(gyro) * dt)
report("accelerometer only", phi_acc)
for alpha in [0.9, 0.98, 0.995, 0.999]:
    tau = alpha * dt / (1 - alpha)
    report(f"complementary, alpha {alpha} (tau {tau:.2f} s)", complementary(alpha))

# A multirotor holding its height tilts in order to accelerate: a_side = -g tan(phi). Its
# accelerometer then feels only thrust, along its own z axis, and reports "level" whatever the tilt.
f_y_mr = rng.normal(0.0, 1.5, t.size)
f_z_mr = g / np.cos(phi) + rng.normal(0.0, 1.5, t.size)
report("same filter (0.995) on a multirotor", complementary(0.995, np.arctan2(f_y_mr, f_z_mr)))
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

The gyroscope alone, even started at the true angle, is 30° off after 30 s: 1°/s of bias, integrated. The accelerometer alone never drifts but is 9.4° RMS off, from vibration and from the sway. Blending them cuts the error to 2.5–3.8° RMS for time constants from 0.05 to 1 s, best near τ≈1\tau \approx 1 s. Push τ\tau to 5 s and the bias creeps back in: in steady state the filter's error is the gyroscope bias times τ\tau (5° here), which is why real filters also estimate the bias and subtract it.

ExplanationH

Flight controllers and navigation

The two open-source flight stacks that most research and many commercial drones use are PX4, which began as a student project at ETH Zurich around 2009, alongside the Pixhawk autopilot hardware, and is now hosted by the Dronecode Foundation under the Linux Foundation, and ArduPilot, a community project begun in 2009 that flies multirotors, planes, VTOL aircraft, helicopters, boats and rovers. Both run on small autopilot boards and use the cascade above, extended to 3-D: a position loop and a velocity loop produce a desired acceleration and thrust direction, an attitude loop (on quaternions, as in Rotations and quaternions) produces desired body rates, and an inner rate loop, the fastest, running at hundreds of hertz to a few kilohertz, turns rate errors into torques for the mixer. Their estimators (PX4's EKF2, ArduPilot's EKF3) are extended Kalman filters fusing the IMU, magnetometer, barometer, GNSS and optional vision or optical-flow sensors. Betaflight and its relatives, popular for racing and first-person-view flying, run only the inner loops, very fast, with the pilot closing the outer ones by eye.

Above the autopilot, a companion computer runs perception and planning, often with ROS 2 (ROS 2 and robot software), and sends setpoints over MAVLink, the message protocol shared by autopilots and ground stations. The sketch below uses MAVSDK's Python interface to take off and land; it is shown for reading and is not run here, since it needs a real or simulated vehicle.

python
# MAVSDK-Python: shown for reading, not run here. It needs a PX4 or ArduPilot vehicle,
# or PX4's software-in-the-loop simulator, listening at the given address.
# The address format differs between MAVSDK versions: check its documentation.
import asyncio
from mavsdk import System

async def main():
    drone = System()
    await drone.connect(system_address="udp://:14540")
    async for state in drone.core.connection_state():
        if state.is_connected:
            break
    await drone.action.set_takeoff_altitude(3.0)
    await drone.action.arm()
    await drone.action.takeoff()
    await asyncio.sleep(10)
    await drone.action.land()

asyncio.run(main())

Develop against the simulator first. PX4 and ArduPilot both run unchanged on a desktop as software in the loop, with Gazebo or another simulator standing in for the vehicle (Simulation), so a mission can crash a hundred times at no cost before it flies once.

Where am I? Outdoors, GNSS (GPS, Galileo, BeiDou, GLONASS) gives position to a few metres, and RTK correction from a nearby base station to a couple of centimetres, enough for surveying and precision spraying. GNSS fails under bridges, near tall buildings, in forests and indoors, and it can be jammed or spoofed, so a drone also needs to navigate without it. Visual–inertial odometry (VIO) fuses a camera with the IMU to track motion from features in the image, as in HKUST's VINS-Mono, the University of Delaware's OpenVINS or the University of Zaragoza's ORB-SLAM3; downward optical-flow sensors with a rangefinder hold position over textured floors; lidar odometry works in the dark. Research labs fly indoors under motion-capture systems, which track reflective markers with external cameras to millimetres, and so separate control research from estimation. VIO drifts like any odometry, and SLAM corrects it against a map.

The frontier is fast, autonomous flight from onboard sensing. In 2023 the University of Zurich's Swift system, a policy trained with reinforcement learning, beat human world-class pilots in head-to-head races on a physical track, using only onboard camera and IMU; drone swarms that fly through forests on onboard perception are the subject of Multi-robot systems.

ExplanationH

Fixed wings and VTOL

Multirotors buy their simplicity with efficiency: they hold themselves up by brute force, accelerating a column of air downwards all the time. A fixed-wing aircraft gets its lift from forward motion, L=12ρv2SCLL = \tfrac{1}{2}\rho v^2 S C_L for wing area SS and lift coefficient CLC_L, and needs only enough thrust to overcome drag, a fraction of its weight set by its lift-to-drag ratio. Small fixed-wing drones therefore fly for hours and cover tens to hundreds of kilometres, which is why long-range mapping and delivery networks use them. Their costs are a minimum speed (below it the wing stalls), and the need for a runway, a catapult or a net.

VTOL (vertical take-off and landing) aircraft combine the two: they take off and land like a multirotor and cruise on a wing. A quadplane adds lift rotors to a conventional plane; a tilt-rotor turns its rotors from vertical to forward, as on Wingcopter's delivery drones from Germany; a tail-sitter stands on its tail and pitches the whole aircraft over. Some delivery systems avoid landing altogether: Zipline's fixed-wing aircraft are launched by catapult, drop packages by parachute, and are caught by a wire on their return. The control problem in VTOL aircraft is the transition between hover and wing-borne flight, when neither the rotors nor the wing alone can hold the aircraft up; PX4 and ArduPilot both support these airframes.

ExplanationH

The law and safety

Drone rules differ from country to country and change often, so the only reliable source is the national aviation authority where you fly: for example EASA and the national authorities in the European Union, the FAA in the United States, the CAA in the United Kingdom, the DGCA in India, Japan's Civil Aviation Bureau, Brazil's ANAC or Kenya's KCAA. As of 2026 many countries share some features: registration of the operator or the aircraft above a small mass (often 250 g, but in Japan 100 g); a height limit of around 120 m above the ground; keeping the drone within the pilot's visual line of sight; staying away from airports, crowds and restricted areas (often published as digital maps); online tests for pilots; and, increasingly, Remote ID, a radio broadcast of the drone's identity and position. Commercial and beyond-visual-line-of-sight operations need further permissions. Privacy and data-protection law also applies to cameras in the sky.

Note

Flying safely. Propellers spin at thousands of rpm and cut skin; never handle a drone with its battery connected and armed, and remove the propellers whenever you work on it at the bench. Lithium-polymer flight batteries store a lot of energy: charge them with a proper balance charger on a non-flammable surface while someone is present, and stop using any that are swollen, punctured or damaged. Test new code in simulation, then on a small, light drone (tens of grams, with propeller guards) indoors in an empty room, before anything larger. Never fly over people, near airports or beyond the rules of your country, and keep a manual override and a geofence ready.

Common misconceptionsH

Common misconceptions

Misconception

"A quadrotor turns left by speeding up its right-hand motors." That rolls it to the left. To yaw, it speeds up one diagonal pair and slows the other, using the difference in propeller drag torques, with total thrust unchanged. Yaw authority is weak because γ\gamma is small.

Misconception

"The accelerometer measures gravity, so it tells the flight controller which way is down." It measures specific force, acceleration minus gravity. On a multirotor in coordinated flight that is mostly thrust along the body axis, whatever the tilt. Only when the vehicle is not accelerating does it point along gravity.

Misconception

"Higher gains make a drone more stable." Higher inner-loop gains make it respond faster, until sensor noise, motor delays and propeller flexibility turn the loop into an oscillation; outer loops must stay several times slower than inner ones, as the simulation showed.

Misconception

"If my drone is small and light, the rules do not apply." Thresholds differ between countries, and some rules (no flying near airports, over crowds or in restricted areas, respecting privacy) apply to every drone. Check with your national authority before you fly.

Exercises

Exercises

1. Aerial robots

Warm-upHuman

A 1.2 kg quadrotor hovers with all four motors at the same speed. Each propeller's thrust is kfω2k_f\omega^2 with kf=1.2×10−5k_f = 1.2 \times 10^{-5} N per (rad/s)². Taking g=9.81g = 9.81 m/s², what is each motor's speed in rad/s, to the nearest whole number?

2. Aerial robots

CoreHuman

A quadrotor holding a constant height wants to accelerate horizontally at 33 m/s². Ignoring drag and taking g=9.81g = 9.81 m/s², by how many degrees must it tilt? Round to the nearest degree.

3. Aerial robots

CoreHuman

Use the lesson's quadrotor: motors 1–4 at front-left, front-right, rear-right and rear-left, with 1 and 3 spinning clockwise and 2 and 4 anticlockwise, seen from above. To yaw the body anticlockwise (turning its nose to the left) without changing the total thrust, which motors should speed up? Give the motor numbers.

Write elements separated by commas. Order and repeats don’t matter — just like in a set!

4. Aerial robots

CoreHuman

In the lesson's cascaded controller, why must the attitude loop be several times faster than the position loop?

Choose one

5. Aerial robots

CoreHuman

Which of these statements about how drones know where they are are correct? Select all that apply.

Choose all that apply

6. Aerial robots

CoreComputational

Write motor_thrusts(T, tau_x, tau_y, tau_z, a=0.159, gamma=0.016), which returns the four motor thrusts f1,…,f4f_1, \ldots, f_4 (as a NumPy array) that produce total thrust T and body torques tau_x, tau_y, tau_z for the lesson's X-layout quadrotor:

T=f1+f2+f3+f4,τx=a(f1−f2−f3+f4),τy=a(−f1−f2+f3+f4),τz=γ(f1−f2+f3−f4).T = f_1 + f_2 + f_3 + f_4,\quad \tau_x = a(f_1 - f_2 - f_3 + f_4),\quad \tau_y = a(-f_1 - f_2 + f_3 + f_4),\quad \tau_z = \gamma(f_1 - f_2 + f_3 - f_4).

You may use np.linalg.solve, but there is a neat closed form.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

7. Aerial robots

StretchComputational

Write complementary_filter(gyro, acc_angle, dt, alpha). gyro[k] is the gyroscope's angular rate (rad/s) and acc_angle[k] the accelerometer's tilt estimate (rad) at step kk. Return an array est with est[0] = acc_angle[0] and, for k≥1k \ge 1,

ϕ^k=α(ϕ^k−1+ωk Δt)+(1−α) ϕacc,k.\hat\phi_k = \alpha\big(\hat\phi_{k-1} + \omega_k\,\Delta t\big) + (1 - \alpha)\,\phi_{\text{acc},k}.

The tests check, among other things, that with a constant gyroscope bias bb and a perfect accelerometer the estimate settles at the true angle plus bτb\tau, with τ=αΔt/(1−α)\tau = \alpha\Delta t/(1 - \alpha).

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Further reading and resources