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

#include <Sensor.h>

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

Public Member Functions

 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
 
void SetSensorName (const FString newName)
 
virtual FString GetTopicName ()
 
UTopic * GetROSTopic () const
 
void SetSimulateSensor (bool SimulateSensor)
 
bool CanSimulateSensor () const
 
ASensorModelGetSensorModel () const
 
void SetSensorModel (ASensorModel *NewSensorModel)
 
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
 
- 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)
 

Static Public Member Functions

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

FSensorDestroy OnSensorDestroy
 
FString AttachedToComponent
 
FName AttachedToBone
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 
virtual void CreateROSTopic ()
 
virtual void DestroyROSTopic ()
 
virtual void CreateDataSavePath ()
 
bool IsLogFileCreated ()
 
virtual void CreateLogFile ()
 
void WriteToLogFile (const FString &Message)
 

Static Protected Member Functions

template<typename InStructType >
static FString StructToString (const InStructType &InStruct)
 

Protected Attributes

UTopic * ROSTopic = nullptr
 
bool SendDataToROS = true
 
ULogFileLogFile = nullptr
 
FString FileSavePath
 
UROSIntegrationGameInstance * ROSInstance = nullptr
 

Static Protected Attributes

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"
 

Private Member Functions

void ROSBridgeStateChanged (EROSState ROSState)
 

Private Attributes

TObjectPtr< ASensorModelSensorModel
 
FString SensorIdentifier
 
FString SensorName
 
bool SimulateThisSensor = true
 
bool ROSConnected = false
 

Static Private Attributes

static TArray< TWeakObjectPtr< UPrimitiveComponent > > ComponentsToHide
 

Detailed Description

Base class for all sensors.

Definition at line 43 of file Sensor.h.

Constructor & Destructor Documentation

◆ ASensor()

ASensor::ASensor ( const FObjectInitializer &  ObjectInitializer)

Definition at line 22 of file Sensor.cpp.

22 : Super(ObjectInitializer)
23{
24 RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot"));
25}

Member Function Documentation

◆ BeginPlay()

void ASensor::BeginPlay ( )
overrideprotectedvirtual

Reimplemented in ACamera, ACollisionSensor, ALidar, AOverlapSensor, ARadar, and ATransformSensor.

Definition at line 27 of file Sensor.cpp.

28{
29 Super::BeginPlay();
30
31 UWorld* World = GetWorld();
32
34 if (ROSHandler)
35 {
36 // Subscribe to ROS changed event
37 ROSHandler->OnROSStateChanged.AddUniqueDynamic(this, &ASensor::ROSBridgeStateChanged);
38 }
39
41 if (ROSInstance)
42 {
43 // Check if ROS is connected at BeginPlay
44 ROSConnected = ROSInstance->IsROSConnected();
45 }
46
47 // Delay logging sensor information message so each sensor have time setup fully.
48 FTimerHandle Handle;
49 World->GetTimerManager().SetTimer(Handle, FTimerDelegate::CreateLambda([this]
50 {
51 if (IsValid(this))
52 {
53 FString Message = FString("Spawned ") + GetActorInformation_Implementation();
54 SimulatorLog::Log(Message);
55 }
56 }), 0.150f, false);
57
59}
void ROSBridgeStateChanged(EROSState ROSState)
Definition: Sensor.cpp:118
UROSIntegrationGameInstance * ROSInstance
Definition: Sensor.h:352
bool ROSConnected
Definition: Sensor.h:384
virtual FString GetActorInformation_Implementation() const override
Definition: Sensor.h:217
static void Log(const FString &Message, bool LogToTextFile=true, bool LogToROS=true)
static UROSIntegrationGameInstance * GetROSGameInstance(const UObject *WorldContextObject)
static UROSHandler * GetROSHandle(const UObject *WorldContextObject)
FROSDelegate_ROState OnROSStateChanged
Definition: ROSHandler.h:81
static void AddSensor(ASensor *SensorPtr)

References USensorManager::AddSensor(), GetActorInformation_Implementation(), UAgrarsenseStatics::GetROSGameInstance(), UAgrarsenseStatics::GetROSHandle(), SimulatorLog::Log(), UROSHandler::OnROSStateChanged, ROSBridgeStateChanged(), ROSConnected, and ROSInstance.

