Camera flight.
Follow a learned controller from camera image to thrust. The first flight begins with the window behind the drone.
Loading recorded flights…
Flight replay
Who controls what?
The trained network chooses a direction and how strongly to act. A fixed rule converts its four numbers to a force and a turning torque. MuJoCo computes the resulting motion. The next camera image closes the loop.
- 1 · ObserveCamera · 5 HzRay tracing gives each pixel a brightness from 0 to 255. Furniture is dark, walls are gray and the sky is bright. Neither color commands a move. The policy learns associations from rewards.
- 2 · DecideNeural policy · 5 HzThe policy reads the pooled image and its change. It outputs forward, right, up and turn requests from −1 to +1. Only this stage is learned.
- 3 · ApplyForce rule · 5 HzRotate the request into the room axes, add gravity compensation, limit tilt and thrust, then smooth the force. Hold the force and yaw torque until the next decision.
- 4 · MoveMuJoCo · 50 HzIntegrate translation and yaw under thrust, gravity, damping and contact. The new position and heading determine the next image. Velocity can point away from thrust while braking.
The large view follows recorded physics states every 20 ms with interpolation for display. The grayscale image and commands update every 200 ms. The score and new contacts are reported at the end of each decision. Use ← and → to step between camera samples. At the end, the last force is shown for reference.
Model-free reinforcement learning with a small neural network
Proximal policy optimization (PPO) trains the actor from rewarded experience. A second output estimates future return during training. “Model-free” means PPO learns without a predictive model of the dynamics for planning or gradients. The simulator supplies dynamics. Replays use a frozen actor with exploration noise off. Rewards never enter its camera input. This is sampled output feedback. The policy has only partial information about the state, and the results provide no stability or collision-avoidance guarantee.
For pooled brightness B, the 48 brightness features are B/127.5 − 1. The 48 change features are (B − previous B)/127.5. Positive change means a patch got brighter. At the start, change is zero.
The actor’s 7,204 float32 weights and biases occupy 28.1 KiB. Fixed block averaging feeds two dense tanh layers. There are no learned convolutions or recurrent state. Camera buffers, activations and software need additional memory. Onboard timing and memory use remain untested.
Force law and plant equations
The simulated mass is 1 kg. On the overhead map, +x is right, +y is up the page, +z is height. Heading ψ is clockwise from +y. Let f, r, u and q be forward, right, up and clockwise turn. At rest, zero requests and 9.81 N of vertical thrust balance gravity.
- Orange · thrust and turning torque. Tilting the applied thrust redirects some of it sideways. The outer arc shows the separate torque that changes the turning rate.
- Purple · gravity. Weight pulls straight down at 9.81 N. From above it points into the page (⊗). In steady hover it balances upward thrust.
- Dashed blue · damping. The force −1.5 v opposes motion. The inner arc shows −0.06 ω opposing rotation. Both vanish at rest.
Read the straight arrows as two projections of the same forces. Each pair lists horizontal and vertical components in the labeled axes. The top view magnifies horizontal forces. Longer arrows and larger arc angles mean stronger effects. Tiny arrows can disappear or overlap.
In free flight, the forces add to give mass × acceleration. At impact a surface also pushes on the drone. The replay omits that contact force. The diagram uses the last active sample when the flight ends.
Turning and descending at ½ speed · Braking at ¼ speed · Back to the flight
Fₓ = 4.5 (f sin ψ + r cos ψ)
Fᵧ = 4.5 (f cos ψ − r sin ψ)
Fz = 9.81 + 4uT[k] = 0.4 T[k−1] + 0.6 Flimited[k]
τ[k] = 0.14 q[k] N·mm dv/dt = T − mg ez − 1.5 v
I dω/dt = τ − 0.06 ωFirst shrink the horizontal component if tilt would exceed 30° from vertical. Then scale the whole vector if its length exceeds 1.55 mg × the selected limit. Only thrust has the smoothing term. The resulting world-frame thrust and torque are held constant for up to ten physics steps. MuJoCo adds contact forces when the sphere touches a surface.
Here v is world velocity, ez points upward, ω is clockwise yaw rate and I = 0.01024 kg·m² for the 0.16 m radius sphere. Linear damping is 1.5 N·s/m and yaw damping is 0.06 N·m·s/rad. A 76% limit still allows 11.56 N of thrust. Hover is possible by construction. There is no PID, individual motor control, or roll and pitch state in this model.
Watch braking at 11 seconds in Room 2. Horizontal thrust opposes velocity at this instant. The drone keeps moving as it slows down.
The CSV includes every recorded physics sample. Commands apply from the listed time forward. The terminal row has no outgoing command. On the overhead map, the solid thrust arrow spans 0.30 m per newton and the dashed velocity arrow spans 0.50 m per m/s. Very small arrows are hidden.
Did it find the window?
A smaller window
Clean exits in validation
PPO training loss
From simulation to hardware
The physics model uses a spherical collision envelope, gravity, inertia and a limited thrust vector. Contacts are sampled every 20 ms, so a brief graze can go undetected. The level camera rotates with the drone. The air-density comparison scales the thrust ceiling. It approximates one effect of thinner air. Wind, changing sunlight, camera tilt and motor dynamics are absent here. Performance on a real Crazyflie still needs to be measured.
Crazyflie in Mexico City
At 2,240 m, standard pressure is about 77 kPa. Air density is about 80% of the sea-level value under the standard atmosphere model, or 76% when both sites are at the same indoor temperature. We use these ratios to limit maximum thrust. Actual rotor speed, battery condition, airflow and payload matter too.
The budget target is the Crazyflie 2.1+. Its recommended payload is 15 g. The AI-deck adds 4.4 g, before separate guards. Local loaded hover, braking and camera behavior remain untested. This page replays simulations only.
For hardware, we would retrain the outer policy to request bounded motion setpoints and retain the Crazyflie’s state estimation and fast stabilization loops. A real quadrotor tilts to redirect thrust. Its motors, camera motion and delays need to be modeled and measured. No onboard controller is connected here.
A bright reflection or closed glass pane can look like open sky. Before field trials, vary light, materials and opening sizes, add range sensing for clearance, and compare real recordings offline. Begin with supervised hover in a clear indoor space and a pilot able to take over.