Added Radar default noise
This commit is contained in:
parent
ba32d5a08e
commit
2a11d4528f
|
@ -768,7 +768,13 @@ void UActorBlueprintFunctionLibrary::MakeRadarDefinition(
|
|||
Aperture.RecommendedValues = { TEXT("10") };
|
||||
Aperture.bRestrictToRecommended = false;
|
||||
|
||||
Definition.Variations.Append({FOV, Steps, Far, Aperture});
|
||||
FActorVariation PointLossPercentage;
|
||||
PointLossPercentage.Id = TEXT("point_loss_percentage");
|
||||
PointLossPercentage.Type = EActorAttributeType::Float;
|
||||
PointLossPercentage.RecommendedValues = { TEXT("0.7") };
|
||||
PointLossPercentage.bRestrictToRecommended = false;
|
||||
|
||||
Definition.Variations.Append({FOV, Steps, Far, Aperture, PointLossPercentage});
|
||||
|
||||
Success = CheckActorDefinition(Definition);
|
||||
}
|
||||
|
@ -1494,6 +1500,8 @@ void UActorBlueprintFunctionLibrary::SetRadar(
|
|||
RetrieveActorAttributeToFloat("far", Description.Variations, 100.0f) * TO_CENTIMETERS);
|
||||
Radar->SetAperture(
|
||||
RetrieveActorAttributeToInt("aperture", Description.Variations, 10));
|
||||
Radar->SetPointLossPercentage(
|
||||
RetrieveActorAttributeToFloat("point_loss_percentage", Description.Variations, 0.7));
|
||||
}
|
||||
|
||||
#undef CARLA_ABFL_CHECK_ACTOR
|
||||
|
|
|
@ -19,6 +19,8 @@ ARadar::ARadar(const FObjectInitializer& ObjectInitializer)
|
|||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
RandomEngine = CreateDefaultSubobject<URandomEngine>(TEXT("RandomEngine"));
|
||||
|
||||
TraceParams = FCollisionQueryParams(FName(TEXT("Laser_Trace")), true, this);
|
||||
TraceParams.bTraceComplex = true;
|
||||
TraceParams.bReturnPhysicalMaterial = false;
|
||||
|
@ -50,6 +52,11 @@ void ARadar::SetAperture(int NewAperture)
|
|||
PreCalculateLineTraceIncrement();
|
||||
}
|
||||
|
||||
void ARadar::SetPointLossPercentage(float NewLossPercentage)
|
||||
{
|
||||
PointLossPercentage = NewLossPercentage;
|
||||
}
|
||||
|
||||
void ARadar::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
@ -143,6 +150,15 @@ void ARadar::SendLineTraces(float DeltaSeconds)
|
|||
|
||||
EndLocation += Rotation * LineTraceIncrement;
|
||||
|
||||
// PointLossPercentage is in range [0.0 - 1.0]
|
||||
// e.g: If PointLossPercentage is 0.7, the 70% of the rays are lost
|
||||
// TODO: Improve the performance precalculating the noise probabilty offline
|
||||
if (RandomEngine->GetBoolWithWeight(PointLossPercentage))
|
||||
{
|
||||
// Do not compute the current ray
|
||||
continue;
|
||||
}
|
||||
|
||||
Hitted = World->LineTraceSingleByChannel(
|
||||
OutHit,
|
||||
RadarLocation,
|
||||
|
|
|
@ -41,6 +41,9 @@ public:
|
|||
UFUNCTION(BlueprintCallable, Category = "Radar")
|
||||
void SetAperture(int NewAperture);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Radar")
|
||||
void SetPointLossPercentage(float NewLossPercentage);
|
||||
|
||||
protected:
|
||||
|
||||
void BeginPlay() override;
|
||||
|
@ -59,6 +62,10 @@ protected:
|
|||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Detection")
|
||||
int Steps;
|
||||
|
||||
/// Noise threshold [0.0, 1.0] of rays that will be
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Detection")
|
||||
float PointLossPercentage;
|
||||
|
||||
private:
|
||||
|
||||
void CalculateCurrentVelocity(const float DeltaTime);
|
||||
|
|
Loading…
Reference in New Issue