Obstacle avoidance is not a path drawing problem; it is a timed command-selection problem.
A Local Planner With Commitment Issues
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.
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.
- Build a local costmap from recent sensor data.
- Sample velocity commands allowed by current speed and acceleration limits.
- Roll each command forward over a short horizon.
- 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]}")
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.
Tool Workflow
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.
Replay moving obstacles, stale costmaps, delayed transforms, actuator saturation, and local minima. Local planning should fail loudly before it commands unsafe motion.
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.
Freeze controller frequency, velocity limits, acceleration limits, cost weights, obstacle horizon, inflation, and safety stop rules before comparing local planners.
Frontier work is pushing local planning toward risk-aware MPC, social navigation, learned traversability, and fast GPU rollout for dynamic scenes.
Obstacle avoidance is not a path drawing problem; it is a timed command-selection problem.
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.
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.
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.