diff --git a/PythonClient/manual_control.py b/PythonClient/manual_control.py index c89c660ce..417d8c304 100755 --- a/PythonClient/manual_control.py +++ b/PythonClient/manual_control.py @@ -315,7 +315,6 @@ class CarlaGame(object): ) self._display.blit(surface, (10, 10)) - if self._map_view is not None: array = self._map_view array = array[:, :, :3] diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Lidar.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Lidar.cpp index 824adb5f9..bc2f9d7a4 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Lidar.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Lidar.cpp @@ -8,8 +8,8 @@ // Sets default values ALidar::ALidar() { - // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. - PrimaryActorTick.bCanEverTick = true; + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; auto MeshComp = CreateDefaultSubobject(TEXT("CamMesh0")); MeshComp->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName); @@ -24,12 +24,12 @@ ALidar::ALidar() void ALidar::Set(const FLidarDescription &LidarDescription) { Channels = LidarDescription.Channels; - Range = LidarDescription.Range; - PointsPerSecond = LidarDescription.PointsPerSecond; - RotationFrequency = LidarDescription.RotationFrequency; - UpperFovLimit = LidarDescription.UpperFovLimit; - LowerFovLimit = LidarDescription.LowerFovLimit; - ShowDebugPoints = LidarDescription.ShowDebugPoints; + Range = LidarDescription.Range; + PointsPerSecond = LidarDescription.PointsPerSecond; + RotationFrequency = LidarDescription.RotationFrequency; + UpperFovLimit = LidarDescription.UpperFovLimit; + LowerFovLimit = LidarDescription.LowerFovLimit; + ShowDebugPoints = LidarDescription.ShowDebugPoints; CreateLasers(); } @@ -38,45 +38,45 @@ void ALidar::CreateLasers() float dAngle = (UpperFovLimit - LowerFovLimit) / (Channels - 1); Lasers.Empty(); - for(int i=0; i Lasers; - float CurrentHorizontalAngle = 0; + TArray Lasers; + float CurrentHorizontalAngle = 0; void CreateLasers(); @@ -35,37 +35,37 @@ public: void ReadPoints(float DeltaTime, FCapturedLidarSegment& LidarSegmentData); /** Number of lasers */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - int Channels = 32; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + int Channels = 32; /** Measure distance */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float Range = 5000; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float Range = 5000; /** Points generated by all lasers per second */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float PointsPerSecond = 56000; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float PointsPerSecond = 56000; /** Lidar rotation frequency */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float RotationFrequency = 10; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float RotationFrequency = 10; /** Upper laser angle, counts from horizontal, positive values means above horizontal line */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float UpperFovLimit = 10; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float UpperFovLimit = 10; /** Lower laser angle, counts from horizontal, negative values means under horizontal line */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float LowerFovLimit = -30; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float LowerFovLimit = -30; /** wether to show debug points of laser hits in simulator */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - bool ShowDebugPoints = false; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + bool ShowDebugPoints = false; }; diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/LidarLaser.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/LidarLaser.cpp index 803273860..9710a2f4d 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/LidarLaser.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/LidarLaser.cpp @@ -8,47 +8,47 @@ int LidarLaser::GetId() { - return Id; + return Id; } bool LidarLaser::Measure(ALidar* Lidar, float HorizontalAngle, FVector& XYZ, bool Debug) { - FCollisionQueryParams TraceParams = FCollisionQueryParams(FName(TEXT("Laser_Trace")), true, Lidar); - TraceParams.bTraceComplex = true; - TraceParams.bReturnPhysicalMaterial = false; + FCollisionQueryParams TraceParams = FCollisionQueryParams(FName(TEXT("Laser_Trace")), true, Lidar); + TraceParams.bTraceComplex = true; + TraceParams.bReturnPhysicalMaterial = false; - FHitResult HitInfo(ForceInit); + FHitResult HitInfo(ForceInit); - FVector LidarBodyLoc = Lidar->GetActorLocation(); + FVector LidarBodyLoc = Lidar->GetActorLocation(); FRotator LidarBodyRot = Lidar->GetActorRotation(); - FRotator LaserRot (VerticalAngle, HorizontalAngle, 0); // float InPitch, float InYaw, float InRoll + FRotator LaserRot (VerticalAngle, HorizontalAngle, 0); // float InPitch, float InYaw, float InRoll FRotator ResultRot = UKismetMathLibrary::ComposeRotators( LaserRot, LidarBodyRot ); - FVector EndTrace = Lidar->Range * UKismetMathLibrary::GetForwardVector(ResultRot) + LidarBodyLoc; + FVector EndTrace = Lidar->Range * UKismetMathLibrary::GetForwardVector(ResultRot) + LidarBodyLoc; - Lidar->GetWorld()->LineTraceSingleByChannel( - HitInfo, - LidarBodyLoc, - EndTrace, - ECC_MAX, - TraceParams, - FCollisionResponseParams::DefaultResponseParam - ); + Lidar->GetWorld()->LineTraceSingleByChannel( + HitInfo, + LidarBodyLoc, + EndTrace, + ECC_MAX, + TraceParams, + FCollisionResponseParams::DefaultResponseParam + ); - if (HitInfo.bBlockingHit) - { + if (HitInfo.bBlockingHit) + { if (Debug) { - DrawDebugPoint( - Lidar->GetWorld(), - HitInfo.ImpactPoint, - 10, //size - FColor(255,0,255), - false, //persistent (never goes away) - 0.1 //point leaves a trail on moving object - ); + DrawDebugPoint( + Lidar->GetWorld(), + HitInfo.ImpactPoint, + 10, //size + FColor(255,0,255), + false, //persistent (never goes away) + 0.1 //point leaves a trail on moving object + ); } XYZ = LidarBodyLoc - HitInfo.ImpactPoint; @@ -58,9 +58,9 @@ bool LidarLaser::Measure(ALidar* Lidar, float HorizontalAngle, FVector& XYZ, boo FVector(0, 0, 1) ); - return true; - } else { + return true; + } else { XYZ = FVector(0, 0, 0); - return false; - } + return false; + } } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/LidarLaser.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/LidarLaser.h index 511870803..6ddb842bd 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/LidarLaser.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/LidarLaser.h @@ -10,17 +10,17 @@ class CARLA_API LidarLaser { public: - LidarLaser(int Id, float VerticalAngle) : - Id(Id), - VerticalAngle(VerticalAngle) - {} + LidarLaser(int Id, float VerticalAngle) : + Id(Id), + VerticalAngle(VerticalAngle) + {} - int GetId(); - bool Measure(ALidar* Lidar, float HorizontalAngle, FVector& XYZ, bool Debug = false); + int GetId(); + bool Measure(ALidar* Lidar, float HorizontalAngle, FVector& XYZ, bool Debug = false); private: - int Id; - float VerticalAngle; + int Id; + float VerticalAngle; }; diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/LidarDescription.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/LidarDescription.h index f1a39c231..dbb8128a1 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/LidarDescription.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/LidarDescription.h @@ -10,38 +10,38 @@ struct FLidarDescription GENERATED_USTRUCT_BODY() /** Number of lasers */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - int Channels = 32; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + int Channels = 32; /** Measure distance */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float Range = 5000; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float Range = 5000; /** Points generated by all lasers per second */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float PointsPerSecond = 56000; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float PointsPerSecond = 56000; /** Lidar rotation frequency */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float RotationFrequency = 10; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float RotationFrequency = 10; /** Upper laser angle, counts from horizontal, positive values means above horizontal line */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float UpperFovLimit = 10; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float UpperFovLimit = 10; /** Lower laser angle, counts from horizontal, negative values means under horizontal line */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - float LowerFovLimit = -30; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + float LowerFovLimit = -30; /** wether to show debug points of laser hits in simulator */ - UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") - bool ShowDebugPoints = false; + UPROPERTY(EditDefaultsOnly, Category = "Lidar Description") + bool ShowDebugPoints = false; /** Position relative to the player. */ UPROPERTY(Category = "Lidar Description", EditDefaultsOnly)