Add horizontal fov property to lidar description

This commit is contained in:
Tobias Völkel 2020-10-29 13:31:02 +01:00 committed by DSantosO
parent 6b27c8226f
commit 7d0a46d45d
3 changed files with 22 additions and 5 deletions

View File

@ -849,6 +849,11 @@ void UActorBlueprintFunctionLibrary::MakeLidarDefinition(
LowerFOV.Id = TEXT("lower_fov");
LowerFOV.Type = EActorAttributeType::Float;
LowerFOV.RecommendedValues = { TEXT("-30.0") };
// Horizontal FOV.
FActorVariation HorizontalFOV;
HorizontalFOV.Id = TEXT("horizontal_fov");
HorizontalFOV.Type = EActorAttributeType::Float;
HorizontalFOV.RecommendedValues = { TEXT("360.0") };
// Atmospheric Attenuation Rate.
FActorVariation AtmospAttenRate;
AtmospAttenRate.Id = TEXT("atmosphere_attenuation_rate");
@ -894,7 +899,9 @@ void UActorBlueprintFunctionLibrary::MakeLidarDefinition(
DropOffGenRate,
DropOffIntensityLimit,
DropOffAtZeroIntensity,
StdDevLidar});
StdDevLidar,
HorizontalFOV
});
}
else if (Id == "ray_cast_semantic") {
Definition.Variations.Append({
@ -903,7 +910,8 @@ void UActorBlueprintFunctionLibrary::MakeLidarDefinition(
PointsPerSecond,
Frequency,
UpperFOV,
LowerFOV});
LowerFOV,
HorizontalFOV});
}
else {
DEBUG_ASSERT(false);
@ -1516,6 +1524,8 @@ void UActorBlueprintFunctionLibrary::SetLidar(
RetrieveActorAttributeToFloat("upper_fov", Description.Variations, Lidar.UpperFovLimit);
Lidar.LowerFovLimit =
RetrieveActorAttributeToFloat("lower_fov", Description.Variations, Lidar.LowerFovLimit);
Lidar.HorizontalFov =
RetrieveActorAttributeToFloat("horizontal_fov", Description.Variations, Lidar.HorizontalFov);
Lidar.AtmospAttenRate =
RetrieveActorAttributeToFloat("atmosphere_attenuation_rate", Description.Variations, Lidar.AtmospAttenRate);
Lidar.RandomSeed =

View File

@ -38,6 +38,10 @@ struct CARLA_API FLidarDescription
/// horizontal line.
UPROPERTY(EditAnywhere)
float LowerFovLimit = -30.0f;
/// Horizontal field of view
UPROPERTY(EditAnywhere)
float HorizontalFov = 360.0f;
/// Attenuation Rate in the atmosphere in m^-1.
UPROPERTY(EditAnywhere)

View File

@ -95,7 +95,8 @@ void ARayCastSemanticLidar::SimulateLidar(const float DeltaTime)
const float CurrentHorizontalAngle = carla::geom::Math::ToDegrees(
SemanticLidarData.GetHorizontalAngle());
const float AngleDistanceOfTick = Description.RotationFrequency * 360.0f * DeltaTime;
const float AngleDistanceOfTick = Description.RotationFrequency * Description.HorizontalFov
* DeltaTime;
const float AngleDistanceOfLaserMeasure = AngleDistanceOfTick / PointsToScanWithOneLaser;
ResetRecordedHits(ChannelCount, PointsToScanWithOneLaser);
@ -106,7 +107,9 @@ void ARayCastSemanticLidar::SimulateLidar(const float DeltaTime)
for (auto idxPtsOneLaser = 0u; idxPtsOneLaser < PointsToScanWithOneLaser; idxPtsOneLaser++) {
FHitResult HitResult;
const float VertAngle = LaserAngles[idxChannel];
const float HorizAngle = CurrentHorizontalAngle + AngleDistanceOfLaserMeasure * idxPtsOneLaser;
const float HorizAngle = std::fmod(std::fmod(CurrentHorizontalAngle
+ AngleDistanceOfLaserMeasure * idxPtsOneLaser, Description.HorizontalFov)
- Description.HorizontalFov / 2, 360.0f);
const bool PreprocessResult = RayPreprocessCondition[idxChannel][idxPtsOneLaser];
if (PreprocessResult && ShootLaser(VertAngle, HorizAngle, HitResult)) {
@ -120,7 +123,7 @@ void ARayCastSemanticLidar::SimulateLidar(const float DeltaTime)
ComputeAndSaveDetections(ActorTransf);
const float HorizontalAngle = carla::geom::Math::ToRadians(
std::fmod(CurrentHorizontalAngle + AngleDistanceOfTick, 360.0f));
std::fmod(CurrentHorizontalAngle + AngleDistanceOfTick, Description.HorizontalFov));
SemanticLidarData.SetHorizontalAngle(HorizontalAngle);
}