◆ CanSimulateSensor()

bool ASensor::CanSimulateSensor ( ) const
inline

Checks whether this sensor can be simulated.

Returns
True if the sensor can be simulated, false otherwise.

Definition at line 161 of file Sensor.h.

162 {
163 return SimulateThisSensor;
164 }
bool SimulateThisSensor
Definition: Sensor.h:381

Referenced by ADVSCamera::ChangeDVSCameraParameters(), ALidar::ChangeLidarParameters(), ARadar::ChangeRadarParameters(), ACollisionSensor::OnCollisionEvent(), ACamera::ShouldSimulate(), ALidar::SimulateRaycastLidar(), ARadar::Tick(), and ATransformSensor::TickParallel().

◆ CreateDataSavePath()

void ASensor::CreateDataSavePath ( )
protectedvirtual

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

Definition at line 202 of file Sensor.cpp.

203{
204 if (FileSavePath.IsEmpty())
205 {
206 FString DataLocation = UAgrarsensePaths::GetDataFolder();
207 FString UnixTimeStamp = FString::FromInt(FDateTime::Now().ToUnixTimestamp());
208 FileSavePath = DataLocation + GetSensorIdentifier() + "_" + UnixTimeStamp + "/";
209 }
210}
FString GetSensorIdentifier() const
Definition: Sensor.h:74
FString FileSavePath
Definition: Sensor.h:349
static FString GetDataFolder()

References FileSavePath, UAgrarsensePaths::GetDataFolder(), and GetSensorIdentifier().

Referenced by ACamera::Init(), and ALidar::Init().

◆ CreateLogFile()

void ASensor::CreateLogFile ( )
protectedvirtual

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 in ACamera.

Definition at line 212 of file Sensor.cpp.

213{
214 if (IsValid(LogFile))
215 {
216 // File has already been created, return
217 return;
218 }
219
220 FLogFileSettings Settings;
223 Settings.QueueLength = 10;
224 Settings.KeepFileOpen = false;
225
226 LogFile = NewObject<ULogFile>(ULogFile::StaticClass());
227 if (LogFile)
228 {
229 // FileName is SensorName_ID_UnixTimeStamp.txt
230 FString UnixTimeStamp = FString::FromInt(FDateTime::Now().ToUnixTimestamp());
231
232 FString ActorID = GetActorID_Implementation();
233
234 // Temp fix, Remove all "/" from ActorID
235 ActorID.ReplaceInline(TEXT("/"), TEXT(""), ESearchCase::IgnoreCase);
236
237 FString FileName = FString::Printf(TEXT("%s_%s_%s"), *GetSensorName(), *ActorID, *UnixTimeStamp);
238 LogFile->Create(FileName, Settings);
239 }
240}
FString GetSensorName() const
Definition: Sensor.h:95
ULogFile * LogFile
Definition: Sensor.h:347
virtual FString GetActorID_Implementation() const override
Definition: Sensor.h:207
void Create(const FString &FileNameWithoutExtension, FLogFileSettings Settings)
Definition: LogFile.cpp:40
bool KeepFileOpen
Definition: LogFile.h:42
FFileWriteOptions FileWriteOptions
Definition: LogFile.h:45
int32 QueueLength
Definition: LogFile.h:48
FFileCreationOptions FileCreationOptions
Definition: LogFile.h:36

References ULogFile::Create(), FLogFileSettings::FileCreationOptions, FLogFileSettings::FileWriteOptions, GetActorID_Implementation(), GetSensorName(), FLogFileSettings::KeepFileOpen, LogFile, Overwrite, Queue, and FLogFileSettings::QueueLength.

Referenced by WriteToLogFile().

◆ CreateROSTopic()

void ASensor::CreateROSTopic ( )
protectedvirtual

Creates ROS Topic for this sensor. Can be overriden by individual sensor if needed.

Reimplemented in ADVSCamera, and ATransformSensor.

Definition at line 146 of file Sensor.cpp.

