CARLA
CollisionSensor.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 
10 #include "Carla/Sensor/Sensor.h"
11 
12 #include "CollisionSensor.generated.h"
13 
14 class UCarlaEpisode;
15 class UCarlaGameInstance;
16 
17 /// A sensor to register collisions.
18 UCLASS()
19 class CARLA_API ACollisionSensor : public ASensor
20 {
21  GENERATED_BODY()
22 
23 public:
24 
25  static FActorDefinition GetSensorDefinition();
26 
27  ACollisionSensor(const FObjectInitializer& ObjectInitializer);
28 
29  void SetOwner(AActor *NewOwner) override;
30 
31 private:
32 
33  UFUNCTION()
34  void OnCollisionEvent(
35  AActor *Actor,
36  AActor *OtherActor,
37  FVector NormalImpulse,
38  const FHitResult &Hit);
39 
40  /// Registry that saves all collisions. Used to avoid sending the same collision more than once per frame,
41  /// as the collision sensor uses the PhysX substepping tick. Helps with sensor usage and stream overload.
42  std::vector<std::tuple<uint64_t, AActor*, AActor*>> CollisionRegistry;
43 };
The game instance contains elements that must be kept alive in between levels.
A definition of a Carla Actor with all the variation and attributes.
std::vector< std::tuple< uint64_t, AActor *, AActor * > > CollisionRegistry
Registry that saves all collisions.
carla::SharedPtr< cc::Actor > Actor
A simulation episode.
Definition: CarlaEpisode.h:38
A sensor to register collisions.