A steady 1 N wind hits a hovering drone. With no feedback it is 4.5 m away three seconds later. Proportional feedback alone swings wider each time. Add damping and it holds, 0.25 m off. Add an integral and it comes back to 0.00 m.
Pick a controller, set the wind, and press Play. Watch the teal drone tilt into the pink wind. Then we build, piece by piece, state space and poles, PD and PID, LQR, the rotor mixer, flatness, the cascade and attitude control on SO(3).
You need Lectures 1 and 2 (rotation matrices, RWB, the hat map), F = ma and a little Python. We build the rest from zero.
Lecture 3 of 14 in our follow-along of MIT 16.485, Visual Navigation for Autonomous Vehicles (VNAV, taught by Luca Carlone). Every idea is re-taught here in our own words and devices. Previous: Lecture 2, Lie groups. Next: Lecture 4, trajectory optimisation.
Illustrative drone, simulated here: 1 kg, two rotors 0.25 m from the centre, at most 10 N each. The wind starts at 1 s and stays. Outer gains kp = 4, kd = 3, ki = 2; the attitude loop is 10 times faster. Side view: y points into the screen, so a positive pitch looks clockwise.
Chapter 0
Set the thrust from a model and watch a heavier battery pull the drone down
The estimator says where the drone is. The planner says where it should be. Neither one spins a rotor. Control is the part that turns the gap between the two into rotor commands, many times a second.
The simplest plan needs no sensor at all. The drone weighs 1 kg, so the rotors push 9.81 N and it hovers. This is open-loop control: the command comes from the model alone. Now swap in a battery that is 50 g heavier.
The controller believes the drone weighs 1 kg. Add mass with the slider, then switch between open loop and feedback. The teal curve is the height; yellow is the target.
Illustrative 1D model. Feedback here is kp = 4, kd = 3 on the measured height and climb rate (Chapter 2).
Work the number. The rotors still push 9.81 N, but the weight is 1.05 × 9.81 = 10.30 N. The net force is 0.49 N down, so the drone sinks at 0.467 m/s². After 2 s it has fallen 0.93 m, and it keeps going.
Closed-loop control, or feedback, measures the height and pushes back on the gap. The same 50 g now costs 0.12 m of sag, and the drone stops there. The model was wrong in both cases. Feedback did not need it to be right.
Symptom: a drone that hovered on the bench drifts down, or sideways, in the field.
Measure: log thrust and height. A constant command with a changing height means no loop closes on that axis.
Fix: feed the measured state back. Keep the model as a feedforward guess, not as the whole command.
Chapter 1
Move a pair of poles and watch the response decay, ring or blow up
To predict a system, list the few numbers that fix its future. For the altitude axis they are the height and the climb rate. That list is the state. What we command, here the thrust beyond the weight, is the input.
Near a hover, most robots obey a linear rule. Call the state vector x, the input u, and two fixed matrices A and B.
X-dot equals A times x, plus B times u.
Multiply the state x by A and the input u by B. Add them. The sum is the velocity of the state, so you can step it forward in time.
Altitude axis of a 1 kg drone: A has rows (0, 1) and (0, 0); B is (0, 1). Take x = (2 m, 0.1 m/s) and u = 0.5 N. Then x-dot = (0.1 m/s, 0.5 m/s²): the height rises at 0.1 m/s, and the climb gains 0.5 m/s each second.
With u = 0, every solution is a mix of modes eλt, one for each eigenvalue λ (lambda) of A. Control engineers call them poles. The real part sets growth or decay. The imaginary part sets how fast it rings.
Left: the pole plane, with the purple pair σ ± jω. Right: the response from a kick of 1. Slide the real part across zero and watch the curve turn.
Exact maths: the response is eσt cos ωt.
Work the number for a mass on a spring: 1 kg, stiffness 4 N/m, no friction. A has rows (0, 1) and (−4, 0), so the poles are ±2j: it rings forever at 2 rad/s. Add friction of 4 N·s/m and both poles sit at −2. That is critical damping, the fastest settle with no overshoot.
The hovering drone is worse than the spring. Its altitude A has both poles at exactly 0. Nothing pulls it back, so a climb rate error of 0.1 m/s becomes 1 m of drift in 10 s. The full planar hover is a chain of four integrators, all poles at 0.
Symptom: a "stable" simulation slowly wanders off when you run it longer.
Measure: print the eigenvalues of A, or of the closed loop. Any real part at or above 0 is not asymptotically stable.
Fix: close a loop that moves every pole into the left half.
Chapter 2
Turn two gains and place the poles of a hovering drone
Feedback makes the input a function of the state: u = −Kx, with a gain matrix K. Then x-dot = (A − BK)x. The poles are now the eigenvalues of A − BK, and we choose K.
One number first. Take x-dot = 2x + u, unstable with its pole at +2. Feed back u = −5x and the pole moves to 2 − 5 = −3. From x = 1, after 1 s, x = e−3 = 0.05.
Now the altitude axis, a mass m pushed by u. Call the error e: the height minus the target height. A PD controller pushes back on the error with a gain kp, the spring. It pushes back on the error rate with a gain kd, the damper: u = −kpe − kdė. The closed loop is a spring and a damper we set by hand.
Omega-n equals the square root of k-p over m. Zeta equals k-d over two times the square root of k-p times m.
The loop m e-double-dot + k-d e-dot + k-p e = 0 is a spring and damper. Its poles are minus zeta omega-n, plus or minus omega-n times the square root of zeta squared minus one. Raise k-p for speed; raise k-d for damping.
m = 1 kg, kp = 4, kd = 2: ωn = 2 rad/s and ζ = 0.5. The poles are −1 ± 1.73j. A 1 m step overshoots by e−πζ/√(1−ζ²) = 16.3%, and settles within 2% after about 4/(ζωn) = 4.0 s.
The drone must climb 1 m. The teal curve is its height; the small panel shows the purple poles. Set kd to 0 to see the hero's P button.
Exact maths on a 1 kg double integrator, simulated with a 1 ms step. No actuator limit here.
The simulation agrees: the peak is 1.163 m at 1.81 s, and the height stays within 2% after 4.04 s. Set kd = 4 and ζ = 1: no overshoot.
Symptom: the drone rings around the target and takes long to settle.
Measure: overshoot and settling time of a step. Overshoot above about 20% means ζ below 0.45.
Fix: raise kd until ζ is near 0.7. Raise kp only for speed.
Chapter 3
Remove a steady sag with memory, then hold the drone down and watch the memory overflow
Back to the heavy battery. A PD loop settles where the spring force kpe balances the missing 0.49 N. With kp = 4 that is 0.12 m low, the sag from Chapter 0. A stiffer spring shrinks it but never removes it.
The fix is memory. Add up the error over time, the integral ∫e dt, and push back on that too. While any sag remains, the sum keeps growing, so the push keeps growing. It stops only when the error is zero.
U equals minus k-p e, minus k-i times the integral of e d-t, minus k-d e-dot.
Each tick, add e times the time step to the running sum. Multiply the error, the sum and the error rate by their gains. Add the three and flip the sign: that is the command u.
With made-up numbers: the drone is 1 m low, so e = −1, e-dot = 0, and the sum is −0.4 m·s. Then u = 9 × 1 + 2 × 0.4 + 5 × 0 = 9.8 N of extra thrust, with 0.8 N of it from memory.
Memory has a price. Suppose the drone sits on the ground for 3 s while the target is 2 m up. The rotors hit their limit, but the sum keeps growing. On release, that stored push throws the drone far past the target. This is integrator windup.
A hand holds the 50 g heavy drone on the ground for the first 3 s. The warm curve is the command, clipped at the rotor limit. Toggle the integral and anti-windup.
Illustrative 1D model: kp = 9, ki = 2, kd = 5, command limited to ±9.81 N beyond the weight. Anti-windup here stops adding to the sum while the limit clips the command and the error pushes the same way.
Work the numbers from the device. Without the integral, the drone stops 0.05 m low (0.49 N / 9). With it, but no guard, the sum reaches 6.9 m·s and the drone peaks at 3.40 m, 1.4 m too high. With anti-windup the peak is 2.15 m.
Symptom: after takeoff, a long climb or a stuck gimbal, the vehicle overshoots far more than in step tests.
Measure: log the integral state next to the clipped command. A sum that grows while the command sits at its limit is windup.
Fix: stop integrating while saturated, and clamp the sum to what the actuator can use.
Chapter 4
Slide one price ratio and let the Riccati equation choose every gain
Two gains are easy to tune by hand. A drone's full state has 12 numbers and 4 inputs, so K has 48 entries. The linear quadratic regulator (LQR) chooses all of them at once. You state what errors and effort cost, and it finds the cheapest K.
Call the price of state error a matrix Q and the price of effort a matrix R. LQR adds both costs over all future time.
J equals the integral from zero to infinity of x-transpose Q x, plus u-transpose R u, d-t.
At each instant, square the errors and weight them by Q. Square the inputs and weight them by R. Add the two and sum over the whole run. That total is J.
Scalar case x-dot = u, Q = R = 1, start at x = 1, gain K. Then x = e−Kt, u = −Kx, and J = (1 + K²)/(2K). K = 0.5 gives 1.25; K = 1 gives 1.00; K = 3 gives 1.67. Too gentle pays in error; too hard pays in effort.
The best K comes from one matrix equation. Call its solution P, a symmetric matrix that prices each starting state.
K equals R-inverse B-transpose P, where A-transpose P plus P A, minus P B R-inverse B-transpose P, plus Q, equals zero.
Solve the second equation, the algebraic Riccati equation, for the P that is positive definite. Then multiply R-inverse, B-transpose and P to get K. SciPy does the solve: solve_continuous_are(A, B, Q, R).
Scalar case: A = 0, B = Q = R = 1, so the equation is −P² + 1 = 0 and P = 1. Then K = 1, the minimum of the table above, and the best cost is P x0² = 1.00.
The drone starts 1 m above the target. Teal is the height; warm is the thrust. The bar splits the cost into error and effort. Slide right to make error expensive.
Exact maths: 1 kg double integrator, Q = diag(q, 0), R = r, gains from the closed form of the Riccati equation, checked against SciPy.
Work the number at q/r = 10. The gains are kp = 3.16 and kd = 2.51, and the best cost is 7.95. Three quarters is error and one quarter effort, at every ratio. For this drone LQR always picks ζ = 0.707.
Symptom: an LQR design saturates the motors on the first gust.
Measure: the peak of u in simulation against the actuator limit.
Fix: raise R, or lower Q on the states that matter less, and re-solve.
Chapter 5
Write Newton and Euler for the drone, then turn force and torque into four rotor speeds
Now the real vehicle, with attitude R = RWB and position p, as in Lecture 1. The body frame is forward, left, up. Every rotor pushes along body z, so the total thrust is one number f along R e3.
Call gravity g, the mass m and the inertia matrix J. Call the body turn rate ω (the gyro reading, ωB in Lecture 2) and the body torque τ.
M p-double-dot equals minus m g e-3, plus f R e-3. J omega-dot equals minus omega cross J omega, plus tau.
In world numbers, gravity pulls down and the thrust f pushes along R e-3. In body numbers, the torque tau turns the body, less the gyroscopic term. The attitude then moves by R-dot = R omega-hat.
Hover thrust f = 9.81 N, pitched 10°. Sideways: 9.81 × sin 10° = 1.70 m/s². Up: 9.81 × cos 10° − 9.81 = −0.15 m/s², so it also sinks. A pitch torque of 0.05 N·m on Jy = 0.01 gives 5 rad/s².
Rotor i spins at Ωi (capital omega i, rad/s). It gives a thrust cfΩi² (cf = 10−5 N·s²) and a drag torque cdΩi² (cd = 10−6 N·m·s²) against its spin. Rotors 1 to 4 sit front, left, back and right, L = 0.25 m out. Rotors 1 and 3 spin clockwise from above.
The vector f, tau-x, tau-y, tau-z equals the mixer matrix times the vector of the four rotor speeds squared.
A faster left rotor rolls the right side down; a faster back rotor pitches the nose down. Ask for f and tau, multiply by the inverse matrix, and take square roots. That inverse is the mixer, or control allocation.
Hover: each rotor gives 9.81/4 = 2.45 N, so Ω = √(2.45/10−5) = 495.2 rad/s, 4,729 rpm. Add a roll torque of 0.05 N·m: Ω2² − Ω4² = 0.05/(0.25 × 10−5) = 20,000. Rotor 2 goes to 505.2 rad/s and rotor 4 to 485.0.
Top view, nose up the screen. Ask for a thrust and torques; the warm discs and bars show each rotor's speed. Push a torque far and one rotor runs out of range.
Illustrative constants cf = 10−5, cd = 10−6, L = 0.25 m, top speed 1,000 rad/s (10 N per rotor). Exact maths.
Symptom: the drone yaws when it should roll, or flips on takeoff.
Measure: command a small roll torque on the bench and check which rotors speed up.
Fix: match the mixer to the real rotor positions and spin directions. One swapped sign flips a row.
Chapter 6
Drag an acceleration and watch the attitude and thrust it forces
Six degrees of freedom, four inputs: we call the quadrotor underactuated. It cannot push sideways while level. To go forward, it tilts the thrust forward. So position and attitude move together.
The tie runs the useful way. Pick the acceleration you want, ad. The thrust must supply ad plus the weight, so that one vector fixes both the thrust size and the direction of body z.
F equals m times the norm of a-d plus g e-3. Z-B-d equals a-d plus g e-3, over its norm.
Add 9.81 m/s² up to the wanted acceleration a-d. Its length times m is the thrust f. Its direction is where body z must point. A wanted yaw ψ then fixes the other two axes. They lie square to zB,d, with xB as close as it can get to the heading (cos ψ, sin ψ, 0).
ad = (2, 0, 0) m/s²: the vector is (2, 0, 9.81), length 10.01. So f = 10.01 N and body z tilts forward by atan(2/9.81) = 11.5°. With ψ = 0, Rd has columns (0.980, 0, −0.200), (0, 1, 0) and (0.200, 0, 0.980).
Side view. Yellow is the acceleration you ask for; pink is gravity; warm is the thrust the drone must make. The drone tilts to match. Ask to fall faster than gravity and see what breaks.
Exact maths, 1 kg, thrust limit 20 N (two rotors in this side view).
Mellinger and Kumar (ICRA 2011) turned this into a design rule. Position x, y, z and yaw ψ are flat outputs: from them and their derivatives you can rebuild every state and input. The attitude needs the acceleration, the body rate needs the jerk (the rate of acceleration), and the torque needs the snap (the rate of jerk).
Work the rate. At ad = (2, 0, 0), raise the forward acceleration by 1 m/s² each second. The pitch rate must be 0.098 rad/s, 5.6°/s. A path with a jump in jerk asks for a jump in body rate, which needs an infinite torque. That is why Lecture 4 builds smooth, minimum-snap paths.
Symptom: the drone drops or flips when asked to dive fast.
Measure: the vertical part of ad + g e3. At or below zero, the thrust would have to point down.
Fix: limit downward acceleration to well under g, and cap the tilt.
Chapter 7
Slow the attitude loop down and watch the position loop lose its footing
The full controller is two loops. The outer position loop turns the position error into a desired force, so a thrust and a desired attitude Rd. The inner attitude loop turns Rd into torques. The mixer turns those into rotor speeds.
Call the position error ex = p − pd and the velocity error ev = v − vd. The outer loop is PD plus two known terms.
F equals minus k-x e-x, minus k-v e-v, plus m g e-3, plus m a-d. Little f equals F dot R e-3.
Build F from the two errors, the weight and the planned acceleration. Point body z along F by sending Rd to the inner loop (Chapter 6 adds the yaw). Command only the part of F along the current body z: if the drone has not tilted yet, it does not shove the wrong way.
A gust left the drone 0.5 m forward of its target, at rest: ex = (0.5, 0, 0). F = (−2, 0, 9.81), so Rd tilts 11.5° back. While still level, f = F · (0, 0, 1) = 9.81 N; once tilted, f = 10.01 N.
This works only if the inner loop is much faster. The outer loop assumes the drone reaches Rd at once. If the attitude lags, the position loop pushes on a tilt that is not there yet.
The drone steps 1 m forward. Teal is its position; the lower trace is its tilt. The slider sets how much faster the attitude loop is than the position loop.
Illustrative planar drone from the hero: outer ωn = 2 rad/s (kx = 4, kv = 3); inner loop ζ = 0.7 at the chosen speed; rotor limits on. Nonlinear simulation, 0.5 ms step.
Work the boundary. Linearise the planar loop. Its poles cross into the right half when the attitude loop is only 2.0 times faster (4.0 rad/s against 2). At 3× it overshoots 12%. At 5× and above it behaves like the ideal PD, 1.02 to 1.03 m peak.
Symptom: raising the position gains makes the drone wobble and then diverge.
Measure: the step-response speed of the attitude loop against the position loop.
Fix: keep the inner loop 5 to 10 times faster. Raise attitude gains first, or lower the position gains.
Chapter 8
Track a flip with a rotation-matrix error and watch Euler angles lose it past 90°
The inner loop drives R to Rd. A PD on roll, pitch and yaw differences looks natural, but Lecture 2 showed that Euler angles jump at 90° pitch.
Lee, Leok and McClamroch (CDC 2010) measure the error on SO(3) itself, from the relative rotation Rd⊤R.
E-R equals one half of R-d-transpose R minus R-transpose R-d, vee. E-omega equals omega minus R-transpose R-d omega-d.
Form R-d-transpose R. If the frames match, its skew part is zero. Otherwise vee of the skew part points along the error axis, length sin θ. Bring the desired rate into the body frame, then subtract.
Rd = I and R = Rx(30°): the skew part gives eR = (0.5, 0, 0) = sin 30° along x. At 150° it is also 0.5, and at 180° it is 0: the push fades for errors past 90°.
The torque is a PD on these errors plus two extra terms. Call the attitude gain kR and the rate gain kω.
Tau equals minus k-R e-R, minus k-omega e-omega, plus omega cross J omega, minus J times omega-hat R-transpose R-d omega-d, minus R-transpose R-d omega-d-dot.
Push back on both errors, like a PD. Cancel the gyroscopic term. Add the torque the planned rotation needs, so the PD fixes only what is left.
At rest, 30° off in roll, hovering target: τ = −0.4 × (0.5, 0, 0) = (−0.2, 0, 0) N·m. With Jx = 0.01, that is −20 rad/s² back toward level. Near level these gains give ωn = 6.3 rad/s, ζ = 0.63.
The yellow frame flips end over end; the teal drone starts 10° off in roll and must follow. Pick a controller and press Play.
Illustrative rigid body, J = diag(0.01, 0.01, 0.018) kg·m², kR = 0.4, kω = 0.08. Both share the rate and feedforward terms. Exact maths, 1 ms steps on SO(3).
Work the numbers at 3 rad/s. The geometric loop is within 0.1° after 1.5 s. Euler PD tracks until the desired pitch passes 90°. Then the desired yaw and roll jump by 180°, the error jumps, and the drone ends up to 180° off.
Lee et al. prove the attitude loop exponentially stable for any start error under 180°, given a bound on the start rate. With the position loop on top: exponentially stable under 90°, exponentially attractive under 180°. This is their "almost global". No smooth feedback on SO(3) can include every start.
Symptom: an aggressive manoeuvre goes wild as the nose passes vertical.
Measure: plot the Euler angles of Rd. Look for 180° jumps in yaw and roll near 90° pitch.
Fix: compute the error on SO(3) with eR. Keep Euler angles for display.
Chapter 9
Click a target and watch an error become a tilt, a torque and two rotor speeds
Here is every piece at once, in the side view of the hero. The position loop of Chapter 7 builds F from the error. Its direction becomes the desired tilt. The attitude loop turns the tilt error into a torque. The mixer of Chapter 5 splits thrust and torque between the front and back rotors.
Nothing commands the tilt directly. Click to the right and watch the drone first lean right, then brake by leaning left. The yellow line is the position error. The thin yellow tick on the drone is Rd, the tilt the outer loop asks for.
Click or tap anywhere on the scene to move the yellow target. The warm bars are the front and back rotor thrusts; they turn red at their limit.
Illustrative planar drone: 1 kg, Jy = 0.01 kg·m², arms 0.25 m, 10 N per rotor. We set kv for ζ = 0.75 at each kx. ki = 2, summed only within 0.5 m of the target. Attitude loop ζ = 0.7. Real time, 1 ms steps.
Try three things. Set the wind to 2 N with the integral off. The drone hangs 0.5 m downwind: 2 N over kx = 4, as in Chapter 3. Turn the integral on and it walks back. Then drop the inner speed to 2× and click across the screen: the cascade of Chapter 7 wobbles and never settles.
Push kx to 12 and click far away. The thrust bars turn red: the rotors saturate, and the clean PD numbers stop holding. Real flight stacks cap the tilt and the acceleration for exactly this reason.
Chapter 10
Keep the laws, the conventions and the code side by side
Feedback beats a model alone because it measures. A linear system's poles say whether it settles; feedback moves them. PD places a spring and a damper, the integral removes steady sag at the risk of windup, and LQR picks all gains from two prices. A quadrotor has one thrust and three torques, so it tilts to move. The position loop asks for a force, and the force fixes thrust and attitude. A faster loop tracks that attitude on SO(3), and the mixer sets the rotor speeds.
| Piece | Law | Number on this page | Watch out |
|---|---|---|---|
| Stability | all poles of A − BK in the left half | hover: 4 poles at 0 | a pole at 0 drifts |
| PD | ωn = √(kp/m), ζ = kd/(2√(kpm)) | kp 4, kd 2: 16.3% overshoot | steady sag d/kp |
| PID | u = −kpe − ki∫e − kdė | windup peak 3.40 m vs 2.15 m guarded | guard the integral |
| Tuning start | Ziegler-Nichols: kp = 0.6Ku, ki = 1.2Ku/Tu, kd = 0.075KuTu | Ku, Tu: gain and period at steady ringing | a starting point, retune on hardware |
| LQR | K = R−1B⊤P, Riccati for P | q/r 10: K = (3.16, 2.51) | check the peak input |
| Mixer | (f, τ) = M (Ωi²) | hover 495.2 rad/s | rotor order and spin signs |
| Flatness | f = m‖ad + g e3‖, zB,d along it | 2 m/s² forward: 11.5°, 10.01 N | jerk sets body rate, snap sets torque |
| Cascade | F = −kxex − kvev + mg e3 + m ad | unstable below 2× inner speed | keep 5 to 10× |
| Attitude | eR = ½(Rd⊤R − R⊤Rd)∨ | 30° roll: eR = (0.5, 0, 0) | |eR| = sin θ, weak near 180° |
python import numpy as np from scipy.linalg import solve_continuous_are def hat(v): return np.array([[0, -v[2], v[1]], [v[2], 0, -v[0]], [-v[1], v[0], 0]]) def vee(M): return np.array([M[2, 1], M[0, 2], M[1, 0]]) g, m = 9.81, 1.0 J = np.diag([0.01, 0.01, 0.018]) class PID: # e = measured - target def __init__(s, kp, ki, kd, umax): s.k = (kp, ki, kd); s.umax = umax; s.I = 0.0 def step(s, e, edot, dt): kp, ki, kd = s.k u_raw = -kp*e - ki*s.I - kd*edot u = np.clip(u_raw, -s.umax, s.umax) if u == u_raw or np.sign(e) == np.sign(u_raw): # anti-windup: no sum that deepens the clip s.I += e*dt return u # LQR on the altitude axis A = np.array([[0., 1], [0, 0]]); B = np.array([[0.], [1/m]]) P = solve_continuous_are(A, B, np.diag([10., 0]), np.array([[1.]])) print((B.T @ P).ravel()) # [3.1623 2.5149] # mixer: rotors front, left, back, right; 1 and 3 clockwise cf, cd, L = 1e-5, 1e-6, 0.25 Mix = np.array([[cf, cf, cf, cf], [0, L*cf, 0, -L*cf], [-L*cf, 0, L*cf, 0], [cd, -cd, cd, -cd]]) def rotor_speeds(f, tau): return np.sqrt(np.linalg.solve(Mix, np.r_[f, tau])) print(rotor_speeds(m*g, [0.05, 0, 0])) # [495.2 505.2 495.2 485.0] def position_loop(p, v, pd, vd, ad, psi, R, kx=4., kv=3.): F = -kx*(p - pd) - kv*(v - vd) + m*g*np.array([0, 0, 1]) + m*ad zb = F/np.linalg.norm(F) # desired body z xc = np.array([np.cos(psi), np.sin(psi), 0]) yb = np.cross(zb, xc); yb /= np.linalg.norm(yb); xb = np.cross(yb, zb) return F @ R[:, 2], np.column_stack([xb, yb, zb]) # thrust f, R_d def attitude_loop(R, w, Rd, wd, wd_dot, kR=0.4, kw=0.08): # Lee, Leok, McClamroch 2010 eR = 0.5*vee(Rd.T @ R - R.T @ Rd) ew = w - R.T @ Rd @ wd return -kR*eR - kw*ew + np.cross(w, J @ w) - J @ (hat(w) @ R.T @ Rd @ wd - R.T @ Rd @ wd_dot) f, Rd = position_loop(np.array([0.5, 0, 0]), np.zeros(3), np.zeros(3), np.zeros(3), np.zeros(3), 0., np.eye(3)) print(f, np.degrees(np.arccos(Rd[2, 2]))) # 9.81 N while level, tilt 11.5 deg
This lecture closes the loop on the state the rest of the series estimates. Lecture 4, trajectory optimisation, supplies pd, vd, ad and ψd as smooth minimum-snap paths, the flat outputs this controller needs. The estimators of later lectures supply p, v, R and ω.
Now press Present or Teach. Explain from memory why open loop sinks, how kp and kd set ζ, why the integral winds up, and what Q and R trade. Derive the mixer, the thrust and tilt from an acceleration, and eR for a 30° roll. Then go back to the hero and say why each button ends where it does.