Journal

The big idea: a small computer that flies the drone 400 times a second

Watch: what a Pixhawk does 400 times a second

Pick up a quadcopter and try to hover it by hand: you cannot. A quad has no natural stability. Tilt it by one degree and the thrust starts pushing it sideways; a gust rolls it over in a fraction of a second. No human can adjust four motor speeds fast enough. A flight controller can.

A Pixhawk is an open-hardware flight controller about the size of a deck of cards. It runs open-source flight software, PX4 or ArduPilot, and does the same four jobs again and again, 400 times a second by default on both:

  1. Sense: read the gyroscope (how fast it is rotating), the accelerometer (which way gravity pulls), and the compass, barometer and GPS.
  2. Estimate: combine them into a best guess of the drone’s attitude (roll, pitch, yaw), and its height and position.
  3. Control: compare that guess with what the pilot or the mission wants and work out how much turning effort (torque) is needed.
  4. Act: share that effort out between the motors (the mixer) and send each ESC a new speed command.

One number, one loop

Say the pilot pushes the roll stick for a 15° bank and the drone is still level. The outer angle loop turns the angle error into a rotation rate to aim for. With PX4’s default gain MC_ROLL_P = 4:

\[\omega_{sp} = K_{\phi}\,(\phi_{sp} – \hat\phi) = 4 \times 0.262\ \text{rad} = 1.05\ \text{rad/s} = 60^\circ/\text{s}\]

The inner rate loop, a PID controller fed by the gyro, then pushes the left motors up and the right motors down until the drone really rolls at that rate. As the angle approaches 15°, the requested rate shrinks to zero and the drone stops there. In the simulation this takes half a second.

Why two sensors and two loops

  • The gyro is smooth and fast but has a small bias. Integrate it to get an angle and the error grows forever: 0.5°/s of bias is 9.4° of tilt after 20 seconds.
  • The accelerometer knows where “down” is, so it never drifts, but motor vibration makes it noisy: about 9° of jitter in our example.
  • A complementary filter trusts the gyro over short times and the accelerometer over long times, and gets the best of both: 0.4° error.
  • The fast rate loop fights gusts within milliseconds; the slower angle loop brings the drone back to level. Remove the angle loop and the same gust leaves the frame tilted.

What this course gives you

You will learn what is on the board and what plugs into every port, how to wire a quad and flash PX4 or ArduPilot, the calibration order, flight modes, failsafes, the pre-arm errors that stop you arming, and how to read a log after a bad flight. Then you build the flight stack yourself in Python and break it on purpose.

Keep the loop in mind: sense → estimate → control → mix → act. Every port, parameter and log plot in this course belongs to one of those five boxes.

Log in or create a free account to save your progress.

Enjoyed the preview? Unlock the full course.

₹199 ₹599 67% off
Create free account to enrollLog in

Lifetime access to every lesson, the equations and the downloadable Python simulation. Your progress is saved to your account.

Pay securely with UPI, cards, netbanking or wallets through Razorpay. The course unlocks instantly.

By enrolling you agree to our Terms, Refund policy and Privacy policy.

All lessons
  1. The big idea: a small computer that flies the drone 400 times a second▶ VideoFree preview
  2. How it was invented and its first uses▶ VideoLocked
  3. Where it is used today: boards, ports, wiring and the two firmware stacks▶ VideoLocked
  4. The equations▶ VideoLocked
  5. Worked demo and tuning: one loop by hand, then a real Pixhawk from box to first hover▶ VideoLocked
  6. Build your own, step by step▶ VideoLocked
  7. Python simulation labLocked
  8. Practice problems and quizLocked

We’ll drive a rover into your seminar hall. The demo is free.

A 45-minute session with a live rover drive and a drone flight in a netted cage, for any engineering college in Kerala or Tamil Nadu.