Agrarsense
OverlapSensor.h
Go to the documentation of this file.
1// Copyright (c) 2023 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "Engine/EngineTypes.h"
10#include "Components/PrimitiveComponent.h"
11
15
16#include "ROSIntegration/Public/std_msgs/String.h"
17
18#include "OverlapSensor.generated.h"
19
20class AVehicle;
21
27UCLASS()
28class AGRARSENSE_API AOverlapSensor : public ASensor
29{
30 GENERATED_BODY()
31
32public:
33
34 AOverlapSensor(const FObjectInitializer& ObjectInitializer);
35
36 UFUNCTION(BlueprintCallable)
37 void Init(FOverlapSensorParameters InParameters);
38
43 virtual ESensorTypes GetSensorType() const override
44 {
46 }
47
51 UFUNCTION(BlueprintCallable)
52 void SetOverlapBounds(const FVector& NewSize);
53
57 UFUNCTION(BlueprintCallable)
58 void SetVisualizeOverlapArea(bool Visualize);
59
63 UFUNCTION(BlueprintCallable)
64 void SetOverlapRelativePosition(const FVector& Vector);
65
73 UFUNCTION(BlueprintCallable)
74 void SetOverlapResponseToAllChannels(const ECollisionResponse Response);
75
76 UFUNCTION(BlueprintCallable)
77 bool IsVisualizingOverlapArea() const
78 {
79 return IsVisible;
80 }
81
82 virtual FString GetParametersAsString() const override
83 {
84 return StructToString(Parameters);
85 }
86
87protected:
88
89 UFUNCTION()
90 void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp,
91 int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
92
93 UFUNCTION()
94 void OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp,
95 int32 OtherBodyIndex);
96
97 UPROPERTY(VisibleAnywhere)
98 UBoundsVisualizerComponent* BoundsComponent = nullptr;
99
100private:
101
102 virtual void BeginPlay() override;
103
104 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
105
106 void BuildAndSendMessage(const FString& Prefix, AActor* Actor);
107
108 FString TryGetID(AActor* Actor);
109
110 TSharedPtr<ROSMessages::std_msgs::String> ROSMessage;
111
113
114 UPROPERTY()
115 AVehicle* Vehicle = nullptr;
116
117 FString VehicleName;
118
119 FString VehicleID;
120
121 bool IsVisible = false;
122
123};
ESensorTypes
Definition: SensorTypes.h:15
virtual FString GetParametersAsString() const override
Definition: OverlapSensor.h:82
virtual ESensorTypes GetSensorType() const override
Definition: OverlapSensor.h:43
Definition: Sensor.h:44
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
Definition: Vehicle.cpp:86
virtual void BeginPlay() override
Definition: Vehicle.cpp:27