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.

Implementation:CARLA simulator Carla ActorBlueprint Class

From Leeroopedia
Knowledge Sources
Domains Client Library, Actor Spawning, Blueprint System
Last Updated 2026-02-15 05:00 GMT

Overview

ActorBlueprint contains all the necessary information for spawning an actor in CARLA, including its identifier, tags, and configurable attributes.

Description

The ActorBlueprint class in the carla::client namespace wraps an rpc::ActorDefinition and provides methods for querying and configuring actor blueprints before spawning.

Construction

The constructor takes an rpc::ActorDefinition and:

  • Stores the _uid (unique identifier) and _id (string identifier, e.g., vehicle.tesla.model3).
  • Splits the definition's comma-separated tags into an _tags set using StringUtil::Split.
  • Fills the _attributes map from the definition's attributes using the FillMap helper.

Tag Operations

  • ContainsTag(tag) -- Checks if a specific tag exists in the tag set.
  • MatchTags(wildcard_pattern) -- Tests if the blueprint ID or any tag matches a Unix shell-style wildcard pattern using StringUtil::Match.
  • GetTags() -- Returns all tags as a vector of strings.

Attribute Operations

  • ContainsAttribute(id) -- Checks if an attribute exists by ID.
  • GetAttribute(id) -- Returns a const reference to the ActorAttribute; throws std::out_of_range if not found.
  • SetAttribute(id, value) -- Sets an attribute value; throws std::out_of_range if the attribute does not exist, or InvalidAttributeValue if the attribute is not modifiable or the format does not match.
  • size() / begin() / end() -- Iteration over attributes using iterator::make_map_values_const_iterator.

Actor Description

  • MakeActorDescription() -- Creates an rpc::ActorDescription from the current blueprint state, collecting the UID, ID, and all current attribute values for submission to the simulator for spawning.

Private Members

  • _uid -- uint32_t unique identifier
  • _id -- std::string blueprint identifier
  • _tags -- std::unordered_set<std::string> of tags
  • _attributes -- std::unordered_map<std::string, ActorAttribute> of configurable attributes

Usage

Retrieve blueprints from the BlueprintLibrary, optionally modify their attributes (e.g., color, number of wheels), then pass to World::SpawnActor or World::TrySpawnActor.

Code Reference

Source Location

  • Repository: CARLA
  • Files:
    • LibCarla/source/carla/client/ActorBlueprint.h (124 lines)
    • LibCarla/source/carla/client/ActorBlueprint.cpp (66 lines)

Signature

namespace carla {
namespace client {

class ActorBlueprint {
public:
  explicit ActorBlueprint(rpc::ActorDefinition actor_definition);

  const std::string &GetId() const;

  bool ContainsTag(const std::string &tag) const;
  bool MatchTags(const std::string &wildcard_pattern) const;
  std::vector<std::string> GetTags() const;

  bool ContainsAttribute(const std::string &id) const;
  const ActorAttribute &GetAttribute(const std::string &id) const;
  void SetAttribute(const std::string &id, std::string value);

  size_t size() const;
  auto begin() const;
  auto end() const;

  rpc::ActorDescription MakeActorDescription() const;

private:
  uint32_t _uid;
  std::string _id;
  std::unordered_set<std::string> _tags;
  std::unordered_map<std::string, ActorAttribute> _attributes;
};

} // namespace client
} // namespace carla

Import

#include "carla/client/ActorBlueprint.h"

I/O Contract

Inputs

Name Type Required Description
actor_definition rpc::ActorDefinition Yes Server-provided actor definition with uid, id, tags, and attributes
id std::string Yes (for Get/SetAttribute) Attribute identifier string
value std::string Yes (for SetAttribute) New attribute value as string
wildcard_pattern std::string Yes (for MatchTags) Unix shell-style wildcard pattern

Outputs

Name Type Description
id const std::string& Blueprint identifier (e.g., "vehicle.tesla.model3")
tags std::vector<std::string> List of tags associated with the blueprint
attribute const ActorAttribute& Attribute value for a given id
description rpc::ActorDescription Complete actor description ready for spawning

Usage Examples

// Get a blueprint from the library
auto blueprint_library = world.GetBlueprintLibrary();
auto bp = blueprint_library->Find("vehicle.tesla.model3");

// Check tags
if (bp->MatchTags("vehicle.*")) {
    // Configure attributes
    if (bp->ContainsAttribute("color")) {
        bp->SetAttribute("color", "255,0,0");
    }

    // Spawn the actor
    auto actor = world.SpawnActor(*bp, spawn_transform);
}

Related Pages

Page Connections

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