Local Planners: DWA, TEB, and Real-Time Obstacle Avoidance
The local planner is where theory meets friction — DWA samples velocity space and TEB optimizes an elastic band, and both fail when the obstacle is faster than the replan rate.
🎯 By the end you'll understand
What the dynamic window is and why velocity constraints from kinematics, dynamics, and obstacle clearance all collapse into a single 2D region. How DWA's scoring function evaluates velocity samples along three axes — heading, clearance, and forward velocity. What TEB does differently: treating the trajectory as a sequence of timed poses and optimizing the whole thing. When each planner wins, and when each one oscillates, stalls, or freezes. How to configure DWA for FollowBot's differential-drive constraints and why narrow corridors expose the deepest flaw in velocity-space sampling.
KEY INSIGHTLocal planning is a real-time constraint-satisfaction problem in disguise
The global planner computed a beautiful path through the room. The local planner's job is to execute it in a world that moved since the computation finished.
Stage 3 taught you that MPC recedes its horizon at every timestep to absorb constraint violations the original plan didn't anticipate. Local planning is exactly this, applied to navigation: the global planner (A*, Dijkstra, RRT*) finds a path on a static map snapshot, and the local planner continuously re-solves a short-horizon problem as the costmap updates with fresh sensor data. If the global plan is the route you filed with air traffic control, the local planner is the turbulence avoidance your autopilot is doing every 100 ms.
A local planner has exactly one output: a velocity command, usually geometry_msgs/Twist on /cmd_vel. Everything else — obstacle detection, costmap maintenance, global path management — is upstream infrastructure. The planner's job is to pick the best (v, ω) pair this planning cycle, where "best" means "follows the global path, avoids obstacles, and is physically achievable in the next timestep." Those three constraints are the entire problem, and DWA, TEB, and their relatives are different strategies for solving it quickly enough to run at 10–20 Hz.
HOW IT WORKSThe dynamic window: three constraints collapsed into one region
The Dynamic Window Approach, introduced by Fox, Burgard, and Thrun in 1997, begins with a key observation: you cannot ask "which velocity commands avoid obstacles?" without first constraining which velocity commands are achievable. A robot with limited acceleration cannot jump from 0 m/s to 1 m/s in a single 100 ms control cycle. The set of velocities reachable in one timestep, given the current velocity, is the dynamic window.
Three constraint sets intersect to define it:
Robot velocity limits (Vs)
The robot has hard limits on translational velocity v and rotational velocity ω from hardware: motor stall current, safety limits, mechanical bearing ratings. For FollowBot: v ∈ [−0.3, 1.2] m/s (forward and limited reverse), ω ∈ [−2.0, 2.0] rad/s. This is a rectangle in velocity space — the global constraint set Vs.
Kinodynamic reachability (Vd) — the actual "window"
From the current velocity (vc, ωc), the robot can only reach velocities within ±amax·dt in the next timestep. If current v = 0.4 m/s, max acceleration av = 1.0 m/s², and dt = 0.1 s, then reachable v ∈ [0.3, 0.5] m/s. This is the dynamic window — it shrinks toward a point at current velocity as the timestep dt shortens and shrinks as the robot approaches a wall (because deceleration constraints tighten). Mathematically:
Vd = { (v, ω) | v ∈ [vc − av·dt, vc + av·dt], ω ∈ [ωc − aω·dt, ωc + aω·dt] }
Admissible velocities (Va) — fast enough to stop before an obstacle
A velocity is admissible if the robot can decelerate to zero before hitting the nearest obstacle on the circular arc that velocity traces. For a circular arc with curvature κ = ω/v, the stopping distance is v²/(2·av). If the obstacle clearance along that arc is dist(v, ω), then admissibility requires: v ≤ √(2 · dist(v, ω) · av). This constraint prunes velocities that would commit the robot to a collision regardless of future commands. It is the safety envelope, not a soft cost.
The intersection Vs ∩ Vd ∩ Va is the admissible dynamic window. DWA samples this region (typically on a grid of 20×20 to 40×40 candidates), evaluates each candidate with a scoring function, and commands the highest-scoring admissible velocity. If the window is empty — no velocity is simultaneously reachable, within limits, and guaranteed collision-free — the robot cannot find a valid command. It sends zero velocity and declares a local planner failure.
CORE CONCEPTThe scoring function: heading, clearance, velocity
Fox et al.'s original scoring function combines three sub-objectives. Each is computed for the robot's pose at the end of a short simulation rollout (typically 1–3 s of forward simulation on the circular arc produced by constant (v, ω)):
| Component | Formula | Meaning | Pathology when over-weighted |
|---|---|---|---|
| Heading α·heading(v,ω) | π − |θ_goal − θ_end| | How well the simulated arc's endpoint faces the goal direction | Robot takes aggressive shortcut arcs, cuts corners, clips obstacles |
| Clearance β·dist(v,ω) | min obstacle distance along arc | How much free space the trajectory maintains from obstacles | Robot creeps far from walls; gets stuck when any path is tight |
| Velocity γ·vel(v,ω) | v / v_max | Normalized forward speed — penalizes stopping or near-zero commands | Robot always charges ahead even when clearance is marginal |
The composite score is: G(v, ω) = α · heading + β · dist + γ · vel, where α, β, γ are weights summing to 1 (or normalized to 1 in practice). The algorithm:
- Compute the admissible dynamic window given current (v, ω) and amax, dt.
- Sample N×M candidate pairs uniformly inside the window.
- For each candidate, simulate the arc over a horizon Tsim; discard inadmissible candidates; score the rest with G.
- Command the (v*, ω*) with the highest score.
A short horizon (Tsim = 0.5 s) means the robot only looks ahead 0.5 s × v m/s. At 0.8 m/s that is 0.4 m — barely past the robot's footprint. It reacts to immediate obstacles but ignores a wall 2 m away. A long horizon (Tsim = 3 s) sees the wall but costs more compute and may simulate arcs that are never actually feasible end-to-end. Nav2's DWB (the evolution of DWA used by Nav2) defaults to 1.7 s and allows per-critic horizon tuning. Get this wrong and the oscillation behavior described in the weakness section below appears immediately.
SEE ITDWA velocity space explorer
Explore how the admissible dynamic window responds to robot constraints and obstacle proximity. Set the robot's dynamic limits, drag the obstacle slider closer, and watch the feasible window shrink. Change the goal direction and see how the scoring changes the selected command. Finally, toggle the narrow corridor scenario to observe DWA's oscillation pathology firsthand.
Notice how bringing the obstacle within ~0.4 m completely collapses the admissible window — Va prunes all velocities that cannot stop in time. With the narrow corridor scenario active, the window is constrained from both sides simultaneously, and the highest-scoring sample oscillates between slight left and right turns rather than converging on a forward command. This is DWA oscillation in its minimal form.
CORE CONCEPTTEB: trajectory as an elastic band with time constraints
The Timed Elastic Band (TEB) planner — Rösmann et al., 2013 — takes a fundamentally different approach. Instead of sampling a single velocity command per cycle, TEB represents the entire planned path as a sequence of timed poses: (x₁, y₁, θ₁, Δt₁), (x₂, y₂, θ₂, Δt₂), …, (x_n, y_n, θ_n). The time stamps are part of the optimization; the planner decides not just where to go but how long each segment takes.
This formulation lets TEB express kinematic and dynamic constraints as penalty terms in a single nonlinear optimization problem (solved via the g2o sparse graph optimizer):
Path fidelity
Elastic-band spring terms pull the trajectory toward the global path reference, preventing the local planner from diverging far from the global plan. These are soft constraints — the band can stretch past narrow passages but snaps back to the reference in open space.
Obstacle repulsion
Costmap obstacle distances add repulsive potential terms at each pose. Unlike DWA's binary admissibility cut (safe vs. unsafe), TEB's obstacle terms are smooth gradients — the trajectory is continuously nudged away from obstacles. This allows TEB to navigate gaps that DWA cannot, because TEB can distort the path geometry to thread the gap rather than sampling a fixed arc through it.
Kinematic consistency
Consecutive poses must be reachable: the velocity implied by (Δposition / Δt) must fall within v_max, and similarly for ω. TEB enforces these as inequality constraints in the optimization. The Δt parameters adapt: the planner allocates more time to tight turns and less to straight segments.
Minimum time (velocity objective)
A time-minimizing objective biases the optimizer toward shorter Δt values — faster traversal. Combined with the kinematic constraints, this drives the robot toward its velocity limits in open corridors while automatically slowing in tight spaces. This is the TEB analog of DWA's velocity scoring term, but globally consistent across the trajectory rather than myopically single-step.
The result: TEB issues a command sequence (not a single velocity pair), and the first pose-to-pose Δt yields the current cycle's (v, ω) command. If the optimizer converges, TEB produces a smoother, more geometrically aware path than DWA. If it doesn't converge within the replan budget (typically 10 ms per cycle), the previous solution is reused — a subtle staleness failure mode the DWA literature does not share.
TEB's underlying optimizer is g2o (General Graph Optimization), a C++ framework that exploits the sparse structure of the Jacobian when solving large least-squares problems. For a TEB pose graph with 50 nodes and 120 constraint edges, g2o exploits the banded sparsity pattern to solve the normal equations in milliseconds. This is the same optimizer used in many graph SLAM implementations — which is why TEB's compute cost scales with path length rather than remaining roughly constant like DWA's fixed-grid sampling.
A practical TEB configuration for a differential-drive robot in Nav2's nav2_teb_controller:
teb_local_planner: ros__parameters: # Trajectory teb_autosize: true # auto-extend pose sequence as needed dt_ref: 0.3 # target time resolution between poses dt_hysteresis: 0.1 # tolerance before adding/removing poses min_samples: 3 max_samples: 500 # Robot kinematics (differential drive) max_vel_x: 1.2 max_vel_x_backwards: 0.3 max_vel_theta: 2.0 acc_lim_x: 1.5 # matches L6-9 braking deceleration acc_lim_theta: 2.5 # Obstacles min_obstacle_dist: 0.30 # hard clearance margin [m] inflation_dist: 0.60 # soft inflation radius include_costmap_obstacles: true dynamic_obstacle_inflation_dist: 0.8 # Optimization no_inner_iterations: 5 no_outer_iterations: 4 optimization_activate: true optimization_verbose: false penalty_epsilon: 0.1 # slack for constraint penalties # Footprint model (circular for efficiency) footprint_model: type: "circular" radius: 0.30 # FollowBot's circumscribed radius
COMPARISONDWA vs. TEB: when each wins and what each costs
Neither planner dominates universally. The practical choice is a function of environment geometry, compute budget, and how much tuning you can afford.
| Dimension | DWA / DWB (Nav2 default) | TEB |
|---|---|---|
| Compute cost | Low-constant: O(N·M) samples, fixed grid | Variable: scales with trajectory length and convergence iterations; can spike |
| Narrow corridors | Poor: sampling misses tight feasible arcs; oscillates | Good: optimization threads the gap; elastic band actively deforms around obstacles |
| Non-holonomic constraints | Exact: arcs are kinematically exact circular paths | Enforced as soft constraints; may produce marginally infeasible velocities at optimizer exit |
| Dynamic obstacles | Reactive: obstacle is in costmap; DWA sees it next cycle | Reactive: same, plus optional dynamic obstacle extension (velocity obstacles) |
| Smoothness | Discontinuous: best-scoring sample can jump between cycles | Smoother: warm-starts from previous solution; continuous trajectory |
| Tuning complexity | Low: 3 weights (α, β, γ), 2 horizons (T_sim, dt) | High: 10+ parameters, optimization weights, footprint model, convergence thresholds |
| Failure mode | Oscillation in corridors; empty window → stop | Optimizer non-convergence → stale command reuse; local minima in complex geometry |
Nav2 ships nav2_dwb_controller, which is DWA with a plugin architecture for scoring critics. Instead of fixed (heading, clearance, velocity) weights, DWB lets you compose arbitrary critic plugins: GoalAlign, ObstacleFootprint, RotateToGoal, etc. This is the right thing to use for FollowBot in practice. The underlying dynamic window and admissibility logic are identical to original DWA.
FOLLOWBOTWiring DWA into FollowBot's Nav2 stack
The Nav2 stack milestone for Stage 6 gives FollowBot a complete local planning pipeline: DWB local planner with FollowBot's constraints, a layered costmap with LIDAR obstacle and inflation layers, and the ROS 2 interface that the behavior tree drives.
The DWB controller plugin config for FollowBot:
controller_server: ros__parameters: controller_frequency: 10.0 # Hz — replan + command cycle controller_plugins: ["FollowPath"] FollowPath: plugin: "dwb_core::DWBLocalPlanner" # Kinematic limits (match URDF / hardware spec) min_vel_x: 0.0 max_vel_x: 1.2 min_vel_y: 0.0 # diff drive: no lateral motion max_vel_y: 0.0 min_speed_xy: 0.0 max_speed_xy: 1.2 min_vel_theta: -2.0 max_vel_theta: 2.0 min_speed_theta: 0.0 # Acceleration limits acc_lim_x: 1.5 # matches L6-9 braking deceleration acc_lim_y: 0.0 acc_lim_theta: 2.5 decel_lim_x: -1.5 # asymmetric: faster decel than accel # Trajectory sampling vx_samples: 20 vy_samples: 1 # diff drive: always 1 vtheta_samples: 20 sim_time: 1.7 # forward simulation horizon [s] linear_granularity: 0.05 angular_granularity: 0.025 # Critics (scoring function components) critics: ["RotateToGoal", "Oscillation", "ObstacleFootprint", "GoalAlign", "PathAlign", "PathDist", "GoalDist"] PathAlign.scale: 32.0 GoalAlign.scale: 24.0 PathDist.scale: 32.0 GoalDist.scale: 24.0 ObstacleFootprint.scale: 0.01 # low: costmap inflation handles margin RotateToGoal.scale: 32.0 RotateToGoal.slowing_factor: 5.0 Oscillation.scale: 1.0 # penalizes rapid v/ω sign changes
A few configuration decisions worth explaining:
- Asymmetric decel_lim_x: FollowBot decelerates 50% faster than it accelerates (1.5 vs 1.0 m/s²). This makes stopping distances shorter, which expands the admissible window near obstacles and reduces collision risk when a person stops suddenly. The hardware can actually do this; make sure your motor driver is configured to allow regenerative braking.
- Oscillation critic: This DWB-specific extension penalizes rapid alternation between positive and negative ω commands — exactly the narrow corridor oscillation DWA is prone to. Weight it at 1.0 initially, increase to 2.0 if oscillation persists.
- sim_time at 1.7 s: At max v = 1.2 m/s, this looks 2 m ahead. For person-following in a typical indoor environment with 3–8 m corridors, this is appropriate. Reduce to 1.0 s in cluttered spaces where longer simulation yields stale obstacle estimates.
At this point in the Nav2 stack build: A* global planner on the SLAM map, DWB local planner with the constraints above, a layered costmap with LIDAR obstacle layer (inflation radius 0.35 m, cost scaling 5.0), and the behavior tree executing detect person → navigate to tracked goal → maintain following distance → handle occlusion → recover. The local planner is the component that makes the robot actually safe — the behavior tree orchestrates what to do, the local planner ensures how to do it without hitting anything. Both must be correct before the sim-to-real transfer in Lesson 6.9.
The minimal Python node that drives FollowBot's local planner through Nav2's lifecycle interface — the pattern you need to send tracked person goals to the navigation stack:
import rclpy from rclpy.node import Node from rclpy.action import ActionClient from nav2_msgs.action import NavigateToPose from geometry_msgs.msg import PoseStamped import math class PersonFollower(Node): def __init__(self): super().__init__('person_follower') self._client = ActionClient(self, NavigateToPose, 'navigate_to_pose') # subscribe to tracked person position (from Stage 4/5 pipeline) self.create_subscription( PoseStamped, '/person_pose', self.person_cb, 10) self._active_goal = None self._FOLLOW_DIST = 1.2 # maintain 1.2 m behind person def person_cb(self, pose: PoseStamped): # compute goal 1.2 m behind the person along their approach vector goal_pose = PoseStamped() goal_pose.header = pose.header yaw = 0.0 # simplification: face person's position goal_pose.pose.position.x = pose.pose.position.x - self._FOLLOW_DIST * math.cos(yaw) goal_pose.pose.position.y = pose.pose.position.y - self._FOLLOW_DIST * math.sin(yaw) goal_pose.pose.orientation.w = 1.0 if not self._client.wait_for_server(timeout_sec=0.1): return # Nav2 not ready; skip this update msg = NavigateToPose.Goal() msg.pose = goal_pose self._active_goal = self._client.send_goal_async(msg)
In practice, you need to debounce: cancel the previous goal before sending the new one, and only update when the person has moved more than a threshold (0.1–0.2 m). Without debouncing, Nav2 receives goal after goal and the local planner oscillates trying to re-plan for each update. The full behavior tree implementation in Lesson 6.6 handles this correctly using Nav2's NavigateToPose with goal tolerance tuning.
WEAKNESSWhere local planners bite you
In a corridor 0.8 m wide with FollowBot's 0.6 m footprint, the left and right obstacle distances are both small (roughly 0.1 m clearance each side). The admissible window's Va constraint prunes all arcs that curve toward either wall. What remains in the admissible window is a narrow band of nearly straight trajectories. But "nearly straight" at 20×20 sampling granularity means adjacent samples differ by small ω increments. The heading score and clearance score give near-identical ratings to left-curving and right-curving samples. Between planning cycles, minor costmap updates (LIDAR noise, person position jitter) shift which sample wins by a razor margin. The result: ω alternates +0.3 / −0.3 / +0.3 rad/s every 100 ms — visible as rapid side-to-side swerving in the corridor. Fix: increase the Oscillation critic weight in DWB, reduce vtheta_samples to coarser granularity, or switch to TEB whose optimization smooths across cycles.
DWA and TEB run at 10 Hz. If a person steps in front of FollowBot at 1.5 m/s, the planner has 100 ms to detect and respond. In that 100 ms, the person covers 0.15 m. At 0.5 m clearance, that leaves 350 ms to decelerate — within the admissibility window. But at 0.2 m clearance (corridor edge), the person has already crossed the admissibility boundary before the planner fires. This is not a bug in DWA or TEB — it is a fundamental limit: a 10 Hz planner cannot guarantee safety against obstacles moving faster than v_max / (obstacle_distance × planner_hz). The right response is a separate, hardware-level safety monitor running at 100 Hz that halts the robot if any LIDAR return is within the safety bubble, independent of the navigation stack.
TEB warm-starts from the previous cycle's solution. If the optimizer does not converge in the allotted time (no_outer_iterations × no_inner_iterations), it exits and issues the command from the previous — now potentially stale — solution. This is different from DWA's failure mode (explicit stop when window is empty). TEB keeps moving on stale data. In practice this is hard to detect because the poses look reasonable. Monitor teb_local_planner/teb_markers in RViz: if the trajectory is not updating (poses freeze between frames), the optimizer has stalled. Set optimization_verbose: true temporarily and check for "optimization failed to converge" messages.
KEY INSIGHTHow this connects
- 6.1 · Configuration Space: The Correct Abstraction for Planning — C-space is the foundation for understanding why the admissible dynamic window works in (v, ω) space rather than in the robot's workspace. DWA is sampling a slice of C-space reachable in one timestep.
- 6.3 · Sampling-Based Planning: RRT and RRT* — the global planner whose output DWA and TEB track. Understanding RRT* sampling makes clear why the global path can be geometrically optimal in static configuration space yet still require a local planner to handle dynamic reality.
- 3.9 · Model Predictive Control: Constraints as the Killer Feature — TEB is MPC applied to navigation: the elastic band is the rolling horizon, the g2o optimization is the QP solver, and the admissibility constraint is the safety envelope. Understanding MPC makes TEB's design choices obvious rather than mysterious.
- 2.1 · Differential Drive Kinematics: FollowBot's Motion Model — the kinematic model (v, ω) → (x, y, θ) is exactly the forward simulator DWA uses to roll out candidate arcs. The circular arc geometry that makes DWA tractable is a direct consequence of differential drive's kinematic structure.
- Next: 6.5 · The Nav2 Stack: Architecture, Lifecycle Nodes, and Failure Modes — everything configured in this lesson (DWB, costmaps, behavior tree goals) is wired together by Nav2's lifecycle node graph, which is the subject of the next lesson.
GLOSSARYKey terms introduced
- Dynamic Window Approach (DWA)
- A local planner that restricts velocity sampling to the set of commands reachable in one timestep given current velocity and acceleration limits (the dynamic window), prunes non-admissible samples, and scores the remainder on heading, clearance, and forward velocity.
- Admissible velocity
- A (v, ω) pair from which the robot can decelerate to zero before reaching the nearest obstacle on the arc that velocity traces. The admissibility constraint V_a is a hard safety envelope, not a soft scoring term.
- Timed Elastic Band (TEB)
- A local planner that represents the trajectory as a sequence of timed poses and optimizes the full band jointly using g2o, enforcing kinematic constraints and obstacle avoidance as penalty terms. Better in narrow corridors; higher compute cost than DWA.
- DWB (Dynamic Window Base)
- Nav2's evolution of DWA that decomposes the scoring function into composable critic plugins (GoalAlign, ObstacleFootprint, Oscillation, etc.), allowing per-deployment tuning without modifying the core sampling and admissibility logic.
- g2o
- General Graph Optimization — a sparse nonlinear least-squares framework used by TEB (and graph SLAM) to efficiently solve optimization problems with many variables and few coupling edges, exploiting the banded structure of the Jacobian.
- Simulation horizon (T_sim)
- The time over which DWA rolls out each candidate arc for scoring. Short horizons react to immediate obstacles but miss distant geometry; long horizons see further but cost more compute and may simulate arcs the costmap will soon invalidate.
- Oscillation critic
- A DWB scoring plugin that penalizes rapid alternation between positive and negative rotational velocity commands — the specific pathology that DWA suffers in narrow corridors where heading and clearance scores are near-identical for left and right turns.
- Elastic band
- The flexible trajectory representation in TEB, where poses are connected by spring-like constraints toward the global path reference. The band stretches to thread obstacles and contracts to follow the reference path in open space.
ACTIVE RECALLCheck your understanding
Answer in your own words first, then reveal.
1What are the three constraint sets that define the admissible dynamic window, and what does each one enforce?›
V_s (hardware limits): the rectangle in (v, ω) space bounded by the robot's physical maximum and minimum velocities — motor limits, safety stops, mechanical ratings. V_d (dynamic window): the subset of V_s reachable in one timestep from the current velocity, given the maximum linear and angular accelerations. This is a smaller rectangle centered on (v_c, ω_c). V_a (admissibility): the subset of velocities from which the robot can decelerate to zero before hitting the nearest obstacle on the circular arc that velocity traces. The intersection V_s ∩ V_d ∩ V_a is the admissible dynamic window. DWA samples only within this intersection and discards everything outside it before scoring. If the intersection is empty, the planner fails and the robot stops.
2Why does DWA oscillate in narrow corridors, and which specific component of the DWB framework is designed to address this?›
In a narrow corridor, the admissible dynamic window is pruned severely on both sides by the obstacle admissibility constraint. What remains is a thin band of nearly-straight trajectories. Small amounts of costmap noise or person-position jitter shift the heading and clearance scores enough to change which slightly-curved sample wins between planning cycles. The best sample alternates between slight-left and slight-right commands every cycle, producing visible side-to-side swerving. The Oscillation critic in DWB penalizes rapid sign changes in ω, adding a smoothing term that biases the selector toward maintaining the current rotational direction unless a clear advantage justifies changing it.
3TEB and DWA both run at 10 Hz and both command (v, ω). What is the fundamental architectural difference in how each computes that command?›
DWA is a sampling-based, single-step approach: it discretizes the admissible velocity space into a grid, forward-simulates each sample for T_sim seconds, scores each with a scalar function, and picks the highest scorer. The computation is O(N·M) in the number of samples, with no iteration. TEB is an optimization-based, trajectory-wide approach: it maintains a sequence of N timed poses representing the full trajectory, and iteratively refines the entire sequence to minimize a cost function encoding path fidelity, obstacle avoidance, and kinematic constraints using g2o. The command (v, ω) is extracted from the first pose transition. TEB produces a globally consistent trajectory; DWA produces a myopic best command. TEB handles narrow corridors better because the optimization deforms the trajectory geometry; DWA cannot deform the arc within a single sampling call.
4Both DWA and TEB can fail when an obstacle moves faster than the replan rate. What is the correct architectural response to this failure mode?›
A 10 Hz planner cannot provide real-time safety guarantees against fast-moving obstacles — this is a fundamental timing limit, not a bug in either algorithm. The correct response is to separate the planning problem from the safety problem: run a hardware-level safety monitor independently, at 100 Hz or higher, that issues a hard stop if any LIDAR return falls within a fixed safety bubble (e.g., 0.25 m from the robot's footprint). This monitor is a simple range-threshold check — it does not plan or score; it just stops. The navigation planner operates in the slow outer loop optimizing for good behavior; the safety monitor operates in the fast inner loop preventing physical damage. In Nav2 this separation is partially provided by the collision_monitor node, which runs independently of the controller server.