Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:CARLA simulator Carla Actor Spawning

From Leeroopedia
Knowledge Sources
Domains Autonomous Driving Simulation, Game Engine Architecture
Last Updated 2026-02-15 00:00 GMT

Overview

Actor spawning is the process of instantiating a simulation entity at a specified location and orientation in the virtual world, creating a live object that participates in physics, rendering, and sensor interactions.

Description

In autonomous driving simulation, an actor is any entity that exists in the world: vehicles, pedestrians, traffic lights, sensors, static props, and more. Spawning an actor involves:

  1. Selecting a blueprint that defines the actor type and its configured attributes.
  2. Specifying a transform (3D position + 3D rotation) that determines where in the world the actor appears.
  3. Performing collision checks to verify the spawn location is not occupied by another actor or static geometry.
  4. Instantiating the actor on the server side, registering it with the physics engine and rendering pipeline.
  5. Returning a handle (actor reference) to the client for subsequent control and queries.

There are two spawning strategies with different failure modes:

  • Strict spawning (spawn_actor): Raises an exception if the actor cannot be placed at the requested location due to collision. This is appropriate when the spawn point is known to be valid and failure indicates a programming error.
  • Safe spawning (try_spawn_actor): Returns None instead of raising an exception when spawning fails. This is appropriate for batch spawning where some locations may be occupied, and the caller wants to handle failures gracefully.

Spawn points are predefined transforms distributed across the map at valid locations on the road network. Using these recommended points avoids spawning actors inside buildings, underground, or in mid-air. Custom transforms can also be used for precise placement.

Usage

Use actor spawning to:

  • Place the ego vehicle -- Spawn the primary vehicle that represents the autonomous agent being tested.
  • Generate traffic -- Spawn multiple NPC vehicles and pedestrians to create realistic traffic scenarios.
  • Deploy sensors -- Spawn camera, LiDAR, radar, and other sensor actors (typically attached to a vehicle).
  • Set up scenarios -- Position specific actors at precise locations for scripted test cases.

Theoretical Basis

Actor lifecycle:

[Blueprint] --(spawn)--> [Alive Actor] --(destroy)--> [Removed]
                              |
                         [Physics Active]
                         [Rendering Active]
                         [Sensors Collecting]
                         [Controllable via API]

Transform representation:

A transform combines a 3D location with a 3D rotation:

Transform = (Location, Rotation)

Location = (x, y, z)           -- meters, left-handed coordinate system
Rotation = (pitch, yaw, roll)  -- degrees, Unreal Engine convention

Collision detection at spawn:

function try_spawn(blueprint, transform):
    bounding_box = compute_bounding_box(blueprint)
    placed_box = apply_transform(bounding_box, transform)

    for actor in world.actors:
        if overlaps(placed_box, actor.bounding_box):
            return None  # Collision detected, spawn fails

    for mesh in world.static_geometry:
        if overlaps(placed_box, mesh.collision):
            return None  # Overlap with static world

    actor = instantiate(blueprint, transform)
    world.register(actor)
    return actor

Spawn strategies comparison:

Method On Failure Use Case
spawn_actor Raises RuntimeError Single critical actor (ego vehicle)
try_spawn_actor Returns None Batch spawning (NPC traffic)

Recommended spawn point selection:

Maps provide a list of pre-validated spawn points. For batch spawning, shuffling this list and iterating provides good distribution:

spawn_points = map.get_spawn_points()
shuffle(spawn_points)
for i in range(num_npcs):
    actor = try_spawn(blueprint, spawn_points[i])
    if actor is not None:
        actors.append(actor)

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment