Agrarsense
|
#include <Lidar.h>
Public Member Functions | |
ALidar (const FObjectInitializer &ObjectInitializer) | |
void | Init (FLidarParameters parameters, bool SimulateSensor=true) |
virtual ESensorTypes | GetSensorType () const override |
void | ChangeLidarParameters (FLidarParameters newLidarParameters) |
void | SetVisualizeLidarParticles (bool Visualize) |
void | SetParticleLifeTime (float ParticleLifeTime) |
FLidarParameters | GetLidarParameters () const |
UNiagaraComponent * | GetNiagaraComponent () const |
virtual FString | GetParametersAsString () const override |
void | ForceClearContainers () |
void | SaveCurrentPointCloudToDisk () |
![]() | |
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 |
AVehicle * | IsAttachedToVehicle () 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) |
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) |
![]() | |
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 | |
virtual void | BeginPlay () override |
virtual void | EndPlay (const EEndPlayReason::Type EndPlayReason) override |
void | CreateLogFile () override |
void | SaveLidarMetaDataToDisk (const FString &FileName) |
![]() | |
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) |
Private Member Functions | |
std::vector< FPointData > | SimulateRaycastLidar (const float DeltaTime) |
void | SetNiagaraRendering (bool Enabled) |
void | VisualizeLidarParticles (std::vector< FPointData > HitPoints) |
void | ChangeParameters () |
FORCEINLINE bool | ShootLaser (const UWorld *World, FHitResult &HitResult, const FVector &EndTrace, const FCollisionQueryParams &TraceParams, const FVector &LidarBodyLocation, const int32 Channel, const bool Semantic, const uint32 RGBDefault, const bool UseLidarNoiseModel) |
void | ResetRecordedHits (int32 MaxPointsPerChannel) |
FORCEINLINE uint32 | GetSemanticData (const FHitResult &HitResult) const |
void | SendData (const float DeltaTime) |
bool | CanSendData (const float DeltaTime) |
void | SendDataToTopic (const std::vector< FPointData > &points) |
void | SaveDataToDisk () |
void | AddProcessingToHitResult (FHitResult &HitResult, const FVector &LidarBodyLocation, const bool UseHorizontalNoise, const bool UseSnowTerrainAdjustment) |
void | AddDistanceNoise (FHitResult &HitResult, const FVector &LidarBodyLocation) |
void | AddLateralNoise (FHitResult &HitResult, const FVector &LidarBodyLocation, const bool UseHorizontalNoise) |
void | AddSnowTerrainAdjustment (FHitResult &HitResult, const FVector &LidarBodyLocation) |
void | UpdateLidarParticles (int32 NumberOfHits, const TArray< FVector > &HitPoints, const TArray< FLinearColor > &Colors) |
void | OnWeatherChanged (FWeatherParameters WeatherParams) |
Friends | |
class | ALidarManager |
Additional Inherited Members | |
![]() | |
static void | HideComponentForAllCameras (UPrimitiveComponent *PrimitiveComponent) |
static TMap< FString, FColor > | GetSemanticColors () |
static TArray< TWeakObjectPtr< UPrimitiveComponent > > | GetComponentsToHide () |
![]() | |
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 () |
![]() | |
FSensorDestroy | OnSensorDestroy |
FString | AttachedToComponent |
FName | AttachedToBone |
![]() | |
template<typename InStructType > | |
static FString | StructToString (const InStructType &InStruct) |
![]() | |
UTopic * | ROSTopic = nullptr |
bool | SendDataToROS = true |
ULogFile * | LogFile = nullptr |
AActor * | ParentActor = nullptr |
FString | FileSavePath |
UROSIntegrationGameInstance * | ROSInstance = nullptr |
![]() | |
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" |
Parameterized linetrace based Lidar sensor. Parameters defined in FLidarParameters struct. This Sensor Actor is ticked by LidarManager where all added Lidar sensors are ticked in parallel.
ALidar::ALidar | ( | const FObjectInitializer & | ObjectInitializer | ) |
|
private |
Definition at line 390 of file Lidar.cpp.
References FLidarParameters::DistanceNoiseStdDev, Generator, and LidarParameters.
Referenced by AddProcessingToHitResult().
|
private |
Definition at line 399 of file Lidar.cpp.
References Generator, FLidarParameters::LateralNoiseStdDev, and LidarParameters.
Referenced by AddProcessingToHitResult().
|
private |
Definition at line 372 of file Lidar.cpp.
References AddDistanceNoise(), AddLateralNoise(), AddSnowTerrainAdjustment(), FLidarParameters::DistanceNoiseStdDev, FLidarParameters::LateralNoiseStdDev, and LidarParameters.
Referenced by SimulateRaycastLidar().
|
private |
Definition at line 421 of file Lidar.cpp.
References SnowHeightOffset, and TerrainTag.
Referenced by AddProcessingToHitResult().
|
overrideprotectedvirtual |
Reimplemented from ASensor.
Definition at line 56 of file Lidar.cpp.
References ALidarManager::AddRaycastLidar(), CachedNoneColor, CachedSnowflakeColor, CurrentWeatherParameters, AWeather::GetCurrentWeather(), UAgrarsenseStatics::GetLidarManager(), ASensor::GetSemanticColors(), UAgrarsenseStatics::GetWeatherActor(), ASensor::HideComponentForAllCameras(), NiagaraComponent, OnWeatherChanged(), AWeather::OnWeatherChanged, SemanticColors, and SetParticleLifeTime().
|
private |
Checks can sensor send data in this tick
Definition at line 526 of file Lidar.cpp.
References ClearContainers, SendDataEveryFrame, SensorHzFrequency, and SensorHzTimer.
Referenced by SendData().
void ALidar::ChangeLidarParameters | ( | FLidarParameters | newLidarParameters | ) |
Change Lidar parameter for this sensor.
newLidarParameters | FLidarParameters struct |
Definition at line 548 of file Lidar.cpp.
References ASensor::CanSimulateSensor(), ChangeParameters(), LidarParameters, LidarParametersChanged, and TempLidarParameters.
|
private |
Change this Lidar sensor parameters
Definition at line 165 of file Lidar.cpp.
References FLidarParameters::Channels, ASensor::CreateROSTopic(), FLidarParameters::DistanceNoiseStdDev, FLidarParameters::HorizontalFov, LaserAngles, FLidarParameters::LateralNoiseStdDev, LidarParameters, SimulatorLog::Log(), FLidarParameters::LowerFovLimit, Points, FLidarParameters::PointsPerSecond, PreProcessedHitImpactPoints, FLidarParameters::RotationFrequency, FLidarParameters::SendDataAtRotationFrequency, SendDataEveryFrame, FLidarParameters::SendDataToROS, ASensor::SendDataToROS, SensorHzFrequency, SetVisualizeLidarParticles(), FLidarParameters::UpperFovLimit, and FLidarParameters::VisualizePointcloud.
Referenced by ChangeLidarParameters(), Init(), and SimulateRaycastLidar().
|
overrideprotectedvirtual |
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 751 of file Lidar.cpp.
References ULogFile::Create(), FLogFileSettings::FileCreationOptions, FLogFileSettings::FilePath, ASensor::FileSavePath, FLogFileSettings::FileWriteOptions, GeoReferencingSystem, FLogFileSettings::KeepFileOpen, ASensor::LogFile, FLogFileSettings::OverrideFilePath, Overwrite, Queue, FLogFileSettings::QueueLength, FLogFileSettings::Timestamp, and ASensor::WriteToLogFile().
Referenced by Init().
|
overrideprotectedvirtual |
Reimplemented from ASensor.
Definition at line 116 of file Lidar.cpp.
References UAgrarsenseStatics::GetLidarManager(), UAgrarsenseStatics::GetWeatherActor(), LaserAngles, NiagaraComponent, OnWeatherChanged(), AWeather::OnWeatherChanged, PointCloudMessage, Points, PointsFlattened, PreProcessedHitImpactPoints, ALidarManager::RemoveRaycastLidar(), and SetNiagaraRendering().
|
inline |
Definition at line 110 of file Lidar.h.
Referenced by ADataCapture::UpdatePositions().
|
inline |
Get current Lidar parameters
Definition at line 83 of file Lidar.h.
Referenced by USimulatorJsonExporter::ExportSensorToJSON().
|
inline |
Retrieves the Niagara component associated with this sensor.
|
inlineoverridevirtual |
Get current LidarParameters struct fields as one string.
Reimplemented from ASensor.
|
private |
Retrieve semantic data based on the object hit by the line trace.
HitResult | The result of the line trace indicating the object hit. |
Definition at line 564 of file Lidar.cpp.
References CachedNoneColor, CachedSnowflakeColor, and SemanticColors.
Referenced by ShootLaser(), and SimulateRaycastLidar().
|
inlineoverridevirtual |
void ALidar::Init | ( | FLidarParameters | parameters, |
bool | SimulateSensor = true |
||
) |
Initialize new Lidar sensor
parameters | FLidarParameters struct |
Definition at line 40 of file Lidar.cpp.
References ChangeParameters(), ASensor::CreateDataSavePath(), CreateLogFile(), Generator, LidarParameters, PointCloudMessage, RandomDevice, and ASensor::SetSimulateSensor().
Referenced by USensorFactory::SpawnLidarSensor().
|
private |
Definition at line 153 of file Lidar.cpp.
References CurrentWeatherParameters, FWeatherParameters::SnowAmount, and SnowHeightOffset.
Referenced by BeginPlay(), and EndPlay().
|
private |
Reset and possibly re-allocate needed arrays.
Definition at line 649 of file Lidar.cpp.
References FLidarParameters::Channels, ClearContainers, LidarParameters, Points, PointsFlattened, FLidarParameters::PointsPerSecond, PreProcessedHitImpactPoints, FLidarParameters::SavePointcloudWithoutNoiseModel, SendDataEveryFrame, and VisualizeLidarParticles().
Referenced by SimulateRaycastLidar().
|
inline |
Definition at line 118 of file Lidar.h.
Referenced by ADataCapture::CaptureDataNow().
|
private |
Definition at line 713 of file Lidar.cpp.
References ASensor::FileSavePath, LidarSaves, NeedToSavePointCloudWithoutNoise, PointsFlattened, PreProcessedHitImpactPoints, SaveLidarMetaDataToDisk(), and UPointcloudUtilities::SaveVectorArrayAsPlyAsync().
Referenced by SendData().
|
protected |
Definition at line 787 of file Lidar.cpp.
References ASensor::CreateTimeStampString(), GeoReferencingSystem, ASensor::LogFile, UCoordinateConversionUtilities::UnrealToGeographicCoordinates(), and ASensor::WriteToLogFile().
Referenced by SaveDataToDisk().
|
private |
Send data to topics and save point cloud to disk if that's enabled. Before sending and saving, CanSendData is checked.
Definition at line 490 of file Lidar.cpp.
References CanSendData(), LidarParameters, Points, PointsFlattened, SaveCurrentPointCloudToDiskRequested, SaveDataToDisk(), FLidarParameters::SaveDataToDisk, ASensor::SendDataToROS, and SendDataToTopic().
Referenced by SimulateRaycastLidar().
|
private |
Definition at line 690 of file Lidar.cpp.
References ASensor::GetROSTopic(), ASensor::IsROSConnected(), PointCloudMessage, and ASensor::SendDataToROS.
Referenced by SendData().
|
private |
Set Niagara component rendering on/off
bEnabled | boolean to set Niagara rendering on/off |
Definition at line 213 of file Lidar.cpp.
References NiagaraComponent, and UpdateLidarParticles().
Referenced by EndPlay(), and SetVisualizeLidarParticles().
void ALidar::SetParticleLifeTime | ( | float | ParticleLifeTime | ) |
Set Niagara particle lifetime (default 2 seconds)
particleLifeTime | new lifetime as float |
Definition at line 239 of file Lidar.cpp.
References NiagaraComponent.
Referenced by BeginPlay().
void ALidar::SetVisualizeLidarParticles | ( | bool | Visualize | ) |
Set boolean whether Lidar sensors be visualized
bVisualize | boolean to set visualization on/off |
Definition at line 208 of file Lidar.cpp.
References SetNiagaraRendering().
Referenced by ChangeParameters().
|
private |
This function calculates the impact point of the laser shot based on provided parameters, considering the specified vertical and horizontal angles, collision parameters, Lidar body location, Lidar body rotation, and the specified range.
Definition at line 588 of file Lidar.cpp.
References LidarNoiseModel::CheckSnowflakeHit(), CurrentWeatherParameters, GetSemanticData(), NeedToSavePointCloudWithoutNoise, PreProcessedHitImpactPoints, and FPointData::X.
Referenced by SimulateRaycastLidar().
|
private |
Simulate this Lidar sensor. Should only be called by LidarManager.
DeltaTime | current DeltaTime |
Definition at line 247 of file Lidar.cpp.
References AddProcessingToHitResult(), ASensor::CanSimulateSensor(), ChangeParameters(), FLidarParameters::Channels, ClearContainers, CurrentHorizontalAngle, CurrentWeatherParameters, FLidarParameters::DistanceNoiseStdDev, GetSemanticData(), FLidarParameters::HorizontalFov, FWeatherParameters::IsLidarNoiseModelCondition(), FWeatherParameters::IsWinterSnowCondition(), LaserAngles, FLidarParameters::LateralNoiseStdDev, LidarParameters, LidarParametersChanged, NeedToSavePointCloudWithoutNoise, Points, PointsFlattened, FLidarParameters::PointsPerSecond, FLidarParameters::Range, ResetRecordedHits(), FLidarParameters::RotationFrequency, FLidarParameters::SaveDataToDisk, FLidarParameters::SavePointcloudWithoutNoiseModel, FLidarParameters::Semantic, SendData(), FLidarParameters::SendDataToCombinedROSTopic, ShootLaser(), SimulateRaycastLidar(), TempLidarParameters, FLidarParameters::UseComplexCollisionTrace, FLidarParameters::UseLidarNoiseModel, and FLidarParameters::UseTerrainSnowHitAdjustment.
Referenced by ALidarManager::SimulateLidars(), and SimulateRaycastLidar().
|
private |
Definition at line 228 of file Lidar.cpp.
References NiagaraComponent, ASensor::NiagaraHitColors, ASensor::NiagaraHitPoints, ASensor::NiagaraPointsFloat, and ASensor::NiagaraPointsInt.
Referenced by SetNiagaraRendering(), and VisualizeLidarParticles().
|
private |
Visualize Lidar particles with Niagara particle system
Definition at line 433 of file Lidar.cpp.
References LidarParameters, NiagaraComponent, FPointData::RGB, FLidarParameters::Semantic, UpdateLidarParticles(), VisualizeLidarParticles(), FLidarParameters::VisualizePointcloud, FPointData::X, FPointData::Y, and FPointData::Z.
Referenced by ResetRecordedHits(), and VisualizeLidarParticles().
|
friend |
|
private |
Definition at line 292 of file Lidar.h.
Referenced by BeginPlay(), and GetSemanticData().
|
private |
Definition at line 294 of file Lidar.h.
Referenced by BeginPlay(), and GetSemanticData().
|
private |
Definition at line 298 of file Lidar.h.
Referenced by CanSendData(), ResetRecordedHits(), and SimulateRaycastLidar().
|
private |
Definition at line 284 of file Lidar.h.
Referenced by SimulateRaycastLidar().
|
private |
Definition at line 261 of file Lidar.h.
Referenced by BeginPlay(), OnWeatherChanged(), ShootLaser(), and SimulateRaycastLidar().
|
private |
Definition at line 276 of file Lidar.h.
Referenced by AddDistanceNoise(), AddLateralNoise(), and Init().
|
private |
Definition at line 254 of file Lidar.h.
Referenced by CreateLogFile(), and SaveLidarMetaDataToDisk().
|
private |
Definition at line 273 of file Lidar.h.
Referenced by ChangeParameters(), EndPlay(), and SimulateRaycastLidar().
|
private |
Definition at line 257 of file Lidar.h.
Referenced by AddDistanceNoise(), AddLateralNoise(), AddProcessingToHitResult(), ChangeLidarParameters(), ChangeParameters(), Init(), ResetRecordedHits(), SendData(), SimulateRaycastLidar(), and VisualizeLidarParticles().
|
private |
Definition at line 279 of file Lidar.h.
Referenced by ChangeLidarParameters(), and SimulateRaycastLidar().
|
private |
Definition at line 290 of file Lidar.h.
Referenced by SaveDataToDisk().
|
private |
Definition at line 278 of file Lidar.h.
Referenced by SaveDataToDisk(), ShootLaser(), and SimulateRaycastLidar().
|
private |
NiagaraComponent for visualizing Lidar particles. Particles are only visible on Spectator camera.
Definition at line 148 of file Lidar.h.
Referenced by BeginPlay(), EndPlay(), SetNiagaraRendering(), SetParticleLifeTime(), UpdateLidarParticles(), and VisualizeLidarParticles().
|
private |
Definition at line 266 of file Lidar.h.
Referenced by EndPlay(), Init(), and SendDataToTopic().
|
private |
Definition at line 270 of file Lidar.h.
Referenced by ChangeParameters(), EndPlay(), ResetRecordedHits(), SendData(), and SimulateRaycastLidar().
|
private |
Definition at line 271 of file Lidar.h.
Referenced by EndPlay(), ResetRecordedHits(), SaveDataToDisk(), SendData(), and SimulateRaycastLidar().
|
private |
Definition at line 268 of file Lidar.h.
Referenced by ChangeParameters(), EndPlay(), ResetRecordedHits(), SaveDataToDisk(), and ShootLaser().
|
private |
|
private |
Definition at line 296 of file Lidar.h.
Referenced by SendData().
|
private |
Definition at line 264 of file Lidar.h.
Referenced by BeginPlay(), and GetSemanticData().
|
private |
Definition at line 280 of file Lidar.h.
Referenced by CanSendData(), ChangeParameters(), and ResetRecordedHits().
|
private |
Definition at line 285 of file Lidar.h.
Referenced by CanSendData(), and ChangeParameters().
|
private |
Definition at line 286 of file Lidar.h.
Referenced by CanSendData().
|
private |
Definition at line 288 of file Lidar.h.
Referenced by AddSnowTerrainAdjustment(), and OnWeatherChanged().
|
private |
Definition at line 259 of file Lidar.h.
Referenced by ChangeLidarParameters(), and SimulateRaycastLidar().
|
private |
Definition at line 282 of file Lidar.h.
Referenced by AddSnowTerrainAdjustment().