147{
148 if (!SendDataToROS
149 || ROSTopic
150 || !ROSInstance
151 || !IsROSConnected())
152 {
153 return;
154 }
155
156 FString MessageType;
157 ESensorTypes SensorType = GetSensorType();
158
159 switch (SensorType)
160 {
163 MessageType = "sensor_msgs/PointCloud2";
164 break;
165
170 case ESensorTypes::DVSCamera: // DVS Camera should override this.
171 MessageType = "sensor_msgs/Image";
172 break;
173
175 MessageType = "geometry_msgs/Transform";
176 break;
177
180 MessageType = "std_msgs/String";
181 break;
182
183 default:
184 FString SensorNameString = UEnumUtilities::ConvertSensorTypeToString(SensorType);
185 UE_LOG(LogTemp, Warning, TEXT("Unhandled ROS sensor message creation for sensor: %s"), *SensorNameString);
186 break;
187 }
188
189 FString TopicName = FString::Printf(TEXT("/agrarsense/out/sensors/%s"), *GetSensorIdentifier());
190
191 ROSTopic = NewObject<UTopic>(UTopic::StaticClass());
192 if (ROSTopic)
193 {
194 ROSTopic->Init(ROSInstance->ROSIntegrationCore, TopicName, MessageType);
195 ROSTopic->Advertise();
196 }
197
198 FString Message = FString::Printf(TEXT("%s sensor created ROS topic. Name: '%s' MessageType: '%s' "), *GetSensorName(), *TopicName, *MessageType);
199 SimulatorLog::Log(Message);
200}
ESensorTypes
Definition: SensorTypes.h:15
@ SemanticSegmentationCamera
UTopic * ROSTopic
Definition: Sensor.h:341
virtual ESensorTypes GetSensorType() const
Definition: Sensor.h:64
bool IsROSConnected() const
Definition: Sensor.h:192
bool SendDataToROS
Definition: Sensor.h:344
static FString ConvertSensorTypeToString(ESensorTypes Sensortype)

References Collision, UEnumUtilities::ConvertSensorTypeToString(), DepthCamera, DVSCamera, GetSensorIdentifier(), GetSensorName(), GetSensorType(), IsROSConnected(), Lidar, SimulatorLog::Log(), Overlap, Radar, RGBCamera, ROSInstance, ROSTopic, SemanticSegmentationCamera, SendDataToROS, ThermalCamera, and Transform.

Referenced by ALidar::ChangeParameters(), ACollisionSensor::Init(), AOverlapSensor::Init(), ARadar::Init(), ROSBridgeStateChanged(), and ACamera::SetupCamera().

◆ DestroyROSTopic()

void ASensor::DestroyROSTopic ( )
protectedvirtual

Destroy created ROS Topic. Can be overriden by individual sensor if needed.

Reimplemented in ATransformSensor.

Definition at line 134 of file Sensor.cpp.

135{
136 if (ROSTopic)
137 {
138 ROSTopic->Unadvertise();
139 ROSTopic->Unsubscribe();
140 ROSTopic->MarkAsDisconnected();
141 ROSTopic->ConditionalBeginDestroy();
142 ROSTopic = nullptr;
143 }
144}

References ROSTopic.

Referenced by EndPlay(), and ROSBridgeStateChanged().

◆ EndPlay()

void ASensor::EndPlay ( const EEndPlayReason::Type  EndPlayReason)
overrideprotectedvirtual

Reimplemented in ACamera, ADepthCamera, ADVSCamera, AThermalCamera, ACollisionSensor, ALidar, AOverlapSensor, ARadar, and ATransformSensor.

Definition at line 61 of file Sensor.cpp.

