CARLA
CollisionEvent.h
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 #pragma once
8 
9 #include "carla/Debug.h"
11 #include "carla/geom/Vector3D.h"
14 
15 namespace carla {
16 namespace sensor {
17 namespace data {
18 
19  /// A registered collision.
20  class CollisionEvent : public SensorData {
21  using Super = SensorData;
22  protected:
23 
25 
26  friend Serializer;
27 
28  explicit CollisionEvent(const RawData &data)
29  : Super(data),
30  _self_actor(Serializer::DeserializeRawData(data).self_actor),
31  _other_actor(Serializer::DeserializeRawData(data).other_actor),
32  _normal_impulse(Serializer::DeserializeRawData(data).normal_impulse) {}
33 
34  public:
35 
36  /// Get "self" actor. Actor that measured the collision.
38  return _self_actor.Get(GetEpisode());
39  }
40 
41  /// Get the actor to which we collided.
43  return _other_actor.Get(GetEpisode());
44  }
45 
46  /// Normal impulse result of the collision.
48  return _normal_impulse;
49  }
50 
51  private:
52 
54 
56 
58  };
59 
60 } // namespace data
61 } // namespace sensor
62 } // namespace carla
Holds an Actor, but only instantiates it when needed.
Definition: ActorVariant.h:30
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition: Memory.h:20
SharedPtr< client::Actor > GetActor() const
Get "self" actor. Actor that measured the collision.
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
client::detail::ActorVariant _self_actor
const auto & GetEpisode() const
Definition: SensorData.h:54
SensorData(size_t frame, double timestamp, const rpc::Transform &sensor_transform)
Definition: SensorData.h:25
Base class for all the objects containing data generated by a sensor.
Definition: SensorData.h:20
CollisionEvent(const RawData &data)
Serializes the current state of the whole episode.
SharedPtr< client::Actor > Get(EpisodeProxy episode) const
Definition: ActorVariant.h:49
A registered collision.
client::detail::ActorVariant _other_actor
const geom::Vector3D & GetNormalImpulse() const
Normal impulse result of the collision.
SharedPtr< client::Actor > GetOtherActor() const
Get the actor to which we collided.
Wrapper around the raw data generated by a sensor plus some useful meta-information.
Definition: RawData.h:21