Implementation:CARLA simulator Carla Client Load World
| Knowledge Sources | |
|---|---|
| Domains | Autonomous Driving Simulation, Virtual Environments |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for loading a pre-built map into the CARLA simulation world provided by the CARLA simulator.
Description
The Client.load_world method instructs the CARLA server to unload the current map and load a new one identified by name. This operation destroys all existing actors, resets the simulation world, and initializes the new map's road network and static geometry. The method blocks until the new world is fully loaded and ready.
The map_name parameter accepts either short names (e.g., "Town01") or full asset paths. CARLA ships with several pre-built maps ranging from simple test tracks to complex urban environments. The map_layers parameter enables selective loading of geometry categories to reduce memory usage.
When reset_settings is True (the default), all world settings are reverted to their defaults after loading. Set this to False if you plan to immediately apply custom settings and want to avoid a brief period of default behavior.
Usage
Use this method to switch between different driving environments at the start of a simulation session or between evaluation episodes. Always set an appropriate client timeout before calling load_world, as map loading can take significantly longer than normal API calls.
Code Reference
Source Location
- Repository: CARLA
- File:
LibCarla/source/carla/client/Client.h - Lines: L74-79
- Python binding:
PythonAPI/carla/src/Client.cpp - Lines: L194-196
Signature
Client.load_world(map_name: str, reset_settings: bool = True, map_layers: carla.MapLayer = carla.MapLayer.All) -> carla.World
Import
import carla
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| map_name | str | Yes | Name of the map to load (e.g., "Town01", "Town03", "Town10HD"). Can also be a full Unreal asset path. |
| reset_settings | bool | No | Whether to reset world settings to defaults after loading. Defaults to True. |
| map_layers | carla.MapLayer | No | Bitmask specifying which geometry layers to load. Defaults to carla.MapLayer.All. Use bitwise OR to combine layers. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | carla.World | The newly loaded simulation world, ready for actor spawning and configuration |
Usage Examples
Basic Example
import carla
client = carla.Client("localhost", 2000)
client.set_timeout(30.0) # Map loading can take a while
# List available maps
available_maps = client.get_available_maps()
print(f"Available maps: {available_maps}")
# Load Town03 (a medium-complexity urban environment)
world = client.load_world("Town03")
# Verify the loaded map
current_map = world.get_map()
print(f"Loaded map: {current_map.name}")
# Get spawn points for the new map
spawn_points = current_map.get_spawn_points()
print(f"Number of spawn points: {len(spawn_points)}")
Selective Layer Loading Example
import carla
client = carla.Client("localhost", 2000)
client.set_timeout(30.0)
# Load only roads and ground (no buildings, foliage, or props)
# This significantly reduces memory usage and load time
minimal_layers = carla.MapLayer.Ground | carla.MapLayer.Decals
world = client.load_world(
"Town05",
reset_settings=False, # Preserve current settings
map_layers=minimal_layers
)
# Apply custom synchronous settings immediately
settings = world.get_settings()
settings.synchronous_mode = True
settings.fixed_delta_seconds = 0.05
world.apply_settings(settings)