CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
client
ActorBlueprint.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include "
carla/Debug.h
"
10
#include "
carla/Iterator.h
"
11
#include "
carla/client/ActorAttribute.h
"
12
#include "
carla/rpc/ActorDefinition.h
"
13
#include "
carla/rpc/ActorDescription.h
"
14
15
#include <exception>
16
#include <unordered_map>
17
#include <unordered_set>
18
19
namespace
carla
{
20
namespace
client
{
21
22
/// Contains all the necessary information for spawning an Actor.
23
class
ActorBlueprint
{
24
public
:
25
26
// =========================================================================
27
/// @name Constructor
28
// =========================================================================
29
/// @{
30
31
explicit
ActorBlueprint
(
rpc::ActorDefinition
actor_definition);
32
33
/// @}
34
// =========================================================================
35
/// @name Id
36
// =========================================================================
37
/// @{
38
39
public
:
40
41
const
std::string &
GetId
()
const
{
42
return
_id
;
43
}
44
45
/// @}
46
// =========================================================================
47
/// @name Tags
48
// =========================================================================
49
/// @{
50
51
public
:
52
53
bool
ContainsTag
(
const
std::string &tag)
const
{
54
return
_tags
.find(tag) !=
_tags
.end();
55
}
56
57
/// Test if any of the flags matches @a wildcard_pattern.
58
///
59
/// @a wildcard_pattern follows Unix shell-style wildcards.
60
bool
MatchTags
(
const
std::string &wildcard_pattern)
const
;
61
62
std::vector<std::string>
GetTags
()
const
{
63
return
{
_tags
.begin(),
_tags
.end()};
64
}
65
66
/// @}
67
// =========================================================================
68
/// @name Attributes
69
// =========================================================================
70
/// @{
71
72
public
:
73
74
bool
ContainsAttribute
(
const
std::string &
id
)
const
{
75
return
_attributes
.find(
id
) !=
_attributes
.end();
76
}
77
78
/// @throw std::out_of_range if no such element exists.
79
const
ActorAttribute
&
GetAttribute
(
const
std::string &
id
)
const
;
80
81
/// Set the value of the attribute given by @a id.
82
///
83
/// @throw std::out_of_range if no such element exists.
84
/// @throw InvalidAttributeValue if attribute is not modifiable.
85
/// @throw InvalidAttributeValue if format does not match the attribute type.
86
void
SetAttribute
(
const
std::string &
id
, std::string value);
87
88
size_t
size
()
const
{
89
return
_attributes
.size();
90
}
91
92
auto
begin
()
const
{
93
return
iterator::make_map_values_const_iterator(
_attributes
.begin());
94
}
95
96
auto
end
()
const
{
97
return
iterator::make_map_values_const_iterator(
_attributes
.end());
98
}
99
100
/// @}
101
// =========================================================================
102
/// @name ActorDescription
103
// =========================================================================
104
/// @{
105
106
public
:
107
108
rpc::ActorDescription
MakeActorDescription
()
const
;
109
110
/// @}
111
112
private
:
113
114
uint32_t
_uid
= 0u;
115
116
std::string
_id
;
117
118
std::unordered_set<std::string>
_tags
;
119
120
std::unordered_map<std::string, ActorAttribute>
_attributes
;
121
};
122
123
}
// namespace client
124
}
// namespace carla
Debug.h
Iterator.h
ActorAttribute.h
ActorDefinition.h
ActorDescription.h
carla::client::ActorAttribute
An attribute of an ActorBlueprint.
Definition
LibCarla/source/carla/client/ActorAttribute.h:184
carla::client::ActorBlueprint::_id
std::string _id
Definition
ActorBlueprint.h:116
carla::client::ActorBlueprint::MakeActorDescription
rpc::ActorDescription MakeActorDescription() const
Definition
ActorBlueprint.cpp:54
carla::client::ActorBlueprint::_attributes
std::unordered_map< std::string, ActorAttribute > _attributes
Definition
ActorBlueprint.h:120
carla::client::ActorBlueprint::GetAttribute
const ActorAttribute & GetAttribute(const std::string &id) const
Definition
ActorBlueprint.cpp:41
carla::client::ActorBlueprint::_tags
std::unordered_set< std::string > _tags
Definition
ActorBlueprint.h:118
carla::client::ActorBlueprint::ContainsTag
bool ContainsTag(const std::string &tag) const
Definition
ActorBlueprint.h:53
carla::client::ActorBlueprint::ActorBlueprint
ActorBlueprint(rpc::ActorDefinition actor_definition)
Definition
ActorBlueprint.cpp:26
carla::client::ActorBlueprint::GetId
const std::string & GetId() const
Definition
ActorBlueprint.h:41
carla::client::ActorBlueprint::size
size_t size() const
Definition
ActorBlueprint.h:88
carla::client::ActorBlueprint::ContainsAttribute
bool ContainsAttribute(const std::string &id) const
Definition
ActorBlueprint.h:74
carla::client::ActorBlueprint::begin
auto begin() const
Definition
ActorBlueprint.h:92
carla::client::ActorBlueprint::MatchTags
bool MatchTags(const std::string &wildcard_pattern) const
Test if any of the flags matches wildcard_pattern.
Definition
ActorBlueprint.cpp:33
carla::client::ActorBlueprint::SetAttribute
void SetAttribute(const std::string &id, std::string value)
Set the value of the attribute given by id.
Definition
ActorBlueprint.cpp:50
carla::client::ActorBlueprint::_uid
uint32_t _uid
Definition
ActorBlueprint.h:114
carla::client::ActorBlueprint::GetTags
std::vector< std::string > GetTags() const
Definition
ActorBlueprint.h:62
carla::client::ActorBlueprint::end
auto end() const
Definition
ActorBlueprint.h:96
carla::rpc::ActorDefinition
Definition
LibCarla/source/carla/rpc/ActorDefinition.h:19
carla::rpc::ActorDescription
Definition
LibCarla/source/carla/rpc/ActorDescription.h:25
carla::client
Definition
BasicAgent.h:24
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
Generated by
1.18.0