Agrarsense
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
AOverlapSensor Class Reference

#include <OverlapSensor.h>

Inheritance diagram for AOverlapSensor:
Inheritance graph
[legend]
Collaboration diagram for AOverlapSensor:
Collaboration graph
[legend]

Public Member Functions

 AOverlapSensor (const FObjectInitializer &ObjectInitializer)
 
void Init (FOverlapSensorParameters InParameters)
 
virtual ESensorTypes GetSensorType () const override
 
void SetOverlapBounds (const FVector &NewSize)
 
void SetVisualizeOverlapArea (bool Visualize)
 
void SetOverlapRelativePosition (const FVector &Vector)
 
void SetOverlapResponseToAllChannels (const ECollisionResponse Response)
 
bool IsVisualizingOverlapArea () const
 
virtual FString GetParametersAsString () const override
 
- Public Member Functions inherited from ASensor
 ASensor (const FObjectInitializer &ObjectInitializer)
 
FString ExportToJsonFile (const FString &FileName)
 
virtual ESensorTypes GetSensorType () const
 
FString GetSensorIdentifier () const
 
void SetSensorIdentifier (const FString newIdentifier)
 
FString GetSensorName () const
 
virtual FString GetParametersAsString () const
 
AVehicleIsAttachedToVehicle () const
 
void SetSensorName (const FString newName)
 
FString GetTopicName ()
 
UTopic * GetROSTopic () const
 
void SetSimulateSensor (bool SimulateSensor)
 
bool CanSimulateSensor () const
 
ASensorModelGetSensorModel () const
 
void SetSensorModel (ASensorModel *NewSensorModel)
 
FORCEINLINE bool IsROSConnected () const
 
UROSIntegrationGameInstance * GetROSGameInstance () const
 
virtual FString GetActorID_Implementation () const override
 
virtual FString GetActorName_Implementation () const override
 
virtual FString GetActorInformation_Implementation () const override
 
virtual void SetActorName_Implementation (const FString &NewActorName) override
 
virtual void SetActorIDAndName_Implementation (const FString &NewActorName, const FString &NewID) override
 
void SetParentActorPtr (AActor *ParentActorPtr)
 
- Public Member Functions inherited from IActorInformation
FString GetActorID () const
 
FString GetActorName () const
 
FString GetActorInformation () const
 
void SetActorName (const FString &NewActorName)
 
void SetActorIDAndName (const FString &NewActorName, const FString &NewID)
 

Protected Member Functions

