Principle:CARLA simulator Carla NPC Vehicle Configuration
| Knowledge Sources | |
|---|---|
| Domains | Autonomous Driving Simulation, Vehicle Configuration |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
NPC vehicle configuration is the process of selecting and customizing the visual and physical properties of non-player-character vehicles to create realistic and diverse traffic populations in a driving simulation.
Description
In autonomous driving simulation, the realism of a traffic scenario depends not only on vehicle behavior but also on the visual and physical diversity of the vehicle population. NPC vehicle configuration addresses this by providing a mechanism to:
- Select vehicle types from a catalog of available models (sedans, SUVs, trucks, motorcycles, bicycles)
- Customize visual attributes such as paint color, enabling varied appearances even among the same model
- Filter by category to include or exclude specific vehicle classes (e.g., cars only, no bicycles)
- Randomize properties to create naturalistic distributions of vehicle appearances
The configuration process typically follows a blueprint pattern, where each vehicle type is represented by a template (blueprint) that describes its mesh, physics properties, and configurable attributes. The user selects and optionally modifies these templates before passing them to the spawning system.
Key Configuration Attributes
Vehicle blueprints typically expose the following configurable attributes:
- color -- The RGB paint color of the vehicle exterior. Blueprints define a set of recommended colors, and one can be selected randomly or explicitly.
- driver_id -- The visual appearance of the driver character model seated inside the vehicle, contributing to visual diversity.
- role_name -- A semantic tag (e.g., "autopilot", "hero") that can be used to distinguish the ego vehicle from NPC traffic.
- sticky_control -- Whether control commands persist between ticks or must be re-sent each tick.
Usage
Configure NPC vehicle blueprints when you need to:
- Generate a diverse traffic population for sensor testing (e.g., camera, LiDAR)
- Create specific traffic compositions (e.g., 80% cars, 15% trucks, 5% motorcycles)
- Ensure visual variety for perception algorithm training data
- Set up reproducible scenarios with specific vehicle types and colors
- Filter out vehicle categories that are unsuitable for a given scenario (e.g., exclude bicycles from highway scenarios)
Theoretical Basis
Blueprint Pattern
The blueprint pattern used for vehicle configuration is a creational design pattern where an object (the blueprint) serves as a prototype or template from which instances are created. In the context of traffic generation:
Blueprint Library (catalog of all available blueprints)
|
+-- filter("vehicle.*") --> Subset of vehicle blueprints
|
+-- For each blueprint:
attributes = blueprint.get_attributes()
if "color" in attributes:
colors = attributes["color"].recommended_values
blueprint.set_attribute("color", random.choice(colors))
if "driver_id" in attributes:
drivers = attributes["driver_id"].recommended_values
blueprint.set_attribute("driver_id", random.choice(drivers))
Traffic Composition Distribution
Realistic traffic requires a distribution of vehicle types that mirrors real-world observations. Traffic studies typically report vehicle class distributions such as:
| Vehicle Class | Typical Urban Share | Typical Highway Share |
|---|---|---|
| Passenger cars | 70-80% | 65-75% |
| SUVs/Light trucks | 10-15% | 15-20% |
| Commercial trucks | 3-8% | 8-12% |
| Motorcycles | 2-5% | 1-3% |
| Bicycles | 1-5% | 0% |
To achieve a desired distribution, one can weight the random selection of blueprints according to the target class probabilities, or filter the blueprint library to include only desired classes.
Role-Based Tagging
Setting the role_name attribute enables downstream systems to distinguish between different categories of actors. The "hero" role is conventionally reserved for the ego vehicle (the autonomous vehicle under test), while "autopilot" is used for NPC traffic. This tagging is important for:
- Sensor data labeling (distinguishing ego vehicle from traffic in ground truth)
- Traffic Manager behavior (some TM settings apply only to non-hero vehicles)
- Logging and analytics (filtering metrics by actor role)