Artificial potential fields (Khatib, 1986) are the simplest reactive obstacle-avoidance scheme: the goal pulls, every obstacle pushes, and the agent moves along the gradient of the resulting scalar field. The scheme has two virtues: it is closed-form (no planning, no optimisation, just an arithmetic step per timestep) and it generalises trivially to higher-dimensional configuration spaces. It has one well-known vice: the gradient field has spurious local minima where attractive and repulsive forces balance, and the agent stops at any such point. This page demonstrates both behaviours.
The total force on the agent at position p is the sum of an attractive force toward the goal and a repulsive force from each obstacle within an influence radius r∞:
F_attr(p) = −k_attr · (p − p_goal)
F_rep(p) = Σ over obstacles with d_i < r_inf
k_rep · ( 1/d_i − 1/r_inf ) · ( 1 / d_i² ) · (p − p_obs_i) / ‖p − p_obs_i‖
v(p) = clip( F_attr(p) + F_rep(p), v_max )
Implementation: k_attr = 1.0, k_rep = 2.5, r_inf = 1.5, v_max = 1.2 m/s, integrated by forward Euler at dt = 0.05 s. The repulsive term diverges as 1/d² when the agent gets close to an obstacle, which is the behaviour an actual safety-of-life controller wants. But it is also why the agent oscillates if the gain is mistuned.
The reactive controller threads three obstacle layouts where obstacles sit off the direct start-to-goal line. The trajectory bends around each obstacle and snaps back to the goal-direction once clear. Step counts: 212, 206, 211 (out of an 800-step budget).
The same controller in front of a U-shaped obstacle: the cup of the U is a local minimum of the potential field. Attractive force pulls toward the goal on the far side; repulsive forces from the three obstacles balance the attraction. The agent halts before the trap and never reaches the goal. This is intrinsic to the method: the gradient flow on a non-convex potential is incomplete.
The standard fixes are well-known: add a bug-style perimeter-following backup, use a navigation-function potential that is provably free of spurious minima (Rimon and Koditschek, 1992), or escalate to a global planner that reactive control then tracks. The MPC page on this site demonstrates the predictive variant; the A* page shows the global-search variant.