void OnOverlapBegin (UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
 
void OnOverlapEnd (UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex)
 
FORCEINLINE bool IsValidOverlap (const AActor *OtherActor, const UPrimitiveComponent *OtherComp) const
 
- Protected Member Functions inherited from ASensor
virtual void BeginPlay () override
 
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 
FString CreateTimeStampString () const
 
virtual void CreateROSTopic ()
 
virtual void DestroyROSTopic ()
 
virtual void CreateDataSavePath ()
 
bool IsLogFileCreated ()
 
virtual void CreateLogFile ()
 
void WriteToLogFile (const FString &Message)
 

Protected Attributes

UBoundsVisualizerComponent * BoundsComponent = nullptr
 
- Protected Attributes inherited from ASensor
UTopic * ROSTopic = nullptr
 
bool SendDataToROS = true
 
ULogFileLogFile = nullptr
 
AActor * ParentActor = nullptr
 
FString FileSavePath
 
UROSIntegrationGameInstance * ROSInstance = nullptr
 

Private Member Functions

virtual void BeginPlay () override
 
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 
void BuildAndSendMessage (const FString &Prefix, AActor *Actor, UPrimitiveComponent *Comp, int32 Index)
 
void CreateDataSavePath () override
 
void CreateLogFile () override
 
FString TryGetID (AActor *Actor)
 

Private Attributes

TSharedPtr< ROSMessages::std_msgs::String > ROSMessage
 
FOverlapSensorParameters Parameters
 
AVehicleVehicle = nullptr
 
FString VehicleName
 
FString VehicleID
 
bool IsVisible = false
 

Additional Inherited Members

- Static Public Member Functions inherited from ASensor
static void HideComponentForAllCameras (UPrimitiveComponent *PrimitiveComponent)
 
static TMap< FString, FColor > GetSemanticColors ()
 
static TArray< TWeakObjectPtr< UPrimitiveComponent > > GetComponentsToHide ()
 
- Static Public Member Functions inherited from IActorInformation
static void SetAndValidateActorIDAndName (FString &ActorName, FString &ActorID, TWeakObjectPtr< AActor > Actor)
 
static bool DestroyActorByID (const FString &ID)
 
static AActor * GetActorByID (const FString &ID)
 
template<typename T >
static TArray< T * > GetActorsWithInterface ()
 
static void PrintAllIds ()
 
- Public Attributes inherited from ASensor
FSensorDestroy OnSensorDestroy
 
FString AttachedToComponent
 
FName AttachedToBone
 
- Static Protected Member Functions inherited from ASensor
template<typename InStructType >
static FString StructToString (const InStructType &InStruct)
 
- Static Protected Attributes inherited from ASensor
static FPrimitiveAdded OnPrimitiveAdded
 
static const FName NiagaraPointsInt = "User.PointCount"
 
static const FName NiagaraHitPoints = "User.HitPoints"
 
static const FName NiagaraHitColors = "User.HitColors"
 
static const FName NiagaraPointsFloat = "User.Test"
 

Detailed Description

Overlap sensor is a sensor that detects overlap starts and ends with objects in the simulation. Allowed overlapped components: StaticMeshComponent, InstancedStaticMeshComponent and SkeletalMeshComponent. All other components are ignored.

Definition at line 28 of file OverlapSensor.h.

Constructor & Destructor Documentation

◆ AOverlapSensor()

AOverlapSensor::AOverlapSensor ( const FObjectInitializer &  ObjectInitializer)

Definition at line 20 of file OverlapSensor.cpp.

20 : Super(ObjectInitializer)
21{
22 PrimaryActorTick.bCanEverTick = false;
23
24 BoundsComponent = CreateDefaultSubobject<UBoundsVisualizerComponent>(TEXT("BoundsComponent"));
25 BoundsComponent->SetupAttachment(RootComponent);
26 BoundsComponent->SetGenerateOverlapEvents(true);
27 BoundsComponent->SetVisibility(false);
28 BoundsComponent->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
29}
UBoundsVisualizerComponent * BoundsComponent
Definition: OverlapSensor.h:98

References BoundsComponent.

Member Function Documentation

◆ BeginPlay()

void AOverlapSensor::BeginPlay ( )
overrideprivatevirtual

Reimplemented from ASensor.

Definition at line 106 of file OverlapSensor.cpp.

107{
108 Super::BeginPlay();
109
110 BoundsComponent->OnComponentBeginOverlap.AddDynamic(this, &AOverlapSensor::OnOverlapBegin);
111 BoundsComponent->OnComponentEndOverlap.AddDynamic(this, &AOverlapSensor::OnOverlapEnd);
112}
void OnOverlapEnd(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex)
void OnOverlapBegin(UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)

References BoundsComponent, OnOverlapBegin(), and OnOverlapEnd().

◆ BuildAndSendMessage()

void AOverlapSensor::BuildAndSendMessage ( const FString &  Prefix,
AActor *  Actor,
UPrimitiveComponent *  Comp,
int32  Index 
)
private

Definition at line 203 of file OverlapSensor.cpp.

204{
205 if (!Actor) return;
206
207 const FString ID = TryGetID(Actor);
208
209 AActor* From = this;
210 if (AActor* VehicleActorPtr = GetParentActor())
211 {
212 From = VehicleActorPtr;
213 }
214
215 if (Vehicle == Actor)
216 {
217 // BP_Drone is implemented in a way that the Actor itself doesn't move,
218 // only its skeletal mesh component does. So ignore overlapping with the vehicle itself.
219 return;
220 }
221
222 FVector Location = Actor->GetActorLocation();
223
224 if (Comp)
225 {
226 if (const UInstancedStaticMeshComponent* ISM = Cast<UInstancedStaticMeshComponent>(Comp))
227 {
228 if (Index >= 0)
229 {
230 FTransform Xf;
231 if (ISM->GetInstanceTransform(Index, Xf, true))
232 {
233 // If ISM and valid index, use the instance's world transform for location
234 Location = Xf.GetLocation();
235 }
236 }
237 }
238 }
239
240 // Distance from sensor parent (vehicle) to the (instance) location
241 const float DistanceInMeters = FVector::Dist(From->GetActorLocation(), Location) / 100.0f;
242
243 const FString Phase = Prefix.Replace(TEXT(" "), TEXT("_"));
244 const FString ActorNm = Actor->GetName();
245 const FString CompCls = Comp ? Comp->GetClass()->GetName() : TEXT("none");
246
247 // Try to get the mesh name
248 FString MeshName;
249 if (const UInstancedStaticMeshComponent* ISM = Cast<UInstancedStaticMeshComponent>(Comp))
250 {
251 if (const UStaticMesh* SM = ISM->GetStaticMesh()) { MeshName = SM->GetName(); }
252 }
253 else if (const UStaticMeshComponent* SMC = Cast<UStaticMeshComponent>(Comp))
254 {
255 if (const UStaticMesh* SM = SMC->GetStaticMesh()) { MeshName = SM->GetName(); }
256 }
257 else if (const USkeletalMeshComponent* SKC = Cast<USkeletalMeshComponent>(Comp))
258 {
259 if (const USkeletalMesh* Skel = SKC->GetSkeletalMeshAsset()) { MeshName = Skel->GetName(); }
260 }
261
262 auto Quote = [](FString S)
263 {
264 S.ReplaceInline(TEXT("\""), TEXT("\\\"")); return FString::Printf(TEXT("%s"), *S);
265 };
266 const FString Timestamp = CreateTimeStampString();
267
268 const FString FullMessage = FString::Printf(
269 TEXT("phase=%s actor=%s id=%s distance_m=%.2f location=%.2f,%.2f,%.2f component=%s mesh=%s timestamp=%s"),
270 *Phase,
271 *Quote(ActorNm),
272 *Quote(ID),
273 DistanceInMeters,
274 Location.X, Location.Y, Location.Z,
275 *CompCls,
276 *Quote(MeshName),
277 *Quote(Timestamp));
278
279 UTopic* Topic = GetROSTopic();
280 if (ROSMessage.IsValid() && Topic && IsROSConnected())
281 {
282 ROSMessage->_Data = FullMessage;
283 Topic->Publish(ROSMessage);
284 }
285
286 WriteToLogFile(FullMessage);
287}
TSharedPtr< ROSMessages::std_msgs::String > ROSMessage
AVehicle * Vehicle
FString TryGetID(AActor *Actor)
UTopic * GetROSTopic() const
Definition: Sensor.h:150
FString CreateTimeStampString() const
Definition: Sensor.cpp:330
void WriteToLogFile(const FString &Message)
Definition: Sensor.cpp:302
FORCEINLINE bool IsROSConnected() const
Definition: Sensor.h:201

References ASensor::CreateTimeStampString(), ASensor::GetROSTopic(), ASensor::IsROSConnected(), ROSMessage, TryGetID(), Vehicle, and ASensor::WriteToLogFile().

Referenced by OnOverlapBegin(), and OnOverlapEnd().

◆ CreateDataSavePath()

void AOverlapSensor::CreateDataSavePath ( )
overrideprivatevirtual

Creates data save path for this sensor. Can be overriden if needed.

Reimplemented from ASensor.

Definition at line 289 of file OverlapSensor.cpp.

290{
291 if (!FileSavePath.IsEmpty())
292 {
293 return;
294 }
295
296 const FString DataLocation = UAgrarsensePaths::GetDataFolder();
297
298 // Default save path
299 FileSavePath = DataLocation + GetActorID_Implementation() + "/";
300
301 if (AVehicle* AttachedVehicle = IsAttachedToVehicle())
302 {
303 // If sensor is attached to vehicle, save data to vehicle folder
304 FileSavePath = DataLocation + AttachedVehicle->GetActorID_Implementation();
305 }
306}
AVehicle * IsAttachedToVehicle() const
Definition: Sensor.cpp:159
virtual FString GetActorID_Implementation() const override
Definition: Sensor.h:216
FString FileSavePath
Definition: Sensor.h:372
static FString GetDataFolder()

References ASensor::FileSavePath, ASensor::GetActorID_Implementation(), UAgrarsensePaths::GetDataFolder(), and ASensor::IsAttachedToVehicle().

Referenced by CreateLogFile().

◆ CreateLogFile()

void AOverlapSensor::CreateLogFile ( )
overrideprivatevirtual

Create Text file for this sensor if it has not been created already. Text file will be created to ROOT/Data/Run/Logs directory. Filename will be SensorName_ID_UnixTimestamp.txt Can be overriden by individual sensor if needed.

Reimplemented from ASensor.

Definition at line 308 of file OverlapSensor.cpp.

309{
310 if (IsValid(LogFile))
311 {
312 // File has already been created, return
313 return;
314 }
315
317
318 FLogFileSettings Settings;
321 Settings.QueueLength = MAX_int32;
322 Settings.KeepFileOpen = false;
323 Settings.Timestamp = false;
324 Settings.OverrideFilePath = true;
325 Settings.FilePath = FileSavePath;
326
327 UE_LOG(LogTemp, Warning, TEXT("FileSavePath %s"), *FileSavePath);
328
329 LogFile = NewObject<ULogFile>(ULogFile::StaticClass());
330 if (IsValid(LogFile))
331 {
332 FString Prefix;
333 if (AVehicle* AttachedVehicle = IsAttachedToVehicle())
334 {
335 Prefix = AttachedVehicle->GetActorID_Implementation();
336 }
337 FString FileName = Prefix.IsEmpty() ? TEXT("overlap") : Prefix + TEXT("_overlap");
338
339 LogFile->Create(FileName, Settings);
340 }
341}
void CreateDataSavePath() override
ULogFile * LogFile
Definition: Sensor.h:367
void Create(const FString &FileNameWithoutExtension, FLogFileSettings Settings)
Definition: LogFile.cpp:40
bool KeepFileOpen
Definition: LogFile.h:42
bool Timestamp
Definition: LogFile.h:39
FString FilePath
Definition: LogFile.h:54
FFileWriteOptions FileWriteOptions
Definition: LogFile.h:45
int32 QueueLength
Definition: LogFile.h:48
bool OverrideFilePath
Definition: LogFile.h:51
FFileCreationOptions FileCreationOptions
Definition: LogFile.h:36

References ULogFile::Create(), CreateDataSavePath(), FLogFileSettings::FileCreationOptions, FLogFileSettings::FilePath, ASensor::FileSavePath, FLogFileSettings::FileWriteOptions, ASensor::IsAttachedToVehicle(), FLogFileSettings::KeepFileOpen, ASensor::LogFile, FLogFileSettings::OverrideFilePath, Overwrite, Queue, FLogFileSettings::QueueLength, and FLogFileSettings::Timestamp.

Referenced by Init().

◆ EndPlay()

void AOverlapSensor::EndPlay ( const EEndPlayReason::Type  EndPlayReason)
overrideprivatevirtual

Reimplemented from ASensor.

Definition at line 114 of file OverlapSensor.cpp.

115{
116 Super::EndPlay(EndPlayReason);
117
118 BoundsComponent->OnComponentBeginOverlap.RemoveDynamic(this, &AOverlapSensor::OnOverlapBegin);
119 BoundsComponent->OnComponentEndOverlap.RemoveDynamic(this, &AOverlapSensor::OnOverlapEnd);
120}

References BoundsComponent, OnOverlapBegin(), and OnOverlapEnd().

◆ GetParametersAsString()

virtual FString AOverlapSensor::GetParametersAsString ( ) const
inlineoverridevirtual

Get this sensor parameters as string

Reimplemented from ASensor.

Definition at line 82 of file OverlapSensor.h.

83 {
85 }
FOverlapSensorParameters Parameters
static FString StructToString(const InStructType &InStruct)
Definition: Sensor.h:325

◆ GetSensorType()

virtual ESensorTypes AOverlapSensor::GetSensorType ( ) const
inlineoverridevirtual

Get type of the sensor

Returns
Sensor's type

Reimplemented from ASensor.

Definition at line 43 of file OverlapSensor.h.

44 {
46 }

References Overlap.

◆ Init()

void AOverlapSensor::Init ( FOverlapSensorParameters  InParameters)

Definition at line 31 of file OverlapSensor.cpp.

32{
33 Parameters = InParameters;
34
35 Vehicle = Cast<AVehicle>(Parameters.OwningActor);
36
37 if (Vehicle)
38 {
39 VehicleName = IActorInformation::Execute_GetActorName(Vehicle);
40 VehicleID = IActorInformation::Execute_GetActorID(Vehicle);
41 }
42
43 UPrimitiveComponent* TriggerComponent = Cast<UPrimitiveComponent>(BoundsComponent);
44
45 if (!InParameters.AllChannels)
46 {
47 const int32 OverlapSensorIndex = 2;
48 const ECollisionChannel OverlapSensorChannel = UCollisionProfile::Get()->ConvertToCollisionChannel(false, OverlapSensorIndex);
49
50 BoundsComponent->SetCollisionObjectType(OverlapSensorChannel);
51 BoundsComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
52 BoundsComponent->SetCollisionResponseToChannel(OverlapSensorChannel, ECollisionResponse::ECR_Overlap);
53 }
54 else
55 {
56 // Set to use custom collision profile defined in DefaultEngine.ini
57 BoundsComponent->SetCollisionProfileName(TEXT("OverlapSensorAll"));
58 }
59
60 BoundsComponent->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
61 BoundsComponent->SetGenerateOverlapEvents(true);
62 BoundsComponent->SetRelativeLocation(Parameters.RelativePosition);
63
64 if (RootComponent)
65 {
66 BoundsComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepWorldTransform);
67 }
68
69 TriggerComponent = BoundsComponent;
70
71 if (TriggerComponent)
72 {
73 SetOverlapBounds(InParameters.Size);
74 //SetRootComponent(TriggerComponent);
76
77 ROSMessages::std_msgs::String StringMsg;
78 ROSMessage = MakeShared<ROSMessages::std_msgs::String>(StringMsg);
79
81 {
83 }
84 }
85
87 {
88 FVector Size = FVector(Parameters.Size.X, Parameters.Size.Y, Parameters.Size.Z);
89 BoundsComponent->SetRelativeScale3D(Size);
90 BoundsComponent->SetRelativeLocation(Parameters.RelativePosition);
91
92 if (RootComponent)
93 {
94 BoundsComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepWorldTransform);
95 }
96 }
97
99 {
100 AttachToActor(Parameters.OwningActor, FAttachmentTransformRules::KeepWorldTransform);
101 }
102
104}
FString VehicleName
void CreateLogFile() override
void SetOverlapBounds(const FVector &NewSize)
void SetSimulateSensor(bool SimulateSensor)
Definition: Sensor.h:160
virtual void CreateROSTopic()
Definition: Sensor.cpp:197