62{
63 // Broadcast that this sensor will be destroyed
64 OnSensorDestroy.Broadcast(this);
65
67
68 Super::EndPlay(EndPlayReason);
69
70 UROSHandler* ROSHandler = UAgrarsenseStatics::GetROSHandle(GetWorld());
71 if (ROSHandler)
72 {
73 ROSHandler->OnROSStateChanged.RemoveDynamic(this, &ASensor::ROSBridgeStateChanged);
74 }
75
76 FString Sensor = UEnum::GetDisplayValueAsText(GetSensorType()).ToString();
77 FString ID = GetSensorIdentifier();
78 FString Message = FString::Printf(TEXT("Destroyed %s sensor with ID: %s"), *Sensor, *ID);
79 SimulatorLog::Log(Message);
80
81 if (EndPlayReason == EEndPlayReason::EndPlayInEditor
82 || EndPlayReason == EEndPlayReason::Quit)
83 {
84 for (auto& WeakComponentPtr : ComponentsToHide)
85 {
86 WeakComponentPtr.Reset();
87 }
88 ComponentsToHide.Empty();
89 }
90
91 // Destroy all Actors that are attached to this sensor (Sensor model for example)
92 TArray<AActor*> AttachedActors;
93 GetAttachedActors(AttachedActors);
94 for (AActor* Actor : AttachedActors)
95 {
96 if (Actor)
97 {
98 Actor->Destroy();
99 }
100 }
101
102 ROSInstance = nullptr;
103
104 if (LogFile)
105 {
106 LogFile->Destroy();
107 LogFile = nullptr;
108 }
109
111}
static TArray< TWeakObjectPtr< UPrimitiveComponent > > ComponentsToHide
Definition: Sensor.h:386
virtual void DestroyROSTopic()
Definition: Sensor.cpp:134
FSensorDestroy OnSensorDestroy
Definition: Sensor.h:269
void Destroy()
Definition: LogFile.cpp:170
static void RemoveSensor(ASensor *SensorPtr)

References ComponentsToHide, ULogFile::Destroy(), DestroyROSTopic(), UAgrarsenseStatics::GetROSHandle(), GetSensorIdentifier(), GetSensorType(), SimulatorLog::Log(), LogFile, UROSHandler::OnROSStateChanged, OnSensorDestroy, USensorManager::RemoveSensor(), ROSBridgeStateChanged(), and ROSInstance.

◆ ExportToJsonFile()

FString ASensor::ExportToJsonFile ( const FString &  FileName)

Export this Sensor and parameters to a JSON file.

Parameters
FileNameThe name of the file without extension.
Returns
FString representing saved Json file path, or an empty string if the export fails.

Definition at line 113 of file Sensor.cpp.

114{
115 return USimulatorJsonExporter::ExportSensorToJSON(FileName, this);
116}
static FString ExportSensorToJSON(const FString &FileName, ASensor *Sensor)

References USimulatorJsonExporter::ExportSensorToJSON().

Referenced by UROSCommands::HandleExportSensors().

◆ GetActorID_Implementation()

virtual FString ASensor::GetActorID_Implementation ( ) const
inlineoverridevirtual

◆ GetActorInformation_Implementation()

virtual FString ASensor::GetActorInformation_Implementation ( ) const
inlineoverridevirtual

Definition at line 217 of file Sensor.h.

218 {
220 const FString ID = GetActorID_Implementation();
221 const FTransform VehicleTransform = GetActorTransform();
222 const FVector Location = VehicleTransform.GetLocation();
223 const FRotator Rotation = VehicleTransform.Rotator();
224 const FString Parameters = GetParametersAsString();
225
226 FString Information = FString::Printf(TEXT("Sensor: %s \nID: %s \nLocation: %s \nRotation: %s \nParameters: %s"),
227 *Sensor, *ID, *Location.ToString(), *Rotation.ToString(), *Parameters);
228
229 return Information;
230 }
virtual FString GetParametersAsString() const
Definition: Sensor.h:104

References UEnumUtilities::ConvertSensorTypeToString().

Referenced by BeginPlay().

◆ GetActorName_Implementation()

virtual FString ASensor::GetActorName_Implementation ( ) const
inlineoverridevirtual

Definition at line 212 of file Sensor.h.

213 {
214 return GetSensorName();
215 }

Referenced by AVehicle::GetActorInformation_Implementation().

◆ GetComponentsToHide()

static TArray< TWeakObjectPtr< UPrimitiveComponent > > ASensor::GetComponentsToHide ( )
inlinestatic

Static method to retrieve an array of weak pointers to UPrimitiveComponents that are ready to be hidden.

Returns
An array of TWeakObjectPtr<UPrimitiveComponent> containing components ready to be hidden.

Definition at line 256 of file Sensor.h.

257 {
258 // Since we don't know whether some UPrimitiveComponent has been destroyed,
259 // we need to check these are still valid.
260 ComponentsToHide.RemoveAll([](const TWeakObjectPtr<UPrimitiveComponent>& WeakComponent)
261 {
262 return !WeakComponent.IsValid();
263 });
264
265 return ComponentsToHide;
266 }

Referenced by ACamera::BeginPlay().

