Implementation:CARLA simulator Carla Change Map Layer Tool
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Map Management, Utility |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
Command-line utility script that loads or unloads specific map layers in a running CARLA simulation, controlling visibility of Buildings, Decals, Foliage, Ground, and other environmental elements.
Description
This script (change_map_layer.py) enables dynamic loading and unloading of map layers during a CARLA simulation. It defines a MAP_LAYERS dictionary mapping layer names to carla.MapLayer enum values: Buildings, Decals, Foliage, Ground, ParkedVehicles, Particles, Props, StreetLights, Walls, and All. The script connects to the CARLA server, validates the requested layer, and calls either world.load_map_layer() or world.unload_map_layer() based on the --action argument (load or unload). This is particularly useful for reducing rendering overhead or isolating specific scene elements during testing.
Usage
Use this tool to dynamically control map layer visibility during simulation, which is useful for performance optimization, debugging, or creating specific test scenarios with reduced scene complexity.
Code Reference
Source Location
- Repository: CARLA
- File: PythonAPI/util/change_map_layer.py
Signature
MAP_LAYERS = {
'Buildings': carla.MapLayer.Buildings,
'Decals': carla.MapLayer.Decals,
'Foliage': carla.MapLayer.Foliage,
'Ground': carla.MapLayer.Ground,
'ParkedVehicles': carla.MapLayer.ParkedVehicles,
'Particles': carla.MapLayer.Particles,
'Props': carla.MapLayer.Props,
'StreetLights': carla.MapLayer.StreetLights,
'Walls': carla.MapLayer.Walls,
'All': carla.MapLayer.All
}
def main():
"""Parse args and load/unload the specified map layer."""
Import
# Run as a command-line tool:
python change_map_layer.py -l Buildings --action unload
I/O Contract
| Argument | Type | Default | Description |
|---|---|---|---|
| --host | str | 127.0.0.1 | CARLA server IP address |
| -p, --port | int | 2000 | CARLA server TCP port |
| -l, --layer | str | required | Layer name to load/unload |
| --action | choice | required | Action: "load" or "unload" |
| Layer Name | Description |
|---|---|
| Buildings | Building structures |
| Decals | Surface decals |
| Foliage | Trees and vegetation |
| Ground | Ground surfaces |
| ParkedVehicles | Stationary vehicles |
| Particles | Particle effects |
| Props | Scene props |
| StreetLights | Street light fixtures |
| Walls | Wall structures |
| All | All layers combined |
Usage Examples
# Unload buildings layer for performance
python change_map_layer.py -l Buildings --action unload
# Reload foliage
python change_map_layer.py -l Foliage --action load
# Unload all layers
python change_map_layer.py -l All --action unload