References FOverlapSensorParameters::AllChannels, BoundsComponent, CreateLogFile(), FOverlapSensorParameters::CreateROSTopic, ASensor::CreateROSTopic(), FOverlapSensorParameters::OwningActor, Parameters, FOverlapSensorParameters::RelativePosition, ROSMessage, SetOverlapBounds(), ASensor::SetSimulateSensor(), FOverlapSensorParameters::Size, Vehicle, VehicleID, and VehicleName.

Referenced by USensorFactory::SpawnOverlapSensor().

◆ IsValidOverlap()

bool AOverlapSensor::IsValidOverlap ( const AActor *  OtherActor,
const UPrimitiveComponent *  OtherComp 
) const
protected

Definition at line 191 of file OverlapSensor.cpp.

192{
193 if (!IsValid(OtherComp)) return false;
194 if (OtherActor && OtherActor->IsA<AOverlapSensor>()) return false;
195 if (OtherComp->IsA<UBoundsVisualizerComponent>()) return false;
196
197 // Only consider overlaps with these component types
198 return OtherComp->IsA<UInstancedStaticMeshComponent>() ||
199 OtherComp->IsA<UStaticMeshComponent>() ||
200 OtherComp->IsA<USkeletalMeshComponent>();
201}

Referenced by OnOverlapBegin(), and OnOverlapEnd().

