Principle:CARLA simulator Carla Navigation Agent Architecture
| Knowledge Sources | |
|---|---|
| Domains | Autonomous Driving, Agent Architecture, Motion Planning |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
The Navigation Agent Architecture in CARLA defines a hierarchical software design pattern for autonomous vehicle control. A base agent class (BasicAgent) provides core capabilities -- global route planning, local waypoint tracking, obstacle detection, and PID-based vehicle control -- while a specialized subclass (BehaviorAgent) extends this foundation with personality-driven driving behaviors such as cautious, normal, and aggressive profiles.
Description
The architecture follows a layered decomposition common in robotics and autonomous driving systems:
- Global Planning Layer: Uses a GlobalRoutePlanner to compute a route from origin to destination over the road network graph. The route is expressed as a sequence of
(carla.Waypoint, RoadOption)tuples. - Local Planning Layer: A LocalPlanner maintains a waypoint queue (deque) and selects the next target waypoint for the vehicle to track. It converts the global plan into immediate control targets.
- Perception Layer: The agent queries the CARLA world for nearby vehicles, pedestrians, and traffic lights. Geometric corridor-based obstacle detection determines whether hazards exist along the planned route.
- Control Layer: A VehiclePIDController with separate longitudinal (throttle/brake) and lateral (steering) PID controllers generates the final
carla.VehicleControlcommand.
BasicAgent composes these layers and exposes a simple run_step() loop that:
- Detects obstacles (vehicles, walkers, traffic lights)
- Issues emergency stop if hazards are present
- Otherwise delegates to the local planner for PID-based waypoint tracking
BehaviorAgent inherits from BasicAgent and adds:
- Behavior profiles (Cautious, Normal, Aggressive) with tunable parameters for safety time, speed limits, and following distances
- Tailgating logic for slow lead vehicles
- Car-following manager with Time-To-Collision (TTC) based speed adaptation
- Lane-change decisions at intersections
Usage
Use the navigation agent architecture when you need to:
- Rapidly prototype an autonomous driving pipeline in CARLA without writing control logic from scratch
- Compare different driving behaviors (cautious vs. aggressive) under identical scenarios
- Build a baseline agent for benchmarking more sophisticated planning algorithms (e.g., reinforcement learning or model-predictive control)
- Teach or demonstrate the sense-plan-act paradigm in a realistic driving simulator
Theoretical Basis
The CARLA agent architecture implements the classical sense-plan-act paradigm from robotics:
loop:
percepts = sense(world) # Query vehicles, walkers, traffic lights
if hazard_detected(percepts):
action = emergency_stop()
else:
plan = local_planner.next_waypoint()
action = pid_controller(plan)
vehicle.apply_control(action)
Hierarchical Decomposition
| Layer | Component | Responsibility |
|---|---|---|
| Global Planning | GlobalRoutePlanner |
Compute route over road network graph (A* search) |
| Local Planning | LocalPlanner |
Maintain waypoint queue, select next target waypoint |
| Perception | BasicAgent._vehicle_obstacle_detected, _affected_by_traffic_light |
Detect obstacles and traffic signals along route corridor |
| Control | VehiclePIDController |
Convert waypoint error into throttle, brake, and steering commands |
Inheritance Hierarchy
BasicAgent
|-- GlobalRoutePlanner (has-a)
|-- LocalPlanner (has-a)
|-- VehiclePIDController (via LocalPlanner)
|
+-- BehaviorAgent (is-a)
|-- Cautious / Normal / Aggressive behavior profiles
|-- car_following_manager()
|-- tailgating logic
The base class provides safe, functional defaults (obey traffic lights, stop for obstacles, follow lane at target speed). The subclass overrides run_step() to inject behavior-specific decision-making while reusing the inherited perception and control infrastructure.