◆ GetParametersAsString()

virtual FString ASensor::GetParametersAsString ( ) const
inlinevirtual

Get this sensor parameters as string

Reimplemented in ACamera, ADepthCamera, ADVSCamera, AThermalCamera, ALidar, AOverlapSensor, and ARadar.

Definition at line 104 of file Sensor.h.

105 {
106 return FString();
107 }

◆ GetROSGameInstance()

UROSIntegrationGameInstance * ASensor::GetROSGameInstance ( ) const
inline

Retrieves the instance of the ROSIntegrationGameInstance set in ASensor::BeginPlay.

Returns
A pointer to the associated ROSIntegrationGameInstance.

Definition at line 202 of file Sensor.h.

203 {
204 return ROSInstance;
205 }

◆ GetROSTopic()

UTopic * ASensor::GetROSTopic ( ) const
inline

Retrieves the ROS topic associated with this sensor.

Returns
A pointer to the associated ROS topic or nullptr.

Definition at line 141 of file Sensor.h.

142 {
143 return ROSTopic;
144 }

Referenced by AOverlapSensor::BuildAndSendMessage(), ACollisionSensor::SendCollisionData(), ALidar::SendDataToTopic(), ACamera::SendImageDataToROS(), ARadar::SendRadarData(), and ATransformSensor::SendTransformDataToROS().

◆ GetSemanticColors()

TMap< FString, FColor > ASensor::GetSemanticColors ( )
static

Definition at line 265 of file Sensor.cpp.

266{
268}
static TMap< FString, FColor > GetSemanticColors()

References USemanticColors::GetSemanticColors().

Referenced by ALidar::BeginPlay().

◆ GetSensorIdentifier()

FString ASensor::GetSensorIdentifier ( ) const
inline

Get sensor's identifier

Returns
sensor identifier as FString

Definition at line 74 of file Sensor.h.

75 {
76 return SensorIdentifier;
77 }
FString SensorIdentifier
Definition: Sensor.h:375

Referenced by CreateDataSavePath(), CreateROSTopic(), ADVSCamera::CreateROSTopic(), ATransformSensor::CreateROSTopic(), EndPlay(), ADVSCamera::Init(), USensorFactory::SetSensorIdentifierAndNameWithFallbacks(), and ACamera::SetupCamera().

◆ GetSensorModel()

ASensorModel * ASensor::GetSensorModel ( ) const
inline

Retrieves the sensor model associated with this sensor.

Note
The returned pointer can be nullptr if no sensor model is set for this sensor.
Returns
A pointer to the associated sensor model or nullptr if not set.

Definition at line 172 of file Sensor.h.

173 {
174 return SensorModel.Get();
175 }
TObjectPtr< ASensorModel > SensorModel
Definition: Sensor.h:372

Referenced by USimulatorJsonParser::AttachActorToSpectatorCamera().

◆ GetSensorName()

FString ASensor::GetSensorName ( ) const
inline

Get sensor's name

Returns
Name

Definition at line 95 of file Sensor.h.

96 {
97 return SensorName;
98 }
FString SensorName
Definition: Sensor.h:378

Referenced by ACamera::AddPostProcessingMaterial(), CreateLogFile(), CreateROSTopic(), and USimulatorJsonExporter::CreateSensorJSONObject().

◆ GetSensorType()

virtual ESensorTypes ASensor::GetSensorType ( ) const
inlinevirtual

◆ GetTopicName()

virtual FString ASensor::GetTopicName ( )
inlinevirtual

Get ROS topic name for this sensor

Returns
Topic name

Definition at line 124 of file Sensor.h.

125 {
126 FString Name = "Undefined";
127
128 if (ROSTopic)
129 {
130 Name = ROSTopic->GetName();
131 }
132
133 return Name;
134 }

◆ HideComponentForAllCameras()

void ASensor::HideComponentForAllCameras ( UPrimitiveComponent *  PrimitiveComponent)
static

Static method to hide a specified primitive component for all cameras in the World.

Parameters
PrimitiveComponentThe UPrimitiveComponent to be hidden for all cameras.

Definition at line 255 of file Sensor.cpp.