◆ IsVisualizingOverlapArea()

bool AOverlapSensor::IsVisualizingOverlapArea ( ) const
inline

Definition at line 77 of file OverlapSensor.h.

78 {
79 return IsVisible;
80 }

◆ OnOverlapBegin()

void AOverlapSensor::OnOverlapBegin ( UPrimitiveComponent *  OverlappedComponent,
AActor *  OtherActor,
UPrimitiveComponent *  OtherComp,
int32  OtherBodyIndex,
bool  bFromSweep,
const FHitResult &  SweepResult 
)
protected

Definition at line 175 of file OverlapSensor.cpp.

176{
177 if (IsValidOverlap(OtherActor, OtherComp))
178 {
179 BuildAndSendMessage("Overlap Begin", OtherActor, OtherComp, OtherBodyIndex);
180 }
181}
void BuildAndSendMessage(const FString &Prefix, AActor *Actor, UPrimitiveComponent *Comp, int32 Index)
FORCEINLINE bool IsValidOverlap(const AActor *OtherActor, const UPrimitiveComponent *OtherComp) const

References BuildAndSendMessage(), and IsValidOverlap().

Referenced by BeginPlay(), and EndPlay().

◆ OnOverlapEnd()

void AOverlapSensor::OnOverlapEnd ( UPrimitiveComponent *  OverlappedComponent,
AActor *  OtherActor,
UPrimitiveComponent *  OtherComp,
int32  OtherBodyIndex 
)
protected

