CARLA
 
载入中...
搜索中...
未找到
client/Actor.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/Memory.h"
13
14namespace carla {
15namespace client {
16
17 /// Represents an actor in the simulation.
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 /// Return the current location of the actor.
34 ///
35 /// @note This function does not call the simulator, it returns the location
36 /// received in the last tick.
38
39 /// Return the current transform of the actor.
40 ///
41 /// @note This function does not call the simulator, it returns the
42 /// transform received in the last tick.
44
45 /// Return the current 3D velocity of the actor.
46 ///
47 /// @note This function does not call the simulator, it returns the
48 /// velocity received in the last tick.
50
51 /// Return the current 3D angular velocity of the actor.
52 ///
53 /// @note This function does not call the simulator, it returns the
54 /// angular velocity received in the last tick.
56
57 /// Return the current 3D acceleration of the actor.
58 ///
59 /// @note This function does not call the simulator, it returns the
60 /// acceleration calculated after the actor's velocity.
62
63 geom::Transform GetComponentWorldTransform(const std::string componentName) const;
64
65 geom::Transform GetComponentRelativeTransform(const std::string componentName) const;
66
67 std::vector<geom::Transform> GetBoneWorldTransforms() const;
68
69 std::vector<geom::Transform> GetBoneRelativeTransforms() const;
70
71 std::vector<std::string> GetComponentNames() const;
72
73 std::vector<std::string> GetBoneNames() const;
74
75 std::vector<geom::Transform> GetSocketWorldTransforms() const;
76
77 std::vector<geom::Transform> GetSocketRelativeTransforms() const;
78
79 std::vector<std::string> GetSocketNames() const;
80
81 /// Teleport the actor to @a location.
82 void SetLocation(const geom::Location &location);
83
84 /// Teleport and rotate the actor to @a transform.
85 void SetTransform(const geom::Transform &transform);
86
87 /// Set the actor velocity before applying physics.
88 void SetTargetVelocity(const geom::Vector3D &vector);
89
90 /// Set the angular velocity of the actor before applying physics.
91 void SetTargetAngularVelocity(const geom::Vector3D &vector);
92
93 /// Enable a constant velocity mode
94 void EnableConstantVelocity(const geom::Vector3D &vector);
95
96 /// Disable the constant velocity mode
98
99 /// Add impulse to the actor at its center of mass.
100 void AddImpulse(const geom::Vector3D &vector);
101
102 /// Add impulse to the actor at certain location.
103 void AddImpulse(const geom::Vector3D &impulse, const geom::Vector3D &location);
104
105 /// Add force to the actor at its center of mass.
106 void AddForce(const geom::Vector3D &force);
107
108 /// Add force to the actor at certain location.
109 void AddForce(const geom::Vector3D &force, const geom::Vector3D &location);
110
111 /// Add angular impulse to the actor.
112 void AddAngularImpulse(const geom::Vector3D &vector);
113
114 /// Add a torque to the actor.
115 void AddTorque(const geom::Vector3D &vector);
116
117 /// Enable or disable physics simulation on this actor.
118 void SetSimulatePhysics(bool enabled = true);
119
120 /// Enable or disable collisions on this actor.
121 void SetCollisions(bool enabled = true);
122
123 /// Set actor as dead and starts his life span
124 void SetActorDead();
125
126 /// Enable or disable gravity on this actor.
127 void SetEnableGravity(bool enabled = true);
128
130
134
135 bool IsDormant() const {
137 }
138
139 bool IsActive() const {
141 }
142
143 /// Tell the simulator to destroy this Actor, and return whether the actor
144 /// was successfully destroyed.
145 ///
146 /// @note It has no effect if the Actor was already successfully destroyed.
147 ///
148 /// @warning This function blocks until the destruction operation is
149 /// completed by the simulator.
150 virtual bool Destroy();
151
152 const auto &Serialize() const {
154 }
155
156 };
157
158} // namespace client
159} // namespace carla
#define LIBCARLA_INITIALIZE_LIFETIME_PROFILER(display_name)
Used to initialize Actor classes.
Represents an actor in the simulation.
void DisableConstantVelocity()
Disable the constant velocity mode
Definition Actor.cpp:91
void AddImpulse(const geom::Vector3D &vector)
Add impulse to the actor at its center of mass.
Definition Actor.cpp:95
std::vector< std::string > GetSocketNames() const
Definition Actor.cpp:67
void AddAngularImpulse(const geom::Vector3D &vector)
Add angular impulse to the actor.
Definition Actor.cpp:111
virtual bool Destroy()
Tell the simulator to destroy this Actor, and return whether the actor was successfully destroyed.
Definition Actor.cpp:139
void AddTorque(const geom::Vector3D &vector)
Add a torque to the actor.
Definition Actor.cpp:115
bool IsActive() const
bool IsDormant() const
geom::Location GetLocation() const
Return the current location of the actor.
Definition Actor.cpp:15
std::vector< std::string > GetComponentNames() const
Definition Actor.cpp:51
std::vector< geom::Transform > GetSocketRelativeTransforms() const
Definition Actor.cpp:63
void SetTransform(const geom::Transform &transform)
Teleport and rotate the actor to transform.
Definition Actor.cpp:75
std::vector< std::string > GetBoneNames() const
Definition Actor.cpp:55
void SetSimulatePhysics(bool enabled=true)
Enable or disable physics simulation on this actor.
Definition Actor.cpp:119
void AddForce(const geom::Vector3D &force)
Add force to the actor at its center of mass.
Definition Actor.cpp:103
void SetEnableGravity(bool enabled=true)
Enable or disable gravity on this actor.
Definition Actor.cpp:131
geom::Vector3D GetVelocity() const
Return the current 3D velocity of the actor.
Definition Actor.cpp:23
Actor(ActorInitializer init)
void SetActorDead()
Set actor as dead and starts his life span
Definition Actor.cpp:127
void SetLocation(const geom::Location &location)
Teleport the actor to location.
Definition Actor.cpp:71
const auto & Serialize() const
geom::Vector3D GetAngularVelocity() const
Return the current 3D angular velocity of the actor.
Definition Actor.cpp:27
geom::Transform GetComponentWorldTransform(const std::string componentName) const
Definition Actor.cpp:35
std::vector< geom::Transform > GetSocketWorldTransforms() const
Definition Actor.cpp:59
void EnableConstantVelocity(const geom::Vector3D &vector)
Enable a constant velocity mode
Definition Actor.cpp:87
void SetTargetAngularVelocity(const geom::Vector3D &vector)
Set the angular velocity of the actor before applying physics.
Definition Actor.cpp:83
geom::Transform GetTransform() const
Return the current transform of the actor.
Definition Actor.cpp:19
virtual ~Actor()=default
geom::Transform GetComponentRelativeTransform(const std::string componentName) const
Definition Actor.cpp:39
std::vector< geom::Transform > GetBoneWorldTransforms() const
Definition Actor.cpp:43
void SetCollisions(bool enabled=true)
Enable or disable collisions on this actor.
Definition Actor.cpp:123
std::vector< geom::Transform > GetBoneRelativeTransforms() const
Definition Actor.cpp:47
geom::Vector3D GetAcceleration() const
Return the current 3D acceleration of the actor.
Definition Actor.cpp:31
void SetTargetVelocity(const geom::Vector3D &vector)
Set the actor velocity before applying physics.
Definition Actor.cpp:79
rpc::ActorState GetActorState() const
Definition Actor.cpp:135
const rpc::Actor & GetActorDescription() const
const std::string & GetDisplayId() const
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133