Technology · Science
MySimulation
A browser-based 6-DOF flight dynamics simulator for small unmanned aircraft — the same equations of motion I use to sanity-check MyDrone and MyTwin-Boom, following Randal W. Beard and Timothy W. McLain's Small Unmanned Aircraft: Theory and Practice.
Why I built it
Understanding a textbook's equations properly means implementing them, not just reading them. MySimulation keeps a Python package and a hand-ported JavaScript twin in lockstep — a golden test runs both on the same inputs and checks they agree, so the browser version is never quietly wrong.
It follows chapters 2 to 4 of Small Unmanned Aircraft: Theory and Practice by Randal W. Beard and Timothy W. McLain (Princeton University Press, 2012): rigid-body kinematics, forces and moments, and the 6-DOF equations of motion used throughout the rest of the book.
Some of the mathematics
From body frame to the world.
Every airframe is a set of vertices in its own body frame. To draw it in the world, each vertex is rotated into the inertial (NED) frame and translated to the aircraft's position.
Rotation — chapter 2
Rbi(φ,θ,ψ) = Rz(ψ)·Ry(θ)·Rx(φ), built from roll φ, pitch θ and yaw ψ.
Translational kinematics — eq. 3.14
ṗ = Rbi(φ,θ,ψ)·[u, v, w]T, position rate from body-frame velocity.
Translational dynamics — eq. 3.15
Body-frame velocity rates from body rates p, q, r and forces fx, fy, fz, divided by mass.
Rotational kinematics & dynamics — eq. 3.16–3.17
Attitude rates from p, q, r; and ṗ, q̇, ṙ from the moments l, m, n and the Γ coefficients built from Jx, Jy, Jz, Jxz.
Gravity in body axes — chapter 4, eq. 4.2
fgravity = mg·[−sinθ, cosθsinφ, cosθcosφ]T, optional in the Simulate tab.
Reference aircraft — appendix E
Try it
Drag to orbit, switch airframes, press play.
Pose mode sets attitude and position directly. Simulate mode drives the aircraft with body forces and moments through the equations of motion above, integrated with RK4.
Source & reference
Reference: Randal W. Beard and Timothy W. McLain, Small Unmanned Aircraft: Theory and Practice, Princeton University Press, 2012. Equation numbers above refer to that edition; all code here is my own implementation of the ideas it describes.