Principle:CARLA simulator Carla Autopilot Mode
| Knowledge Sources | |
|---|---|
| Domains | Autonomous Driving Simulation, Traffic Simulation |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Autopilot mode delegates a vehicle's control to a built-in AI traffic manager that handles steering, throttle, braking, and lane decisions, enabling automated driving behavior without explicit client-side control commands.
Description
In autonomous driving simulation, populating the world with realistic traffic requires many vehicles to drive autonomously following traffic rules. Rather than requiring the client to compute and send control commands for every NPC vehicle at every simulation tick, the simulation provides a built-in Traffic Manager (TM) -- a server-side AI system that controls registered vehicles.
When autopilot is enabled on a vehicle, the Traffic Manager takes over and:
- Plans routes using the map's waypoint graph.
- Follows lanes and respects lane markings.
- Obeys traffic lights and stop signs.
- Maintains safe following distances from vehicles ahead.
- Handles intersections with right-of-way logic.
- Changes lanes when appropriate and safe.
- Adjusts speed based on road speed limits and nearby traffic.
The Traffic Manager runs as a separate component (identified by its port number) that can be configured to adjust driving behavior: desired speed, lane change probability, safety distance, traffic light compliance percentage, and more. Multiple Traffic Manager instances can run simultaneously on different ports, each controlling a different group of vehicles with distinct behavior profiles.
Important distinction: Autopilot mode is designed for NPC background traffic, not for the ego vehicle being tested. The ego vehicle is typically controlled by an external autonomous driving stack or a reinforcement learning agent that processes sensor data and produces control commands.
Usage
Use autopilot mode when you need to:
- Generate background traffic -- Enable autopilot on spawned NPC vehicles to create a realistic driving environment.
- Test ego vehicle behavior -- Surround the ego vehicle with AI-driven traffic to evaluate its response to various driving situations.
- Create diverse traffic patterns -- Configure different Traffic Manager settings per vehicle for varied driving styles (aggressive, cautious, law-abiding, etc.).
- Rapid prototyping -- Quickly test scenarios without implementing custom vehicle controllers.
Theoretical Basis
Traffic Manager architecture:
Client CARLA Server
| |
|-- set_autopilot(True) --> |
| |-- Register vehicle with TM
| |
| Traffic Manager
| +-- Route Planner
| | +-- Waypoint graph navigation
| | +-- Lane selection
| +-- Motion Planner
| | +-- Speed control (PID)
| | +-- Following distance
| +-- Behavior Planner
| | +-- Traffic light response
| | +-- Lane change decisions
| | +-- Intersection handling
| +-- Collision Avoidance
| +-- Emergency braking
| +-- Safe distance maintenance
Control delegation model:
Manual mode:
each tick:
client computes VehicleControl(throttle, steer, brake)
client sends control to vehicle
Autopilot mode:
each tick:
TM reads vehicle state (position, velocity, nearby actors)
TM computes VehicleControl(throttle, steer, brake)
TM applies control to vehicle
-- client does NOT send controls
Configurable behavior parameters:
| Parameter | Description | Effect |
|---|---|---|
| vehicle_percentage_speed_difference | Speed relative to road limit | Negative = faster, Positive = slower |
| distance_to_leading_vehicle | Following distance in meters | Larger = more cautious |
| auto_lane_change | Enable/disable lane changes | True = allows overtaking |
| ignore_lights_percentage | Chance to run a red light | 0 = always obey, 100 = always ignore |
| ignore_signs_percentage | Chance to ignore stop signs | 0 = always obey, 100 = always ignore |
| random_left_lanechange_percentage | Probability of left lane change | Higher = more frequent |
| random_right_lanechange_percentage | Probability of right lane change | Higher = more frequent |
Multi-TM configuration:
TM on port 8000: controls cautious drivers (low speed, large following distance)
TM on port 8001: controls aggressive drivers (high speed, small following distance)
Vehicle A -> set_autopilot(True, tm_port=8000) # cautious
Vehicle B -> set_autopilot(True, tm_port=8001) # aggressive