Agrarsense
|
#include <Sensor.h>
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 |
ASensorModel * | GetSensorModel () 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 |
ULogFile * | LogFile = 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< ASensorModel > | SensorModel |
FString | SensorIdentifier |
FString | SensorName |
bool | SimulateThisSensor = true |
bool | ROSConnected = false |
Static Private Attributes | |
static TArray< TWeakObjectPtr< UPrimitiveComponent > > | ComponentsToHide |
ASensor::ASensor | ( | const FObjectInitializer & | ObjectInitializer | ) |
Definition at line 22 of file Sensor.cpp.
|
overrideprotectedvirtual |
Reimplemented in ACamera, ACollisionSensor, ALidar, AOverlapSensor, ARadar, and ATransformSensor.
Definition at line 27 of file Sensor.cpp.
References USensorManager::AddSensor(), GetActorInformation_Implementation(), UAgrarsenseStatics::GetROSGameInstance(), UAgrarsenseStatics::GetROSHandle(), SimulatorLog::Log(), UROSHandler::OnROSStateChanged, ROSBridgeStateChanged(), ROSConnected, and ROSInstance.
|
inline |
Checks whether this sensor can be simulated.
Definition at line 161 of file Sensor.h.
Referenced by ADVSCamera::ChangeDVSCameraParameters(), ALidar::ChangeLidarParameters(), ARadar::ChangeRadarParameters(), ACollisionSensor::OnCollisionEvent(), ACamera::ShouldSimulate(), ALidar::SimulateRaycastLidar(), ARadar::Tick(), and ATransformSensor::TickParallel().
|
protectedvirtual |
Creates data save path for this sensor. Can be overriden if needed.
Definition at line 202 of file Sensor.cpp.
References FileSavePath, UAgrarsensePaths::GetDataFolder(), and GetSensorIdentifier().
Referenced by ACamera::Init(), and ALidar::Init().
|
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.
References ULogFile::Create(), FLogFileSettings::FileCreationOptions, FLogFileSettings::FileWriteOptions, GetActorID_Implementation(), GetSensorName(), FLogFileSettings::KeepFileOpen, LogFile, Overwrite, Queue, and FLogFileSettings::QueueLength.
Referenced by WriteToLogFile().
|
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.
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().
|
protectedvirtual |
Destroy created ROS Topic. Can be overriden by individual sensor if needed.
Reimplemented in ATransformSensor.
Definition at line 134 of file Sensor.cpp.
References ROSTopic.
Referenced by EndPlay(), and ROSBridgeStateChanged().
|
overrideprotectedvirtual |
Reimplemented in ACamera, ADepthCamera, ADVSCamera, AThermalCamera, ACollisionSensor, ALidar, AOverlapSensor, ARadar, and ATransformSensor.
Definition at line 61 of file Sensor.cpp.
References ComponentsToHide, ULogFile::Destroy(), DestroyROSTopic(), UAgrarsenseStatics::GetROSHandle(), GetSensorIdentifier(), GetSensorType(), SimulatorLog::Log(), LogFile, UROSHandler::OnROSStateChanged, OnSensorDestroy, USensorManager::RemoveSensor(), ROSBridgeStateChanged(), and ROSInstance.
FString ASensor::ExportToJsonFile | ( | const FString & | FileName | ) |
Export this Sensor and parameters to a JSON file.
FileName | The name of the file without extension. |
Definition at line 113 of file Sensor.cpp.
References USimulatorJsonExporter::ExportSensorToJSON().
Referenced by UROSCommands::HandleExportSensors().
|
inlineoverridevirtual |
Definition at line 207 of file Sensor.h.
Referenced by CreateLogFile(), USimulatorJsonExporter::CreateSensorJSONObject(), USimulatorJsonExporter::ExportSensorToJSON(), AVehicle::GetActorInformation_Implementation(), and AOverlapSensor::SetOverlapBounds().
|
inlineoverridevirtual |
Definition at line 217 of file Sensor.h.
References UEnumUtilities::ConvertSensorTypeToString().
Referenced by BeginPlay().
|
inlineoverridevirtual |
Definition at line 212 of file Sensor.h.
Referenced by AVehicle::GetActorInformation_Implementation().
|
inlinestatic |
Static method to retrieve an array of weak pointers to UPrimitiveComponents that are ready to be hidden.
Definition at line 256 of file Sensor.h.
Referenced by ACamera::BeginPlay().
|
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.
|
inline |
Retrieves the instance of the ROSIntegrationGameInstance set in ASensor::BeginPlay.
|
inline |
Retrieves the ROS topic associated with this sensor.
Definition at line 141 of file Sensor.h.
Referenced by AOverlapSensor::BuildAndSendMessage(), ACollisionSensor::SendCollisionData(), ALidar::SendDataToTopic(), ACamera::SendImageDataToROS(), ARadar::SendRadarData(), and ATransformSensor::SendTransformDataToROS().
|
static |
Definition at line 265 of file Sensor.cpp.
References USemanticColors::GetSemanticColors().
Referenced by ALidar::BeginPlay().
|
inline |
Get sensor's identifier
Definition at line 74 of file Sensor.h.
Referenced by CreateDataSavePath(), CreateROSTopic(), ADVSCamera::CreateROSTopic(), ATransformSensor::CreateROSTopic(), EndPlay(), ADVSCamera::Init(), USensorFactory::SetSensorIdentifierAndNameWithFallbacks(), and ACamera::SetupCamera().
|
inline |
Retrieves the sensor model associated with this sensor.
Definition at line 172 of file Sensor.h.
Referenced by USimulatorJsonParser::AttachActorToSpectatorCamera().
|
inline |
Get sensor's name
Definition at line 95 of file Sensor.h.
Referenced by ACamera::AddPostProcessingMaterial(), CreateLogFile(), CreateROSTopic(), and USimulatorJsonExporter::CreateSensorJSONObject().
|
inlinevirtual |
Get type of the sensor
Reimplemented in ACamera, ADepthCamera, ADVSCamera, ASemanticSegmentationCamera, AThermalCamera, ACollisionSensor, ALidar, AOverlapSensor, ARadar, and ATransformSensor.
Definition at line 64 of file Sensor.h.
References NONE.
Referenced by CreateROSTopic(), USensorUtilities::DestroyAllSensors(), EndPlay(), USimulatorJsonExporter::ExportSensorToJSON(), UAgrarsenseSettings::OnSensorDestroyed(), UAgrarsenseSettings::OnSensorSpawned(), USensorFactory::SetSensorIdentifierAndNameWithFallbacks(), and USensorFactory::SpawnModelClassForSensor().
|
inlinevirtual |
|
static |
Static method to hide a specified primitive component for all cameras in the World.
PrimitiveComponent | The UPrimitiveComponent to be hidden for all cameras. |
Definition at line 255 of file Sensor.cpp.
References ComponentsToHide, and OnPrimitiveAdded.
Referenced by ALidar::BeginPlay(), ASpectator::BeginPlay(), USensorUtilities::HideComponentForAllCameraSensors(), and ARadar::Init().
|
inlineprotected |
|
inline |
Check if ROS is connected.
Definition at line 192 of file Sensor.h.
Referenced by AOverlapSensor::BuildAndSendMessage(), CreateROSTopic(), ADVSCamera::CreateROSTopic(), ACollisionSensor::SendCollisionData(), ALidar::SendDataToTopic(), ACamera::SendImageDataToROS(), ADVSCamera::SendRawDVSImageDataToROS(), and ATransformSensor::TickParallel().
|
private |
Callback when ROS Bridge state changed. Must be marked as UFUNCTION.
Definition at line 118 of file Sensor.cpp.
References Connected, CreateROSTopic(), DestroyROSTopic(), Disconnected, and ROSConnected.
Referenced by BeginPlay(), and EndPlay().
|
inlineoverridevirtual |
Definition at line 237 of file Sensor.h.
|
inlineoverridevirtual |
|
inline |
Set sensor's identifier
newIdentifier | New identifier |
Definition at line 84 of file Sensor.h.
Referenced by USensorFactory::SetSensorIdentifierAndNameWithFallbacks().
|
inline |
Sets the sensor model for sensor.
NewSensorModel | The new sensor model to set. |
Definition at line 182 of file Sensor.h.
Referenced by USensorFactory::SpawnModelClass().
|
inline |
Set sensor's name
newIdentifier | New name |
Definition at line 114 of file Sensor.h.
Referenced by USensorFactory::SetSensorIdentifierAndNameWithFallbacks().
|
inline |
Set simulate this sensor
bSimulateSensor | bool |
Definition at line 151 of file Sensor.h.
Referenced by UROSCommands::HandleSetSensorEnabled(), ACollisionSensor::Init(), ATransformSensor::Init(), ACamera::Init(), ALidar::Init(), AOverlapSensor::Init(), ARadar::Init(), USensorUtilities::SetSimulateAllSensors(), and USensorUtilities::SetSimulateSensorsAttachedToVehicle().
|
inlinestaticprotected |
Templated function to convert any struct to JSON string representation for logging and debugging purposes.
InStructType | The type of the structure to be converted to a JSON string. |
InStruct | The structure instance to be converted. |
FString
containing the JSON string representation of the input structure. Definition at line 305 of file Sensor.h.
|
protected |
Write to text file. If the text file doesn't exits, it will be created.
Definition at line 242 of file Sensor.cpp.
References CreateLogFile(), LogFile, and ULogFile::Write().
Referenced by AOverlapSensor::BuildAndSendMessage(), ACamera::CreateLogFile(), ACollisionSensor::OnCollisionEvent(), and ACamera::SaveCameraMetaDataToDisk().
FName ASensor::AttachedToBone |
Definition at line 275 of file Sensor.h.
Referenced by USimulatorJsonExporter::CreateSensorJSONObject().
FString ASensor::AttachedToComponent |
Definition at line 272 of file Sensor.h.
Referenced by USimulatorJsonExporter::CreateSensorJSONObject().
|
staticprivate |
Definition at line 386 of file Sensor.h.
Referenced by EndPlay(), and HideComponentForAllCameras().
|
protected |
Definition at line 349 of file Sensor.h.
Referenced by CreateDataSavePath(), ACamera::CreateLogFile(), ALidar::SaveDataToDisk(), and ACamera::SaveImageToDisk().
|
protected |
Definition at line 347 of file Sensor.h.
Referenced by CreateLogFile(), ACamera::CreateLogFile(), EndPlay(), ACamera::SaveCameraMetaDataToDisk(), and WriteToLogFile().
|
inlinestaticprotected |
Definition at line 359 of file Sensor.h.
Referenced by ALidar::UpdateLidarParticles().
|
inlinestaticprotected |
Definition at line 358 of file Sensor.h.
Referenced by ARadar::SimulateRadar(), and ALidar::UpdateLidarParticles().
|
inlinestaticprotected |
Definition at line 360 of file Sensor.h.
Referenced by ARadar::SimulateRadar(), and ALidar::UpdateLidarParticles().
|
inlinestaticprotected |
Definition at line 357 of file Sensor.h.
Referenced by ARadar::SimulateRadar(), and ALidar::UpdateLidarParticles().
|
staticprotected |
Definition at line 354 of file Sensor.h.
Referenced by ACamera::BeginPlay(), and HideComponentForAllCameras().
FSensorDestroy ASensor::OnSensorDestroy |
|
private |
Definition at line 384 of file Sensor.h.
Referenced by BeginPlay(), and ROSBridgeStateChanged().
|
protected |
Definition at line 352 of file Sensor.h.
Referenced by BeginPlay(), CreateROSTopic(), ADVSCamera::CreateROSTopic(), ATransformSensor::CreateROSTopic(), and EndPlay().
|
protected |
Definition at line 341 of file Sensor.h.
Referenced by CreateROSTopic(), ADVSCamera::CreateROSTopic(), and DestroyROSTopic().
|
protected |
Definition at line 344 of file Sensor.h.
Referenced by ALidar::ChangeParameters(), CreateROSTopic(), ACamera::FrameGrabberCapture(), ALidar::SendData(), ALidar::SendDataToTopic(), ACamera::SendImageDataToROS(), ARadar::SendRadarData(), ADVSCamera::SendRawDVSImageDataToROS(), ARadar::SetRadarParameters(), and ACamera::SetupCamera().
|
private |