CARLA
Loading...
Searching...
No Matches
client/Actor.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/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 /// Return the world-space transform of the scene component named
64 /// @a component_name attached to the actor.
65 geom::Transform GetComponentWorldTransform(const std::string &component_name) const;
66
67 /// Return the parent-relative transform of the scene component named
68 /// @a component_name attached to the actor.
69 geom::Transform GetComponentRelativeTransform(const std::string &component_name) const;
70
71 /// Return the world-space transforms of every bone reachable from the
72 /// actor's skinned mesh components.
73 std::vector<geom::Transform> GetBoneWorldTransforms() const;
74
75 /// Return the component-space transforms of every bone reachable from
76 /// the actor's skinned mesh components. Each transform is the bone's
77 /// local pose multiplied by `FTransform::Identity`, so the result is
78 /// expressed in the owning `USkinnedMeshComponent`'s space, not
79 /// relative to the bone's parent.
80 std::vector<geom::Transform> GetBoneRelativeTransforms() const;
81
82 /// Return the names of every actor component attached to the actor.
83 std::vector<std::string> GetComponentNames() const;
84
85 /// Return the names of every bone reachable from the actor's first
86 /// skinned mesh component.
87 std::vector<std::string> GetBoneNames() const;
88
89 /// Return the world-space transforms of every socket on every scene
90 /// component attached to the actor.
91 std::vector<geom::Transform> GetSocketWorldTransforms() const;
92
93 /// Return the actor-relative transforms of every socket on every scene
94 /// component attached to the actor.
95 std::vector<geom::Transform> GetSocketRelativeTransforms() const;
96
97 /// Return the names of every socket on every scene component attached
98 /// to the actor.
99 std::vector<std::string> GetSocketNames() const;
100
101 /// Return the name of the underlying Unreal actor.
102 ///
103 /// @note This function does not call the simulator, it returns the
104 /// acceleration calculated after the actor's velocity.
105 std::string GetActorName() const;
106
107 /// Return the name of the underlying actor's Unreal class.
108 ///
109 /// @note This function does not call the simulator, it returns the
110 /// acceleration calculated after the actor's velocity.
111 std::string GetActorClassName() const;
112
113 /// Teleport the actor to @a location.
114 void SetLocation(const geom::Location &location);
115
116 /// Teleport and rotate the actor to @a transform.
117 void SetTransform(const geom::Transform &transform);
118
119 /// Set the actor velocity before applying physics.
120 void SetTargetVelocity(const geom::Vector3D &vector);
121
122 /// Set the angular velocity of the actor before applying physics.
123 void SetTargetAngularVelocity(const geom::Vector3D &vector);
124
125 /// Enable a constant velocity mode
126 void EnableConstantVelocity(const geom::Vector3D &vector);
127
128 /// Disable the constant velocity mode
130
131 /// Enable a constant acceleration mode (direct acceleration, no pedal input)
132 void EnableConstantAcceleration(const geom::Vector3D &vector);
133
134 /// Disable the constant acceleration mode
136
137 /// Add impulse to the actor at its center of mass.
138 void AddImpulse(const geom::Vector3D &vector);
139
140 /// Add impulse to the actor at certain location.
141 void AddImpulse(const geom::Vector3D &impulse, const geom::Vector3D &location);
142
143 /// Add force to the actor at its center of mass.
144 void AddForce(const geom::Vector3D &force);
145
146 /// Add force to the actor at certain location.
147 void AddForce(const geom::Vector3D &force, const geom::Vector3D &location);
148
149 /// Add angular impulse to the actor.
150 void AddAngularImpulse(const geom::Vector3D &vector);
151
152 /// Add a torque to the actor.
153 void AddTorque(const geom::Vector3D &vector);
154
155 /// Enable or disable physics simulation on this actor.
156 void SetSimulatePhysics(bool enabled = true);
157
158 /// Enable or disable collisions on this actor.
159 void SetCollisions(bool enabled = true);
160
161 /// Set actor as dead and starts his life span
162 void SetActorDead();
163
164 /// Enable or disable gravity on this actor.
165 void SetEnableGravity(bool enabled = true);
166
167 void ApplyTexture(
168 const rpc::MaterialParameter& MaterialParameter,
169 const rpc::TextureColor& Texture);
170
171 void ApplyTexture(
172 const rpc::MaterialParameter& MaterialParameter,
173 const rpc::TextureFloatColor& Texture);
174
176
180
181 bool IsDormant() const {
183 }
184
185 bool IsActive() const {
187 }
188
189 /// Tell the simulator to destroy this Actor, and return whether the actor
190 /// was successfully destroyed.
191 ///
192 /// @note It has no effect if the Actor was already successfully destroyed.
193 ///
194 /// @warning This function blocks until the destruction operation is
195 /// completed by the simulator.
196 virtual bool Destroy();
197
198 const auto &Serialize() const {
200 }
201
202 };
203
204} // namespace client
205} // 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:101
void AddImpulse(const geom::Vector3D &vector)
Add impulse to the actor at its center of mass.
Definition Actor.cpp:113
std::vector< std::string > GetSocketNames() const
Return the names of every socket on every scene component attached to the actor.
Definition Actor.cpp:67
void AddAngularImpulse(const geom::Vector3D &vector)
Add angular impulse to the actor.
Definition Actor.cpp:129
virtual bool Destroy()
Tell the simulator to destroy this Actor, and return whether the actor was successfully destroyed.
Definition Actor.cpp:171
void AddTorque(const geom::Vector3D &vector)
Add a torque to the actor.
Definition Actor.cpp:133
bool IsActive() const
void EnableConstantAcceleration(const geom::Vector3D &vector)
Enable a constant acceleration mode (direct acceleration, no pedal input)
Definition Actor.cpp:105
bool IsDormant() const
geom::Location GetLocation() const
Return the current location of the actor.
Definition Actor.cpp:15
std::vector< std::string > GetComponentNames() const
Return the names of every actor component attached to the actor.
Definition Actor.cpp:51
std::vector< geom::Transform > GetSocketRelativeTransforms() const
Return the actor-relative transforms of every socket on every scene component attached to the actor.
Definition Actor.cpp:63
void SetTransform(const geom::Transform &transform)
Teleport and rotate the actor to transform.
Definition Actor.cpp:85
std::vector< std::string > GetBoneNames() const
Return the names of every bone reachable from the actor's first skinned mesh component.
Definition Actor.cpp:55
void SetSimulatePhysics(bool enabled=true)
Enable or disable physics simulation on this actor.
Definition Actor.cpp:137
void AddForce(const geom::Vector3D &force)
Add force to the actor at its center of mass.
Definition Actor.cpp:121
void SetEnableGravity(bool enabled=true)
Enable or disable gravity on this actor.
Definition Actor.cpp:149
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:145
void SetLocation(const geom::Location &location)
Teleport the actor to location.
Definition Actor.cpp:81
const auto & Serialize() const
geom::Transform GetComponentWorldTransform(const std::string &component_name) const
Return the world-space transform of the scene component named component_name attached to the actor.
Definition Actor.cpp:35
geom::Vector3D GetAngularVelocity() const
Return the current 3D angular velocity of the actor.
Definition Actor.cpp:27
std::vector< geom::Transform > GetSocketWorldTransforms() const
Return the world-space transforms of every socket on every scene component attached to the actor.
Definition Actor.cpp:59
std::string GetActorName() const
Return the name of the underlying Unreal actor.
Definition Actor.cpp:71
void EnableConstantVelocity(const geom::Vector3D &vector)
Enable a constant velocity mode.
Definition Actor.cpp:97
void ApplyTexture(const rpc::MaterialParameter &MaterialParameter, const rpc::TextureColor &Texture)
Definition Actor.cpp:153
std::string GetActorClassName() const
Return the name of the underlying actor's Unreal class.
Definition Actor.cpp:76
void SetTargetAngularVelocity(const geom::Vector3D &vector)
Set the angular velocity of the actor before applying physics.
Definition Actor.cpp:93
geom::Transform GetTransform() const
Return the current transform of the actor.
Definition Actor.cpp:19
virtual ~Actor()=default
std::vector< geom::Transform > GetBoneWorldTransforms() const
Return the world-space transforms of every bone reachable from the actor's skinned mesh components.
Definition Actor.cpp:43
void SetCollisions(bool enabled=true)
Enable or disable collisions on this actor.
Definition Actor.cpp:141
std::vector< geom::Transform > GetBoneRelativeTransforms() const
Return the component-space transforms of every bone reachable from the actor's skinned mesh component...
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:89
rpc::ActorState GetActorState() const
Definition Actor.cpp:167
void DisableConstantAcceleration()
Disable the constant acceleration mode.
Definition Actor.cpp:109
geom::Transform GetComponentRelativeTransform(const std::string &component_name) const
Return the parent-relative transform of the scene component named component_name attached to the acto...
Definition Actor.cpp:39
const rpc::Actor & GetActorDescription() const
const std::string & GetDisplayId() const
A rigid transform in CARLA's / Unreal's left-handed frame: x forward, y right, z up,...
This file contains definitions of common data structures used in traffic manager.