Two families of planner, one job
Getting a drone from A to B through obstacles is the motion planning problem, and almost every solution belongs to one of two families. Sampling-based planners build a discrete graph of feasible states by randomly sampling the free space and connecting nearby samples; reactive planners compute a force or gradient at the drone's current position and follow it, one instant at a time, with no map of the whole space. RRT* is the workhorse of the first family, artificial potential fields the classic instance of the second, and this simulation runs both on the same 3D obstacle field so you can watch the trade-off directly.
RRT*: growing a tree toward the goal
Rapidly-exploring Random Trees (RRT, LaValle 1998) build a tree rooted at the start pose. Each iteration samples a random point in the 3D volume, finds the nearest existing tree node, and extends a fixed-length step from that node toward the sample. If the new edge is collision-free it joins the tree. Repeat for a few thousand iterations and the tree's leaves are, with high probability, dense enough that one of them is close to the goal.
loop:
x_rand = sample_free_space()
x_near = nearest(tree, x_rand)
x_new = steer(x_near, x_rand, step) // move one fixed step toward x_rand
if collision_free(x_near, x_new):
tree.add(x_new, parent = x_near)
if in_goal_region(x_new): done
Plain RRT finds a path fast, but it is rarely a good one — it zig-zags because it never revisits a decision. RRT* (Karaman & Frazzoli, 2011) fixes this with two extra steps at every iteration: when a new node is added, it looks at all tree nodes within a shrinking radius and (1) picks the parent among them that gives the cheapest path from the root, then (2) rewires any of those nearby nodes through the new node if that lowers their own cost. This local re-optimisation, repeated over thousands of samples, provably converges to the shortest collision-free path as the sample count grows — RRT* is asymptotically optimal, plain RRT is not.
The cost is more bookkeeping per iteration (a nearest-neighbour and a radius query instead of one), which is why practical implementations keep tree nodes in a k-d tree rather than a flat array — without it, each of those queries degrades to O(n) and the whole planner becomes O(n squared) over a run.
Potential fields: no planning, just gradient descent
Artificial potential fields (Khatib, 1986) skip the graph entirely. The goal exerts an attractive potential that pulls the drone toward it like a valley; every obstacle exerts a repulsive potential that pushes the drone away, strong up close and vanishing beyond a safety radius. At every instant the drone simply flies down the combined gradient — no tree, no memory of the space, negligible compute per step, which is why it is the default choice for a real quadrotor's fast inner control loop reacting to a lidar it just read.
F_total(x) = -grad(U_attract(x)) - sum_i grad(U_repel_i(x)) U_attract(x) = 0.5 * k_att * ||x - x_goal||^2 U_repel(x) = 0.5 * k_rep * (1/d(x) - 1/d0)^2 if d(x) < d0, else 0
The catch is the reason this demo pairs the two methods: a purely reactive controller has no lookahead, so it can be trapped in a local minimum — a point where the attractive pull toward the goal is exactly cancelled by the repulsive push of a concave obstacle, such as the inside of a U-shaped wall. The drone sits there, net force zero, goal unreached, no matter how long you wait. Sampling-based planners do not have this failure mode because they explore the whole space rather than descending a single scalar field; the price is that RRT* needs a global map up front and takes measurably longer to produce a path.
What real UAV stacks actually do
Production autonomy stacks rarely pick one and discard the other. A common architecture runs a sampling-based or search-based global planner (RRT*, or a lattice/A* variant) at a low rate over the known map to produce a coarse waypoint corridor, and a fast reactive layer — potential fields, or its smoother cousin velocity obstacles — for local, high-rate collision avoidance against obstacles the global map does not yet know about. The global planner supplies the lookahead that escapes local minima; the reactive layer supplies the millisecond reaction time a moving obstacle or a global replanning cycle cannot.
The other practical detail is kinodynamic feasibility: a quadrotor cannot instantaneously change velocity or turn on a dime, so a raw RRT* path built from straight-line steers must be smoothed and re-parametrised against the vehicle's actual acceleration limits (typically with a minimum-snap or minimum-jerk trajectory fit) before it is flyable. A geometrically shortest path is not the same as a flyable one.
Frequently asked questions
Why does the potential-field demo sometimes get stuck?
It has fallen into a local minimum: a point where the goal's attractive pull is exactly balanced by the repulsion of nearby obstacles, typically inside a concave, U-shaped obstacle. Reactive controllers have no memory of the wider map, so nothing pulls the drone out. Switching to RRT*, which explores globally, avoids this failure mode entirely.
Does RRT* find the shortest possible path?
It converges to the optimal path as the number of samples goes to infinity — it is asymptotically optimal, not instantly optimal. With a finite sample budget you get a path that is usually close to shortest and gets closer the longer the tree grows, thanks to the rewiring step that continually re-optimises nearby connections.
Which method is faster to compute?
Potential fields, by a wide margin — one gradient evaluation per step, no tree, no memory of the whole space, which is why it suits a fast reactive control loop. RRT* needs thousands of samples, nearest-neighbour queries and rewiring passes, but in exchange it produces a globally consistent, near-optimal path that cannot get trapped.
Try it live
Everything above runs in your browser — open UAV Path Planning and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open UAV Path Planning simulation