The 3D version flies a quadrotor through 3D space and renders one blended flight horizon with a camera. This 2D version keeps the exact same control algorithm — sampling-based Model Predictive Path Integral control (MPPI) on a planar double-integrator drone — but computes and draws it as a genuinely 2D object: the reference path, obstacle and drone all live in a flat plane, and instead of hiding the sampling process behind a single result, every one of the K sampled rollouts is drawn, each faded by its own softmax importance weight:
p_(t+1) = p_t + v_t·dt
v_(t+1) = v_t + u_t·dt, |u_t| ≤ u_max (per-axis clamp)
J(U) = Σ_(t=0)^(N-1) [ w_track·‖p_t − p_ref(t)‖² + w_u·‖u_t‖² + obstacle penalty ]
w_k = exp(−(J_k − J_min) / λ)
u*_t = Σ_k w_k·u_(k,t) / Σ_k w_k
Only u*_0 ever gets executed (receding horizon); the rest warm-starts the next replan, exactly as in the 3D controller. What's new here is a direct, 2D-native diagnostic of the importance-sampling math itself: a live weight histogram along the bottom of the canvas shows the raw softmax weight of every rollout sorted high→low, and the effective sample size readout, ESS = 1 / Σ w_k², reports how many of the K samples are actually contributing to the blended control — it collapses toward 1 when one rollout dominates (e.g. hugging the obstacle boundary) and rises toward K when the population is roughly uniform.
- Prediction horizon N — steps planned ahead each replan; longer horizons anticipate the obstacle earlier but cost more to sample.
- Rollout samples K — more samples approximate the optimal control distribution more accurately, and widens the sample cloud drawn on screen.
- Obstacle avoidance weight — scales the penalty for entering the obstacle's safety margin; push it high and watch the cloud's weight collapse onto the handful of rollouts that swerve hardest.
- Lissajous 3:2 — a genuinely 2D reference curve (frequency ratio 3:2 between the two axes) that the 3D version can't draw the same way, since it needed a third (altitude) axis to make its Lissajous path non-planar.