Agents using ORCA local avoidance jam and stand still at a stadium's single exit gate; why does reciprocal avoidance deadlock there, and how would you fix it?
answer
- safe velocities, not progress
- each agent takes half
- half-planes plus a speed disc
- symmetry and over-constraint
- fix the preferred velocities upstream
basics
~20 sORCA targets collision avoidance, not progress: each agent takes the allowed velocity nearest its preferred one, and a dense, symmetric press at one gate leaves only near-zero options. Break symmetry, spread goals across the gate, shorten the horizon.
solid answer
~50 sA **velocity obstacle** is the set of velocities that would hit a neighbour within a time horizon `tau` if the neighbour kept its velocity. Dodging all of it makes both agents overcorrect, so reciprocal methods split the work. **ORCA** finds the smallest change `u` that moves the relative velocity out of the obstacle; each agent takes half, giving a half-plane of allowed velocities through `velocity + u / 2`. The agent intersects one half-plane per neighbour with its speed limit and solves a small linear program for the velocity nearest its **preferred velocity**. At one gate every preferred velocity points at one spot, so agents pack in, the allowed region shrinks toward zero, and mirrored pairs keep yielding to each other. Fixes: aim agents across the gate's width or use a flow field, perturb preferred velocities slightly, give agents in the doorway less responsibility, shorten `tau` in dense areas, and detect stalls.
go deeper
Recall that local avoidance picks a safe velocity near the preferred one each tick, and that a route planner, not avoidance, supplies the direction to go.
Explain the velocity obstacle, why splitting responsibility in half stops oscillation, and how ORCA builds half-planes and solves for the nearest allowed velocity.
Diagnose a jam from preferred and chosen velocities, name symmetry, over-constraint and converging goals, and fix it at the right layer.
Decide where crowd flow is the level designer's problem, gate widths and exits, and where it is the avoidance system's, and budget agent counts accordingly.
## From velocity obstacles to ORCA Local avoidance works in **velocity space**: instead of asking where to go, it asks which velocities are safe for the next few seconds. 1. **Velocity obstacle (VO).** For agent A and a neighbour B, both modelled as discs, the VO is every velocity of A that brings the discs into contact within a **time horizon** `tau`, assuming B keeps its current velocity. In relative terms it is a cone of velocities aimed at a disc of radius `rA + rB` around B, cut off near its apex so that contacts later than `tau` do not count. Picking a velocity outside it is safe against that one neighbour. 2. **The reciprocal dance.** If both agents treat the other as unresponsive, both dodge fully. Next tick each sees the path clear and returns to its preferred velocity, which is on a collision course again, so they oscillate. 3. **RVO** fixes this by assuming the other agent will do half the work, so each dodges half as much. 4. **ORCA** turns that into constraints. It computes `u`, the smallest change that moves A's velocity relative to B out of the VO, and the outward normal `n` at that point. A's allowed velocities form the **half-plane** of velocities `v` with `dot(v - (vA + u / 2), n) >= 0`. B gets the mirror constraint, and together the two changes cover all of `u`. Static obstacles do not move, so the agent takes **full** responsibility for them. ## One ORCA step 1. Each agent sets a **preferred velocity** from its global goal, at its preferred speed. 2. It builds one half-plane per nearby agent and per nearby obstacle segment. 3. It intersects them with a disc of radius `maxSpeed`. 4. A 2D linear program, solved incrementally in expected linear time in the number of constraints, finds the allowed velocity closest to the preferred one. 5. If no velocity satisfies every half-plane, a fallback picks the velocity that violates the worst constraint the least. Under its assumptions, all agents running ORCA and able to adopt any velocity instantly, and as long as the linear program is feasible, this keeps agents from colliding within the horizon. Nothing in it rewards reaching the goal except closeness to the preferred velocity. ## Why one gate deadlocks - **Converging preferences.** If every preferred velocity points at the gate's centre, agents pack into a dense wedge with neighbours on all sides. The intersection of their half-planes shrinks to a sliver around zero, and the closest allowed velocity is nearly a standstill. - **Symmetry.** Two agents shoulder to shoulder at the opening each yield half to the other. The method is deterministic, so the mirrored choice repeats every tick and neither enters. - **A long horizon.** Each neighbour's VO grows with `tau`; in a dense crowd a long horizon over-constrains everyone and drives agents into the fallback. - **Gate posts.** The walls beside the opening add full-responsibility constraints exactly where space is tightest. - **Body limits.** Characters with acceleration or turning limits cannot take the chosen velocity at once, so small errors accumulate into shoving and jitter. ## Fixes, by layer | Layer | Fix | Why it helps | |---|---|---| | Goal | aim each agent at the nearest point on the gate's width, or follow a flow field | agents spread across the opening instead of converging on one point | | Goal | add crowd density to the route cost, or open alternative exits | fewer agents compete for the same space | | Avoidance | tiny random perturbation of preferred velocities | breaks mirrored, deterministic choices | | Avoidance | asymmetric responsibility | the agent already in the doorway yields less, so someone commits | | Avoidance | shorter horizon in dense areas | a larger allowed region, at the cost of later, sharper reactions | | Behaviour | stall detection | after a few seconds near zero speed, queue, wait or pick another goal point | ## Where planning ends and avoidance begins 1. A route planner or flow field gives the global direction, which becomes the preferred velocity. 2. Local avoidance adjusts it to a collision-free velocity against nearby agents and walls. 3. Steering closes the gap between the current and the new velocity within the agent's limits. 4. The character controller or physics moves the body and resolves any contact that still happens. Avoidance never searches for a route and cannot escape a dead end; the planner never sees other agents tick by tick. A jam at a gate is usually a problem between layers 1 and 2. ## Diagnosing it - Draw each agent's preferred and chosen velocity; a jam shows long preferred arrows and near-zero chosen ones. - Count agents that fell back to the infeasible case each tick. - Plot speed and density as a heat map around the gate. - Look for mirrored pairs at the opening, the signature of symmetry.
- Why does plain velocity-obstacle avoidance make two agents oscillate when they meet head-on?Each assumes the other will keep its velocity, so both dodge the full amount. On the next tick each recomputes against the other's new, dodging velocity, finds its preferred velocity safe again and returns to it, which puts them back on a collision course. Reciprocal methods assume each side does half, so the two dodges add up to just enough and stay stable.
- What does ORCA do when the half-planes leave no common velocity, and why should you watch for it?It falls back to a second linear program that picks the velocity whose worst constraint violation is smallest: the least-bad option. Collisions are then possible, and the chosen velocity is often close to zero in a dense press. The share of agents taking this fallback each tick is a good health metric for crowd density and horizon settings.
Two people meeting in a corridor who both step to the same side, then both step back, are the symmetric deadlock; it ends when one of them commits to a side and the other follows, which is what a small random nudge or an agreed priority does for ORCA agents.
- ORCA guarantees every agent eventually reaches its goal.
- Each agent should dodge the full amount, assuming the neighbour keeps its velocity.
- A longer time horizon always makes crowds flow more smoothly.
- Local avoidance will find its own way out of a dead end.
- A gate jam must be fixed inside the avoidance solver alone.