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"// 包含CARLA调试工具
10#include "carla/Iterator.h"// 包含CARLA迭代器工具
11#include "carla/client/ActorAttribute.h"// 包含CARLA客户端参与者属性
12#include "carla/rpc/ActorDefinition.h"// 包含CARLA远程过程调用参与者定义
13#include "carla/rpc/ActorDescription.h"// 包含CARLA远程过程调用参与者描述
14
15#include <exception>// 包含C++标准异常库
16#include <unordered_map>// 包含C++标准无序映射库
17#include <unordered_set>// 包含C++标准无序集合库
18
19namespace carla {
20namespace client {
21
22 /// 包含生成参与者所需的所有必要信息。
24 public:
25
26 // =========================================================================
27 /// @name 构造函数
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 {// 获取参与者ID
42 return _id;
43 }
44
45 /// @}
46 // =========================================================================
47 /// @name 标签
48 // =========================================================================
49 /// @{
50
51 public:
52
53 bool ContainsTag(const std::string &tag) const {// 检查是否包含特定标签
54 return _tags.find(tag) != _tags.end();
55 }
56
57 /// 测试是否有标签满足 @a wildcard_pattern。
58 ///
59 /// @a wildcard_pattern 遵循 Unix shell 风格的通配符。
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 属性
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 异常。
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 异常。
84 /// @throw 如果属性不可修改,则抛出 InvalidAttributeValue 异常。
85 /// @throw 如果格式不匹配属性类型,则抛出 InvalidAttributeValue 异常。
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
108 rpc::ActorDescription MakeActorDescription() const;// 创建参与者描述
109
110 /// @}
111
112 private:
113
114 uint32_t _uid = 0u;// 参与者唯一ID
115
116 std::string _id;// 参与者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
包含生成参与者所需的所有必要信息。
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
测试是否有标签满足 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)
创建一个迭代器,该迭代器提供对map值的const引用的遍历。
Definition Iterator.h:61
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
包含CARLA客户端相关类和函数的命名空间。