256{
257 if (PrimitiveComponent)
258 {
259 TWeakObjectPtr<UPrimitiveComponent> Component(PrimitiveComponent);
260 ComponentsToHide.Add(Component);
261 OnPrimitiveAdded.Broadcast(PrimitiveComponent);
262 }
263}
static FPrimitiveAdded OnPrimitiveAdded
Definition: Sensor.h:354

References ComponentsToHide, and OnPrimitiveAdded.

Referenced by ALidar::BeginPlay(), ASpectator::BeginPlay(), USensorUtilities::HideComponentForAllCameraSensors(), and ARadar::Init().

◆ IsLogFileCreated()

bool ASensor::IsLogFileCreated ( )
inlineprotected

Does log file exists for this sensor.

Definition at line 316 of file Sensor.h.

317 {
318 if (LogFile)
319 {
320 return true;
321 }
322
323 return false;
324 }

◆ IsROSConnected()

bool ASensor::IsROSConnected ( ) const
inline

◆ ROSBridgeStateChanged()

void ASensor::ROSBridgeStateChanged ( EROSState  ROSState)
private

Callback when ROS Bridge state changed. Must be marked as UFUNCTION.

Definition at line 118 of file Sensor.cpp.

119{
120 switch (ROSState)
121 {
123 ROSConnected = true;
125 break;
126
128 ROSConnected = false;
130 break;
131 }
132}
virtual void CreateROSTopic()
Definition: Sensor.cpp:146

References Connected, CreateROSTopic(), DestroyROSTopic(), Disconnected, and ROSConnected.

Referenced by BeginPlay(), and EndPlay().

◆ SetActorIDAndName_Implementation()

virtual void ASensor::SetActorIDAndName_Implementation ( const FString &  NewActorName,
const FString &  NewID 
)
inlineoverridevirtual

Definition at line 237 of file Sensor.h.

238 {
239 SetSensorName(NewActorName);
240 SetSensorIdentifier(NewID);
241 }
void SetSensorName(const FString newName)
Definition: Sensor.h:114
void SetSensorIdentifier(const FString newIdentifier)
Definition: Sensor.h:84

◆ SetActorName_Implementation()

virtual void ASensor::SetActorName_Implementation ( const FString &  NewActorName)
inlineoverridevirtual

Definition at line 232 of file Sensor.h.

233 {
234 SetSensorName(NewActorName);
235 }

◆ SetSensorIdentifier()

void ASensor::SetSensorIdentifier ( const FString  newIdentifier)
inline

Set sensor's identifier

Parameters
newIdentifierNew identifier

Definition at line 84 of file Sensor.h.

85 {
86 SensorIdentifier = newIdentifier;
87 SetAndValidateActorIDAndName(SensorName, SensorIdentifier, TWeakObjectPtr<AActor>(this));
88 }
static void SetAndValidateActorIDAndName(FString &ActorName, FString &ActorID, TWeakObjectPtr< AActor > Actor)

Referenced by USensorFactory::SetSensorIdentifierAndNameWithFallbacks().

◆ SetSensorModel()

void ASensor::SetSensorModel ( ASensorModel NewSensorModel)
inline

Sets the sensor model for sensor.

Parameters
NewSensorModelThe new sensor model to set.

Definition at line 182 of file Sensor.h.

183 {
184 SensorModel = NewSensorModel;
185 }

Referenced by USensorFactory::SpawnModelClass().

◆ SetSensorName()

void ASensor::SetSensorName ( const FString  newName)
inline

Set sensor's name

Parameters
newIdentifierNew name

Definition at line 114 of file Sensor.h.

115 {
116 SensorName = newName;
117 }

Referenced by USensorFactory::SetSensorIdentifierAndNameWithFallbacks().

◆ SetSimulateSensor()

void ASensor::SetSimulateSensor ( bool  SimulateSensor)
inline

◆ StructToString()

template<typename InStructType >
static FString ASensor::StructToString ( const InStructType &  InStruct)
inlinestaticprotected

Templated function to convert any struct to JSON string representation for logging and debugging purposes.

Template Parameters
InStructTypeThe type of the structure to be converted to a JSON string.
Parameters
InStructThe structure instance to be converted.
Returns
A FString containing the JSON string representation of the input structure.

Definition at line 305 of file Sensor.h.

306 {
307 FString AsString;
308 FJsonObjectConverter::UStructToJsonObjectString(InStruct, AsString);
309 return AsString;
310 }

