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 |
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 |
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 |
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 | |
virtual void | BeginPlay () override |
virtual void | EndPlay (const EEndPlayReason::Type EndPlayReason) override |
Protected Member Functions inherited from ASensor | |
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) |
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 (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) |
Private Attributes | |
UNiagaraComponent * | NiagaraComponent = nullptr |
FLidarParameters | LidarParameters |
FLidarParameters | TempLidarParameters |
FWeatherParameters | CurrentWeatherParameters |
UWorld * | World = nullptr |
TMap< FName, FColor > | SemanticColors |
TSharedPtr< ROSMessages::sensor_msgs::PointCloud2 > | PointCloudMessage |
std::vector< std::vector< FPointData > > | PreProcessedHitImpactPoints |
std::vector< std::vector< FPointData > > | Points |
std::vector< FPointData > | PointsFlattened |
std::vector< float > | LaserAngles |
std::random_device | RandomDevice |
std::mt19937 | Generator |
bool | NeedToSavePointCloudWithoutNoise = false |
bool | LidarParametersChanged = false |
bool | SendDataEveryFrame = false |
bool | ClearContainers = true |
const FName | TerrainTag = "Terrain" |
float | CurrentHorizontalAngle = 0.0f |
float | SensorHzFrequency = 0.1f |
float | SensorHzTimer = 0.0f |
float | SnowHeightOffset = 0.0f |
int32 | LidarSaves = 0 |
uint32 | CachedNoneColor |
uint32 | CachedSnowflakeColor |
Friends | |
class | ALidarManager |
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) |
Protected Attributes inherited from ASensor | |
UTopic * | ROSTopic = nullptr |
bool | SendDataToROS = true |
ULogFile * | LogFile = nullptr |
FString | FileSavePath |
UROSIntegrationGameInstance * | ROSInstance = nullptr |
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" |
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 386 of file Lidar.cpp.
References FLidarParameters::DistanceNoiseStdDev, Generator, and LidarParameters.
Referenced by AddProcessingToHitResult().
|
private |
Definition at line 395 of file Lidar.cpp.
References Generator, FLidarParameters::LateralNoiseStdDev, and LidarParameters.
Referenced by AddProcessingToHitResult().
|
private |
Definition at line 368 of file Lidar.cpp.
References AddDistanceNoise(), AddLateralNoise(), AddSnowTerrainAdjustment(), FLidarParameters::DistanceNoiseStdDev, FLidarParameters::LateralNoiseStdDev, and LidarParameters.
Referenced by SimulateRaycastLidar().
|
private |
Definition at line 417 of file Lidar.cpp.
References SnowHeightOffset, and TerrainTag.
Referenced by AddProcessingToHitResult().
|
overrideprotectedvirtual |
Reimplemented from ASensor.
Definition at line 52 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, SetParticleLifeTime(), and World.
|
private |
Checks can sensor send data in this tick
Definition at line 518 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 540 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 |
Reimplemented from ASensor.
Definition at line 112 of file Lidar.cpp.
References UAgrarsenseStatics::GetLidarManager(), UAgrarsenseStatics::GetWeatherActor(), LaserAngles, NiagaraComponent, OnWeatherChanged(), AWeather::OnWeatherChanged, PointCloudMessage, Points, PointsFlattened, PreProcessedHitImpactPoints, ALidarManager::RemoveRaycastLidar(), SetNiagaraRendering(), and World.
|
inline |
Get current Lidar parameters
Definition at line 82 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 556 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 37 of file Lidar.cpp.
References ChangeParameters(), ASensor::CreateDataSavePath(), 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 640 of file Lidar.cpp.
References FLidarParameters::Channels, ClearContainers, LidarParameters, Points, PointsFlattened, FLidarParameters::PointsPerSecond, PreProcessedHitImpactPoints, FLidarParameters::SavePointcloudWithoutNoiseModel, SendDataEveryFrame, and VisualizeLidarParticles().
Referenced by SimulateRaycastLidar().
|
private |
Definition at line 703 of file Lidar.cpp.
References ASensor::FileSavePath, LidarParameters, LidarSaves, NeedToSavePointCloudWithoutNoise, PointsFlattened, PreProcessedHitImpactPoints, FLidarParameters::SaveDataToDisk, and UPointcloudUtilities::SaveVectorArrayAsPlyAsync().
Referenced by SendData().
|
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 486 of file Lidar.cpp.
References CanSendData(), LidarParameters, Points, PointsFlattened, SaveDataToDisk(), FLidarParameters::SaveDataToDisk, ASensor::SendDataToROS, and SendDataToTopic().
Referenced by SimulateRaycastLidar().
|
private |
Definition at line 681 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 580 of file Lidar.cpp.
References LidarNoiseModel::CheckSnowflakeHit(), CurrentWeatherParameters, GetSemanticData(), NeedToSavePointCloudWithoutNoise, PreProcessedHitImpactPoints, World, 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 429 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 271 of file Lidar.h.
Referenced by BeginPlay(), and GetSemanticData().
|
private |
Definition at line 273 of file Lidar.h.
Referenced by BeginPlay(), and GetSemanticData().
|
private |
Definition at line 259 of file Lidar.h.
Referenced by CanSendData(), ResetRecordedHits(), and SimulateRaycastLidar().
|
private |
Definition at line 263 of file Lidar.h.
Referenced by SimulateRaycastLidar().
|
private |
Definition at line 236 of file Lidar.h.
Referenced by BeginPlay(), OnWeatherChanged(), ShootLaser(), and SimulateRaycastLidar().
|
private |
Definition at line 254 of file Lidar.h.
Referenced by AddDistanceNoise(), AddLateralNoise(), and Init().
|
private |
Definition at line 251 of file Lidar.h.
Referenced by ChangeParameters(), EndPlay(), and SimulateRaycastLidar().
|
private |
Definition at line 232 of file Lidar.h.
Referenced by AddDistanceNoise(), AddLateralNoise(), AddProcessingToHitResult(), ChangeLidarParameters(), ChangeParameters(), Init(), ResetRecordedHits(), SaveDataToDisk(), SendData(), SimulateRaycastLidar(), and VisualizeLidarParticles().
|
private |
Definition at line 257 of file Lidar.h.
Referenced by ChangeLidarParameters(), and SimulateRaycastLidar().
|
private |
Definition at line 269 of file Lidar.h.
Referenced by SaveDataToDisk().
|
private |
Definition at line 256 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 126 of file Lidar.h.
Referenced by BeginPlay(), EndPlay(), SetNiagaraRendering(), SetParticleLifeTime(), UpdateLidarParticles(), and VisualizeLidarParticles().
|
private |
Definition at line 244 of file Lidar.h.
Referenced by EndPlay(), Init(), and SendDataToTopic().
|
private |
Definition at line 248 of file Lidar.h.
Referenced by ChangeParameters(), EndPlay(), ResetRecordedHits(), SendData(), and SimulateRaycastLidar().
|
private |
Definition at line 249 of file Lidar.h.
Referenced by EndPlay(), ResetRecordedHits(), SaveDataToDisk(), SendData(), and SimulateRaycastLidar().
|
private |
Definition at line 246 of file Lidar.h.
Referenced by ChangeParameters(), EndPlay(), ResetRecordedHits(), SaveDataToDisk(), and ShootLaser().
|
private |
|
private |
Definition at line 242 of file Lidar.h.
Referenced by BeginPlay(), and GetSemanticData().
|
private |
Definition at line 258 of file Lidar.h.
Referenced by CanSendData(), ChangeParameters(), and ResetRecordedHits().
|
private |
Definition at line 264 of file Lidar.h.
Referenced by CanSendData(), and ChangeParameters().
|
private |
Definition at line 265 of file Lidar.h.
Referenced by CanSendData().
|
private |
Definition at line 267 of file Lidar.h.
Referenced by AddSnowTerrainAdjustment(), and OnWeatherChanged().
|
private |
Definition at line 234 of file Lidar.h.
Referenced by ChangeLidarParameters(), and SimulateRaycastLidar().
|
private |
Definition at line 261 of file Lidar.h.
Referenced by AddSnowTerrainAdjustment().
|
private |
Definition at line 239 of file Lidar.h.
Referenced by BeginPlay(), EndPlay(), and ShootLaser().