CARLA
 
载入中...
搜索中...
未找到
ActorBlueprint.h
浏览该文件的文档.
1// Copyright (c) 2017 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"
14
15#include <exception>
16#include <unordered_map>
17#include <unordered_set>
18
19namespace carla {
20namespace client {
21
22 /// Contains all the necessary information for spawning an Actor.
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 {
94 }
95
96 auto end() const {
98 }
99
100 /// @}
101 // =========================================================================
102 /// @name ActorDescription
103 // =========================================================================
104 /// @{
105
106 public:
107
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
Contains all the necessary information for spawning an Actor.
rpc::ActorDescription MakeActorDescription() const
std::unordered_map< std::string, ActorAttribute > _attributes
const ActorAttribute & GetAttribute(const std::string &id) const
std::unordered_set< std::string > _tags
bool ContainsTag(const std::string &tag) const
ActorBlueprint(rpc::ActorDefinition actor_definition)
const std::string & GetId() const
bool ContainsAttribute(const std::string &id) const
bool MatchTags(const std::string &wildcard_pattern) const
Test if any of the flags matches wildcard_pattern.
void SetAttribute(const std::string &id, std::string value)
Set the value of the attribute given by id.
std::vector< std::string > GetTags() const
static auto make_map_values_const_iterator(It it)
Creates an iterator over const references to the values of a map.
Definition Iterator.h:43
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133