Definition at line 183 of file OverlapSensor.cpp.

184{
185 if (IsValidOverlap(OtherActor, OtherComp))
186 {
187 BuildAndSendMessage("Overlap End", OtherActor, OtherComp, OtherBodyIndex);
188 }
189}

References BuildAndSendMessage(), and IsValidOverlap().

Referenced by BeginPlay(), and EndPlay().

◆ SetOverlapBounds()

void AOverlapSensor::SetOverlapBounds ( const FVector &  NewSize)

Set this Overlap sensor Overlap bounds.

Definition at line 122 of file OverlapSensor.cpp.

123{
124 Parameters.Size = NewSize;
125
126 if (BoundsComponent)
127 {
128 FVector Size = FVector(Parameters.Size.X, Parameters.Size.Y , Parameters.Size.Z);
129 BoundsComponent->SetRelativeScale3D(Size);
130 }
131
132 FString ActorID = IActorInformation::Execute_GetActorID(this);
133
134 FString Msg = FString::Printf(TEXT("OverlapSensor with ID: %s changed overlap bounds to: %s"), *ActorID, *NewSize.ToString());
136}
static void Log(const FString &Message, bool LogToTextFile=true, bool LogToROS=true)

References BoundsComponent, SimulatorLog::Log(), Parameters, and FOverlapSensorParameters::Size.

