Section 30.4: Local planning and obstacle avoidance (DWA, potential fields)

Obstacle avoidance is not a path drawing problem; it is a timed command-selection problem.

A Local Planner With Commitment Issues
Educational illustration for Section 30.4, showing local planning and obstacle avoidance as a robot reasoning problem that connects measurements, state estimates, decisions, and replayable evidence.
Figure 30.4.1: Local planning and obstacle avoidance becomes useful when the visual idea is tied to a state variable, an uncertainty model, and the next robot action.
Big Picture

Local planning and obstacle avoidance turns maps and goals into constrained motion. The planner is not searching for a pretty line; it is choosing a feasible commitment under geometry, dynamics, uncertainty, moving obstacles, and recovery rules.

Problem First

A global path is too coarse for the next second of motion. The robot still has to choose velocities that avoid nearby obstacles, respect acceleration limits, and remain trackable by its controller.

Dynamic Window Approach samples feasible velocity commands and scores their short rollouts. Potential fields define attractive and repulsive forces but can get trapped in local minima. Modern local planning combines costmap scoring, trajectory rollout, and controller constraints.

Feasibility Before Beauty

A local planner is good when its rejected commands are as explainable as its chosen command.

Formal Model

Most navigation methods can be read as constrained search or optimization:

$$ u^*=\arg\min_{u\in\mathcal U_{\mathrm{dyn}}}\alpha d_{\mathrm{goal}}+\beta c_{\mathrm{obstacle}}+\gamma e_{\mathrm{path}} $$

The objective is short-horizon progress; constraints are collision clearance, velocity, acceleration, curvature, obstacle prediction, and emergency stop authority.

Algorithm: Section 30.4 Planning Loop
  1. Build a local costmap from recent sensor data.
  2. Sample velocity commands allowed by current speed and acceleration limits.
  3. Roll each command forward over a short horizon.
  4. Reject collisions and choose the lowest scored command with enough clearance.

Worked Diagnostic

Code Fragment 1 isolates local-planner scoring: candidate command, obstacle clearance, progress term, and dynamic feasibility. The point is to make command rejection inspectable.

# Score three local velocity commands.
# The selected command balances goal progress and obstacle clearance.
candidates = [
    {"v": 0.6, "goal": 2.0, "clearance": 0.20},
    {"v": 0.4, "goal": 2.4, "clearance": 0.55},
    {"v": 0.2, "goal": 3.0, "clearance": 0.80},
]
scores = []
for c in candidates:
    score = c["goal"] + 1.5 / c["clearance"] - 0.3 * c["v"]
    scores.append((round(score, 2), c["v"]))
print(scores)
print(f"command_v={min(scores)[1]}")
[(9.32, 0.6), (4.97, 0.4), (4.82, 0.2)] command_v=0.2

Expected output interpretation. The smallest score belongs to the slowest command because clearance dominates goal progress in this local decision. That is the intended interpretation of the output: when hazards are near, the local planner should sacrifice speed first, rather than preserving nominal throughput at the cost of safety margin.

Code Fragment 1: The local scorer penalizes low clearance strongly enough to choose the slower command. This is the behavior a field robot needs when the global route passes near a hazard.

Tool Workflow

Library Shortcut

Nav2 controller plugins, MPPI controllers, Regulated Pure Pursuit, and DWB controllers package local rollout and tracking behavior. The maintained path handles costmap integration, velocity limits, plugin loading, and behavior-tree coordination.

Keep the small DWA or potential-field fragment as a test for cost terms and constraints. Use Nav2 controllers and behavior trees when deploying on a full robot.

Failure Mode To Test

Replay moving obstacles, stale costmaps, delayed transforms, actuator saturation, and local minima. Local planning should fail loudly before it commands unsafe motion.

Practical Example

Log local costmap, candidate velocities, selected command, obstacle distances, tracking error, and recovery state. Those fields separate a bad local planner from bad perception or global routing.

Integration Checklist

Freeze controller frequency, velocity limits, acceleration limits, cost weights, obstacle horizon, inflation, and safety stop rules before comparing local planners.

Research Frontier

Frontier work is pushing local planning toward risk-aware MPC, social navigation, learned traversability, and fast GPU rollout for dynamic scenes.

Memory Hook

Obstacle avoidance is not a path drawing problem; it is a timed command-selection problem.

Self Check

Can you state the search space, cost function, constraints, replanning trigger, controller interface, and failure metric for local planning and obstacle avoidance? If not, the planner is not specified enough to deploy.

Key Takeaway

Local planning and obstacle avoidance is ready for embodied use when route quality, dynamic feasibility, local control, and recovery behavior are measured in the same replay.

Exercise 30.4.1

Run the panel with pedestrian crossing, sudden obstacle, and narrow doorway. Report minimum clearance, command oscillation, controller saturation, stop distance, and recovery trigger.

What's Next?

Continue to Section 30.5: Learned navigation policies, where this planning contract connects to the next embodied capability.

Section References

LaValle, S. M. "Planning Algorithms." Cambridge University Press, 2006. http://lavalle.pl/planning/

Open textbook reference for graph search, sampling-based planning, configuration spaces, and kinodynamic planning.

OMPL Project. "Open Motion Planning Library." Official documentation. https://ompl.kavrakilab.org/

Primary tool reference for sampling-based planners such as RRT, RRTstar, PRM, and kinodynamic variants.

ROS 2 Navigation Project. "Nav2 documentation." Official documentation. https://navigation.ros.org/

Primary documentation for global planners, controllers, costmaps, behavior trees, and recovery behaviors.