◆ WriteToLogFile()

void ASensor::WriteToLogFile ( const FString &  Message)
protected

Write to text file. If the text file doesn't exits, it will be created.

Definition at line 242 of file Sensor.cpp.

243{
244 if (!IsValid(LogFile) && IsValid(this))
245 {
247 }
248
249 if (IsValid(LogFile))
250 {
251 LogFile->Write(Message);
252 }
253}
virtual void CreateLogFile()
Definition: Sensor.cpp:212
void Write(const FString &Text)
Definition: LogFile.cpp:119

References CreateLogFile(), LogFile, and ULogFile::Write().

Referenced by AOverlapSensor::BuildAndSendMessage(), ACamera::CreateLogFile(), ACollisionSensor::OnCollisionEvent(), and ACamera::SaveCameraMetaDataToDisk().

Member Data Documentation

◆ AttachedToBone

FName ASensor::AttachedToBone

Definition at line 275 of file Sensor.h.

Referenced by USimulatorJsonExporter::CreateSensorJSONObject().

◆ AttachedToComponent

FString ASensor::AttachedToComponent

Definition at line 272 of file Sensor.h.

Referenced by USimulatorJsonExporter::CreateSensorJSONObject().

◆ ComponentsToHide

TArray< TWeakObjectPtr< UPrimitiveComponent > > ASensor::ComponentsToHide
staticprivate

Definition at line 386 of file Sensor.h.

Referenced by EndPlay(), and HideComponentForAllCameras().

◆ FileSavePath

FString ASensor::FileSavePath
protected

◆ LogFile

ULogFile* ASensor::LogFile = nullptr
protected

◆ NiagaraHitColors

const FName ASensor::NiagaraHitColors = "User.HitColors"
inlinestaticprotected

Definition at line 359 of file Sensor.h.

Referenced by ALidar::UpdateLidarParticles().

◆ NiagaraHitPoints

const FName ASensor::NiagaraHitPoints = "User.HitPoints"
inlinestaticprotected

Definition at line 358 of file Sensor.h.

Referenced by ARadar::SimulateRadar(), and ALidar::UpdateLidarParticles().

◆ NiagaraPointsFloat

const FName ASensor::NiagaraPointsFloat = "User.Test"
inlinestaticprotected

Definition at line 360 of file Sensor.h.

Referenced by ARadar::SimulateRadar(), and ALidar::UpdateLidarParticles().

◆ NiagaraPointsInt

const FName ASensor::NiagaraPointsInt = "User.PointCount"
inlinestaticprotected

Definition at line 357 of file Sensor.h.

Referenced by ARadar::SimulateRadar(), and ALidar::UpdateLidarParticles().

◆ OnPrimitiveAdded

FPrimitiveAdded ASensor::OnPrimitiveAdded
staticprotected

Definition at line 354 of file Sensor.h.

Referenced by ACamera::BeginPlay(), and HideComponentForAllCameras().

◆ OnSensorDestroy

FSensorDestroy ASensor::OnSensorDestroy

Definition at line 269 of file Sensor.h.

Referenced by EndPlay().

◆ ROSConnected

bool ASensor::ROSConnected = false
private

Definition at line 384 of file Sensor.h.

Referenced by BeginPlay(), and ROSBridgeStateChanged().

◆ ROSInstance

UROSIntegrationGameInstance* ASensor::ROSInstance = nullptr
protected

◆ ROSTopic

UTopic* ASensor::ROSTopic = nullptr
protected

Definition at line 341 of file Sensor.h.

Referenced by CreateROSTopic(), ADVSCamera::CreateROSTopic(), and DestroyROSTopic().

◆ SendDataToROS

bool ASensor::SendDataToROS = true
protected

◆ SensorIdentifier

FString ASensor::SensorIdentifier
private

Definition at line 375 of file Sensor.h.

◆ SensorModel

TObjectPtr<ASensorModel> ASensor::SensorModel
private

Definition at line 372 of file Sensor.h.

◆ SensorName

FString ASensor::SensorName
private

Definition at line 378 of file Sensor.h.

◆ SimulateThisSensor

bool ASensor::SimulateThisSensor = true
private

Definition at line 381 of file Sensor.h.


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