Referenced by APIDDrone::ChangeDroneParameters(), UROSCommands::HandleChangeOverlapSensorBounds(), Init(), and AVehicle::SetVehicleParameters().

◆ SetOverlapRelativePosition()

void AOverlapSensor::SetOverlapRelativePosition ( const FVector &  Vector)

Set this Overlap sensor relative position to parent.

Definition at line 148 of file OverlapSensor.cpp.

149{
151
152 if (BoundsComponent)
153 {
154 BoundsComponent->SetRelativeLocation(Parameters.RelativePosition);
155 }
156
157 FString Msg = FString::Printf(TEXT("OverlapSensor.cpp: Changed overlap relative position to: %s"), *Vector.ToString());
159}

References BoundsComponent, SimulatorLog::Log(), Parameters, and FOverlapSensorParameters::RelativePosition.

Referenced by UROSCommands::HandleChangeOverlapSensorPosition().

◆ SetOverlapResponseToAllChannels()

void AOverlapSensor::SetOverlapResponseToAllChannels ( const ECollisionResponse  Response)

Set this sensor overlap response.

Parameters
ResponseThe desired collision response. ECR_Overlap: Allows all overlaps to be recognized. ECR_Ignore: Allows only Walker overlaps to be recognized. Other than ECR_Overlap or ECR_Ignore is ignored.

