CARLA
Actor.cpp
Go to the documentation of this file.
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 #include "carla/client/Actor.h"
8 
9 #include "carla/Logging.h"
11 
12 namespace carla {
13 namespace client {
14 
16  return GetEpisode().Lock()->GetActorLocation(*this);
17  }
18 
20  return GetEpisode().Lock()->GetActorTransform(*this);
21  }
22 
24  return GetEpisode().Lock()->GetActorVelocity(*this);
25  }
26 
28  return GetEpisode().Lock()->GetActorAngularVelocity(*this);
29  }
30 
32  return GetEpisode().Lock()->GetActorAcceleration(*this);
33  }
34 
35  void Actor::SetLocation(const geom::Location &location) {
36  GetEpisode().Lock()->SetActorLocation(*this, location);
37  }
38 
39  void Actor::SetTransform(const geom::Transform &transform) {
40  GetEpisode().Lock()->SetActorTransform(*this, transform);
41  }
42 
44  GetEpisode().Lock()->SetActorTargetVelocity(*this, vector);
45  }
46 
48  GetEpisode().Lock()->SetActorTargetAngularVelocity(*this, vector);
49  }
50 
52  GetEpisode().Lock()->EnableActorConstantVelocity(*this, vector);
53  }
54 
56  GetEpisode().Lock()->DisableActorConstantVelocity(*this);
57  }
58 
59  void Actor::AddImpulse(const geom::Vector3D &impulse) {
60  GetEpisode().Lock()->AddActorImpulse(*this, impulse);
61  }
62 
63  void Actor::AddImpulse(const geom::Vector3D &impulse, const geom::Vector3D &location) {
64  GetEpisode().Lock()->AddActorImpulse(*this, impulse, location);
65  }
66 
67  void Actor::AddForce(const geom::Vector3D &force) {
68  GetEpisode().Lock()->AddActorForce(*this, force);
69  }
70 
71  void Actor::AddForce(const geom::Vector3D &force, const geom::Vector3D &location) {
72  GetEpisode().Lock()->AddActorForce(*this, force, location);
73  }
74 
76  GetEpisode().Lock()->AddActorAngularImpulse(*this, vector);
77  }
78 
79  void Actor::AddTorque(const geom::Vector3D &torque) {
80  GetEpisode().Lock()->AddActorTorque(*this, torque);
81  }
82 
83  void Actor::SetSimulatePhysics(const bool enabled) {
84  GetEpisode().Lock()->SetActorSimulatePhysics(*this, enabled);
85  }
86 
87  void Actor::SetEnableGravity(const bool enabled) {
88  GetEpisode().Lock()->SetActorEnableGravity(*this, enabled);
89  }
90 
91  bool Actor::Destroy() {
92  if (IsAlive()) {
93  // Let the exceptions leave the function, IsAlive() will still be true.
94  _is_alive = !GetEpisode().Lock()->DestroyActor(*this);
95  } else {
97  "attempting to destroy an actor that is already dead:",
98  GetDisplayId());
99  _is_alive = false;
100  }
101  return _is_alive;
102  }
103 
104 } // namespace client
105 } // namespace carla
void SetSimulatePhysics(bool enabled=true)
Enable or disable physics simulation on this actor.
Definition: Actor.cpp:83
geom::Vector3D GetAcceleration() const
Return the current 3D acceleration of the actor.
Definition: Actor.cpp:31
void AddForce(const geom::Vector3D &force)
Add force to the actor at its center of mass.
Definition: Actor.cpp:67
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:99
void SetTransform(const geom::Transform &transform)
Teleport and rotate the actor to transform.
Definition: Actor.cpp:39
void AddAngularImpulse(const geom::Vector3D &vector)
Add angular impulse to the actor.
Definition: Actor.cpp:75
const std::string & GetDisplayId() const
Definition: ActorState.h:33
void AddImpulse(const geom::Vector3D &vector)
Add impulse to the actor at its center of mass.
Definition: Actor.cpp:59
virtual bool Destroy()
Tell the simulator to destroy this Actor, and return whether the actor was successfully destroyed...
Definition: Actor.cpp:91
geom::Vector3D GetAngularVelocity() const
Return the current 3D angular velocity of the actor.
Definition: Actor.cpp:27
geom::Transform GetTransform() const
Return the current transform of the actor.
Definition: Actor.cpp:19
void SetTargetAngularVelocity(const geom::Vector3D &vector)
Set the angular velocity of the actor before applying physics.
Definition: Actor.cpp:47
static void log_warning(Args &&... args)
Definition: Logging.h:96
geom::Location GetLocation() const
Return the current location of the actor.
Definition: Actor.cpp:15
void SetLocation(const geom::Location &location)
Teleport the actor to location.
Definition: Actor.cpp:35
void SetTargetVelocity(const geom::Vector3D &vector)
Set the actor velocity before applying physics.
Definition: Actor.cpp:43
geom::Vector3D GetVelocity() const
Return the current 3D velocity of the actor.
Definition: Actor.cpp:23
void EnableConstantVelocity(const geom::Vector3D &vector)
Enable a constant velocity mode.
Definition: Actor.cpp:51
SharedPtrType Lock() const
Same as TryLock but never return nullptr.
void SetEnableGravity(bool enabled=true)
Enable or disable gravity on this actor.
Definition: Actor.cpp:87
bool IsAlive() const
Definition: client/Actor.h:108
void AddTorque(const geom::Vector3D &vector)
Add a torque to the actor.
Definition: Actor.cpp:79
void DisableConstantVelocity()
Disable the constant velocity mode.
Definition: Actor.cpp:55