CARLA
 
载入中...
搜索中...
未找到
CollisionSensor.h
浏览该文件的文档.
1// Copyright (c) 2024 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
14class UCarlaEpisode;
16
17/// A sensor to register collisions.
18UCLASS()
19class CARLA_API ACollisionSensor : public ASensor
20{
21 GENERATED_BODY()
22
23public:
24
25 static FActorDefinition GetSensorDefinition();
26
27 ACollisionSensor(const FObjectInitializer& ObjectInitializer);
28
29 virtual void PrePhysTick(float DeltaSeconds) override;
30 void SetOwner(AActor *NewOwner) override;
31
32 UFUNCTION()
33 void OnCollisionEvent(
34 AActor *Actor,
35 AActor *OtherActor,
36 FVector NormalImpulse,
37 const FHitResult &Hit);
38
39 UFUNCTION(BlueprintCallable, Category="Collision")
40 void OnActorCollisionEvent(
41 AActor *Actor,
42 AActor *OtherActor,
43 FVector NormalImpulse,
44 const FHitResult &Hit);
45
46 UFUNCTION()
47 void OnComponentCollisionEvent(
48 UPrimitiveComponent* HitComp,
49 AActor* OtherActor,
50 UPrimitiveComponent* OtherComp,
51 FVector NormalImpulse,
52 const FHitResult& Hit);
53
54private:
55 /// Registry that saves all collisions. Used to avoid sending the same collision more than once per frame,
56 /// as the collision sensor uses the PhysX substepping tick. Helps with sensor usage and stream overload.
57 std::vector<std::tuple<uint64_t, AActor*, AActor*>> CollisionRegistry;
58};
A sensor to register collisions.
std::vector< std::tuple< uint64_t, AActor *, AActor * > > CollisionRegistry
Registry that saves all collisions.
A simulation episode.
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.