Definition at line 161 of file OverlapSensor.cpp.

162{
163 if (Response != ECollisionResponse::ECR_Overlap && Response != ECollisionResponse::ECR_Ignore)
164 {
165 // If Response is neither ECR_Overlap nor ECR_Ignore, return
166 return;
167 }
168
169 if (BoundsComponent)
170 {
171 BoundsComponent->SetCollisionResponseToAllChannels(Response);
172 }
173}

References BoundsComponent.

◆ SetVisualizeOverlapArea()

void AOverlapSensor::SetVisualizeOverlapArea ( bool  Visualize)

Set this Overlap sensor bounds visulization on or off.

Definition at line 138 of file OverlapSensor.cpp.

139{
140 IsVisible = Visualize;
141
142 if (BoundsComponent)
143 {
144 BoundsComponent->SetVisibility(IsVisible);
145 }
146}

References BoundsComponent, and IsVisible.

Referenced by APIDDrone::ChangeDroneParameters(), UROSCommands::HandleVisualizeOverlapSensorsBounds(), AVehicle::SetVehicleParameters(), and AVehicle::SetVisualizeVehicleOverlapArea().

◆ TryGetID()

FString AOverlapSensor::TryGetID ( AActor *  Actor)
private

Definition at line 343 of file OverlapSensor.cpp.

344{
345 FString ID;
346
347 if (Actor && Actor->GetClass()->ImplementsInterface(UActorInformation::StaticClass()))
348 {
349 if (Actor->Implements<UActorInformation>())
350 {
351 ID = IActorInformation::Execute_GetActorID(Actor);
352 }
353 }
354
355 return ID;
356}

Referenced by BuildAndSendMessage().

Member Data Documentation

◆ BoundsComponent

UBoundsVisualizerComponent* AOverlapSensor::BoundsComponent = nullptr
protected

◆ IsVisible

bool AOverlapSensor::IsVisible = false
private

Definition at line 125 of file OverlapSensor.h.

Referenced by SetVisualizeOverlapArea().

◆ Parameters

FOverlapSensorParameters AOverlapSensor::Parameters
private

Definition at line 116 of file OverlapSensor.h.

Referenced by Init(), SetOverlapBounds(), and SetOverlapRelativePosition().

◆ ROSMessage

TSharedPtr<ROSMessages::std_msgs::String> AOverlapSensor::ROSMessage
private

Definition at line 114 of file OverlapSensor.h.

Referenced by BuildAndSendMessage(), and Init().

◆ Vehicle

AVehicle* AOverlapSensor::Vehicle = nullptr
private

◆ VehicleID

FString AOverlapSensor::VehicleID
private

Definition at line 123 of file OverlapSensor.h.

Referenced by Init().

◆ VehicleName

FString AOverlapSensor::VehicleName
private

Definition at line 121 of file OverlapSensor.h.

Referenced by Init().


The documentation for this class was generated from the following files: