From 3aae33b10f2cf9f66b750957d3c4d4af8bf8b056 Mon Sep 17 00:00:00 2001 From: Shubham Paul Date: Tue, 28 Jan 2020 02:46:05 +0530 Subject: [PATCH] fixed doppler velocity (using the delta v component along the radar and the reflection point instead of the actor) --- Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.cpp | 6 +++--- Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.cpp index 90fb0addb..6dd049ed0 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.cpp @@ -129,7 +129,7 @@ void ARadar::SendLineTraces(float DeltaTime) const TWeakObjectPtr HittedActor = OutHit.Actor; if (Hitted && HittedActor.Get()) { - const float RelativeVelocity = CalculateRelativeVelocity(OutHit, RadarLocation, ForwardVector); + const float RelativeVelocity = CalculateRelativeVelocity(OutHit, RadarLocation); const FVector2D AzimuthAndElevation = FMath::GetAzimuthAndElevation ( (EndLocation - RadarLocation).GetSafeNormal() * Range, @@ -148,7 +148,7 @@ void ARadar::SendLineTraces(float DeltaTime) } } -float ARadar::CalculateRelativeVelocity(const FHitResult& OutHit, const FVector& RadarLocation, const FVector& ForwardVector) +float ARadar::CalculateRelativeVelocity(const FHitResult& OutHit, const FVector& RadarLocation) { constexpr float TO_METERS = 1e-2; @@ -157,7 +157,7 @@ float ARadar::CalculateRelativeVelocity(const FHitResult& OutHit, const FVector& const FVector TargetLocation = OutHit.ImpactPoint; const FVector Direction = (TargetLocation - RadarLocation).GetSafeNormal(); const FVector DeltaVelocity = (TargetVelocity - CurrentVelocity); - const float V = TO_METERS * FVector::DotProduct(DeltaVelocity, ForwardVector); + const float V = TO_METERS * FVector::DotProduct(DeltaVelocity, Direction); return V; } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.h index 8e527c933..753868b28 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/Radar.h @@ -68,7 +68,7 @@ private: void SendLineTraces(float DeltaTime); - float CalculateRelativeVelocity(const FHitResult& OutHit, const FVector& RadarLocation, const FVector& ForwardVector); + float CalculateRelativeVelocity(const FHitResult& OutHit, const FVector& RadarLocation); FRadarData RadarData;