CARLA
 
载入中...
搜索中...
未找到
client/Actor.h
浏览该文件的文档.
1// Copyright (c) 2017 计算机视觉中心 (CVC) - 巴塞罗那自治大学 (UAB).
2//
3// 本作品依据MIT许可证条款授权。
4// 有关详细信息,请参见 <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8
9#include "carla/Debug.h"
10#include "carla/Memory.h"
13
14namespace carla {
15 namespace client {
16
17 /// 表示模拟中的一个行为体(Actor)。
18 class Actor
19 : public EnableSharedFromThis<Actor>,
21 public detail::ActorState {
23 public:
24
25 explicit Actor(ActorInitializer init)
27 Super(std::move(init)) {}
28
29 using ActorState::GetBoundingBox;
30
31 virtual ~Actor() = default;
32
33 /// 返回行为体的当前位置。
34 ///
35 /// @note 该函数不会调用模拟器,而是返回上一个时刻接收到的位置。
37
38 /// 返回行为体的当前变换(位置和方向)。
39 ///
40 /// @note 该函数不会调用模拟器,而是返回上一个时刻接收到的变换。
42
43 /// 返回行为体的当前3D速度。
44 ///
45 /// @note 该函数不会调用模拟器,而是返回上一个时刻接收到的速度。
47
48 /// 返回行为体的当前3D角速度。
49 ///
50 /// @note 该函数不会调用模拟器,而是返回上一个时刻接收到的角速度。
52
53 /// 返回行为体的当前3D加速度。
54 ///
55 /// @note 该函数不会调用模拟器,而是返回根据行为体的速度计算的加速度。
57 /**
58 * 获取指定组件的世界坐标变换。
59 * 这个函数返回一个包含位置、旋转和平移信息的Transform对象,
60 * 表示指定组件在世界坐标系中的位置和方向。
61 * @param componentName 要获取变换的组件名称。
62 * @return 组件的世界坐标变换。
63 */
64 geom::Transform GetComponentWorldTransform(const std::string componentName) const;
65 /**
66 * 获取指定组件相对于Actor的相对坐标变换。
67 * 这个函数返回一个包含位置、旋转和平移信息的Transform对象,
68 * 表示指定组件相对于Actor原点的位置和方向。
69 * @param componentName 要获取变换的组件名称。
70 * @return 组件的相对坐标变换。
71 */
72 geom::Transform GetComponentRelativeTransform(const std::string componentName) const;
73
74 std::vector<geom::Transform> GetBoneWorldTransforms() const;
75
76 std::vector<geom::Transform> GetBoneRelativeTransforms() const;
77
78 std::vector<std::string> GetComponentNames() const;
79
80 std::vector<std::string> GetBoneNames() const;
81
82 std::vector<geom::Transform> GetSocketWorldTransforms() const;
83
84 std::vector<geom::Transform> GetSocketRelativeTransforms() const;
85
86 std::vector<std::string> GetSocketNames() const;
87
88 /// 将行为体传送到 @a location。
89 void SetLocation(const geom::Location& location);
90
91 /// 将行为体传送并旋转到 @a transform。
92 void SetTransform(const geom::Transform& transform);
93
94 /// 在应用物理之前设置行为体的速度。
95 void SetTargetVelocity(const geom::Vector3D& vector);
96
97 /// 在应用物理之前设置行为体的角速度。
99
100 /// 启用恒定速度模式。
102
103 /// 禁用恒定速度模式。
105
106 /// 在行为体的质心施加冲量。
107 void AddImpulse(const geom::Vector3D& vector);
108
109 /// 在某个位置对行为体施加冲量。
110 void AddImpulse(const geom::Vector3D& impulse, const geom::Vector3D& location);
111
112 /// 在行为体的质心施加力。
113 void AddForce(const geom::Vector3D& force);
114
115 /// 在某个位置对行为体施加力。
116 void AddForce(const geom::Vector3D& force, const geom::Vector3D& location);
117
118 /// 对行为体施加角冲量。
120
121 /// 对行为体施加扭矩。
122 void AddTorque(const geom::Vector3D& vector);
123
124 /// 启用或禁用该行为体的物理模拟。
125 void SetSimulatePhysics(bool enabled = true);
126
127 /// 启用或禁用该行为体的碰撞。
128 void SetCollisions(bool enabled = true);
129
130 /// 将行为体标记为已死亡并开始其生命周期。
132
133 /// 启用或禁用该行为体的重力。
134 void SetEnableGravity(bool enabled = true);
135
137
141
142 bool IsDormant() const {
144 }
145
146 bool IsActive() const {
148 }
149
150 /// 告诉模拟器销毁该行为体,并返回行为体是否成功被销毁的结果。
151 ///
152 /// @note 如果行为体已经成功销毁,则该函数没有效果。
153 ///
154 /// @warning 此函数会阻塞,直到模拟器完成销毁操作。
155 virtual bool Destroy();
156
157 const auto& Serialize() const {
159 }
160
161 };
162
163 } // namespace client
164} // namespace carla
#define LIBCARLA_INITIALIZE_LIFETIME_PROFILER(display_name)
用于初始化 Actor 类。只有 ActorFactory 可以创建此对象,因此只有 ActorFactory 可以创建 Actor。
表示模拟中的一个行为体(Actor)。
virtual bool Destroy()
告诉模拟器销毁该行为体,并返回行为体是否成功被销毁的结果。
void DisableConstantVelocity()
禁用恒定速度模式。
void AddImpulse(const geom::Vector3D &vector)
在行为体的质心施加冲量。
std::vector< std::string > GetSocketNames() const
void AddAngularImpulse(const geom::Vector3D &vector)
对行为体施加角冲量。
void AddTorque(const geom::Vector3D &vector)
对行为体施加扭矩。
bool IsActive() const
void AddForce(const geom::Vector3D &force, const geom::Vector3D &location)
在某个位置对行为体施加力。
void AddImpulse(const geom::Vector3D &impulse, const geom::Vector3D &location)
在某个位置对行为体施加冲量。
bool IsDormant() const
geom::Location GetLocation() const
返回行为体的当前位置。
std::vector< std::string > GetComponentNames() const
std::vector< geom::Transform > GetSocketRelativeTransforms() const
void SetTransform(const geom::Transform &transform)
将行为体传送并旋转到 transform。
std::vector< std::string > GetBoneNames() const
void SetSimulatePhysics(bool enabled=true)
启用或禁用该行为体的物理模拟。
void AddForce(const geom::Vector3D &force)
在行为体的质心施加力。
void SetEnableGravity(bool enabled=true)
启用或禁用该行为体的重力。
geom::Vector3D GetVelocity() const
返回行为体的当前3D速度。
Actor(ActorInitializer init)
void SetActorDead()
将行为体标记为已死亡并开始其生命周期。
void SetLocation(const geom::Location &location)
将行为体传送到 location。
const auto & Serialize() const
geom::Vector3D GetAngularVelocity() const
返回行为体的当前3D角速度。
geom::Transform GetComponentWorldTransform(const std::string componentName) const
获取指定组件的世界坐标变换。 这个函数返回一个包含位置、旋转和平移信息的Transform对象, 表示指定组件在世界坐标系中的位置和方向。
std::vector< geom::Transform > GetSocketWorldTransforms() const
void EnableConstantVelocity(const geom::Vector3D &vector)
启用恒定速度模式。
void SetTargetAngularVelocity(const geom::Vector3D &vector)
在应用物理之前设置行为体的角速度。
geom::Transform GetTransform() const
返回行为体的当前变换(位置和方向)。
virtual ~Actor()=default
geom::Transform GetComponentRelativeTransform(const std::string componentName) const
获取指定组件相对于Actor的相对坐标变换。 这个函数返回一个包含位置、旋转和平移信息的Transform对象, 表示指定组件相对于Actor原点的位置和方向。
std::vector< geom::Transform > GetBoneWorldTransforms() const
void SetCollisions(bool enabled=true)
启用或禁用该行为体的碰撞。
std::vector< geom::Transform > GetBoneRelativeTransforms() const
geom::Vector3D GetAcceleration() const
返回行为体的当前3D加速度。
void SetTargetVelocity(const geom::Vector3D &vector)
在应用物理之前设置行为体的速度。
rpc::ActorState GetActorState() const
const rpc::Actor & GetActorDescription() const
const std::string & GetDisplayId() const
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
包含CARLA客户端相关类和函数的命名空间。