Fall 2026

Fall 2026 · 01

Vision-Based SkyJEPA

A latent world model for a quadrotor. The flight stack logs simulated trajectories, and the model predicts future motion in that latent space.

AI@UNC, with R.A.M. Engineering on the hardware side

GitHub · ai-unc/JEPA-drone

Two pieces

The source is ai-unc/JEPA-drone, package skyjepa 0.1.0. It is a PyTorch world model aimed at a quadrotor, plus the ProjectAirSim client that produces the flights the model trains on. The goal for the semester was to take SkyJEPA, which predicts future latent states from estimated quadrotor state, and move it toward onboard vision. R.A.M. Engineering is the hardware partner. The software in that repository is the simulation, the logs, and the model.

Python is 3.11 or newer. From the repository root, uv sync installs the lockfile. The declared dependencies are NumPy, PyTorch, Matplotlib, pandas, SciPy, json5, and projectairsim==1.0.2. The AirSim server itself is a separate Unreal download. The client talks to a Blocks environment that has to be running first.

The model

Shared defaults live in skyjepa/config.py. State is 18 numbers: position, velocity, the nine entries of the rotation matrix, and angular velocity. Action is four rotor forces, in newtons. The latent size is 24. History H is 10 steps and the horizon T is 10 steps, at dt = 0.05 seconds. Training defaults are batch size 32, learning rate 1e-3, 10 epochs, CPU, and VICReg weights 25, 25, and 1.

Logs are recorded at 100 Hz. The loader keeps every fifth row and averages the four motor thrusts across those rows, which is how a 100 Hz CSV becomes a 20 Hz training series.

What the training loop actually calls

skyjepa/train.py loads every CSV in drone/data_sequences/rnd_sky_training, cuts windows, and trains two temporal convolutional encoders plus a GRU predictor. StateHistoryEncoder maps (batch, H, 18) through channels 8, 8, 16, pools, and projects to the latent. ActionHistoryEncoder does the same from 4 channels through 4, 4, 8. LatentPredictor is a GRUCell: the action latent is the input, the state latent is the hidden state, and the hidden size is 24. It rolls that step out across the horizon.

The loss in skyjepa/losses.py is VICReg: invariance, variance, and covariance, plus checks for dimensional collapse and rank collapse. A checkpoint is written to artifacts/jepa.pt. python -m skyjepa.train baseline trains DirectStatePredictor, one MLP that maps recent state and action history to the next physical state and rolls that out, so the two models can be compared on the same windows. The baseline run also writes artifacts/prediction_error_vs_horizon.png.

skyjepa/train_prober.py is the second stage. It loads a frozen artifacts/jepa.pt, rolls the latent predictor forward under torch.no_grad(), and trains PhysicsProber to turn those latents into physical states. The prober’s MLP emits a 3-vector translational residual and a 3×4 angular map. A differentiable integrator then steps position, velocity, rotation, and body rates. The world frame is NED, so gravity is +g on world z. Rotor thrust points along −R[:, :, 2]. Mass is fixed at 1.22 kg. The randomized per-flight mass from the simulator is not used. The last linear layer is initialized at zero, so training starts from nominal physics and only learns corrections. The loss scales each state dimension by the standard deviation of its one-step change. The default holdout is 20 percent of trajectories, and the weights go to artifacts/prober.pt.

Encoders that are in the tree, and not in that loop

skyjepa/models/encoders.py holds the extra encoders. ProprioceptiveEncoder rewrites position relative to the latest position, runs an MLP with GELU, then a GRU, and projects the final hidden state. Its own default latent size is 32.

ImageEncoder is marked for AirSim, and the docstring says it is not for real-world testing. It expects a 64×64 depth image and a 64×64 segmentation map. Segmentation is one-hot across eight classes: unknown, wall, floor, ceiling, door, window, furniture, obstacle. A small CNN maps the stacked tensor to a latent of size 32.

TextEncoder loads Qwen/Qwen3-0.6B through Hugging Face transformers and freezes it. A command is parsed into JSON with an intent, an object, an optional [x, y, z] target, and a preference of nearest, farthest, or none. Intents are move_relative, move_absolute, exit_room, hover, land, explore, approach_object, and other. Relative coordinates are X forward, Y right, Z down. Absolute coordinates are the AirSim NED frame. The structured goal is 23 numbers. A mean-pooled hidden state is concatenated onto it. transformers is not in the core pyproject.toml dependency list, so this class does not import in the base environment.

MultimodalEncoder concatenates an image latent, a proprioceptive latent, and a state vector, then maps them with an MLP to 128 dimensions. train.py does not call it. The dynamics model that actually trains is still state history, action history, and the GRU.

The flight stack

drone/ is the ProjectAirSim client. The simulator clock is steppable, with 1 ms steps, and the controller runs at 100 Hz, so lag in the Unreal window does not change the logged dynamics. Each logged row is 23 columns: time, four thrusts, position, velocity, the rotation matrix, and angular velocity.

A flight can randomize six simulator settings: mass, arm length, thrust coefficient, torque coefficient, motor time constant, and drag. Controllers stack. A physics-based autotuner sets rate-controller gains from the simulation config. Attitude, velocity, and position controllers sit on top of that, and they are not retuned per config because the rate loop already absorbed it. Upside-down flight is rejected. The validation script throws out logs with numerical blowups or tilt past 60 degrees, and it can skip files it has already checked.

The documented log sets are 200 random-thrust flights on nominal physics (rnd_sky_training), 200 random-thrust flights with a new physics draw in each file (rnd_configs_rnd_action_training, some of which blow up), 28 manual gamepad flights with random physics, and 2 manual flights on the default drone. waypoint_flight.py flies a position controller between waypoints for autonomous collection. gamepad_flight.py maps a USB controller through PID loops. custom_flight.py replays a CSV.

drone/simulations/obstacle_course.py places cubes, spheres, cylinders, and a cone goal on a flat map, in meters, NED, with roll, pitch, and yaw in degrees. After a flight it can write that layout into the CSV comment header so a later run can rebuild the same course. The pandas reader ignores lines that start with #.

How to run it

uv sync
python -m skyjepa.train jepa
python -m skyjepa.train baseline
python -m skyjepa.train_prober

The prober needs artifacts/jepa.pt from the first command. docs/tensor_shapes.md is called out in the repository README as likely out of date. setup.md still tells you to run python -m skyjepa.train_jepa. That module name is not the training entry point. The entry point is skyjepa.train.

Tests that are in the tree are tests/test_physics_prober.py and tests/test_validate_input_data.py.

Still open

The repository README still marks both skyjepa/ and drone/ as work in progress. The trained dynamics model does not yet take the image encoder, the text encoder, or the multimodal encoder as input. Embedded deployment on a Radxa Zero 2 Pro, which was the hardware step with R.A.M. Engineering, is outside this repository.