CARLA
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ARayCastLidar Class Reference

A ray-cast based Lidar sensor. More...

#include <RayCastLidar.h>

+ Inheritance diagram for ARayCastLidar:

Public Member Functions

 ARayCastLidar (const FObjectInitializer &ObjectInitializer)
 
const TArray< float > & GetTestPointCloud () const
 
virtual void SendData (const float DeltaTime) override
 
virtual void Set (const FActorDescription &Description) override
 
virtual void Set (const FLidarDescription &LidarDescription) override
 
- Public Member Functions inherited from ARayCastSemanticLidar
 ARayCastSemanticLidar (const FObjectInitializer &ObjectInitializer)
 
void GetMirrorState (carla::multigpu::SensorState &State) const override
 Multi-GPU: the runtime state this sensor starts its next tick from (noise generator, sweep angle, history).
 
void SetMirrorState (const carla::multigpu::SensorState &State) override
 
virtual void SimulateLidar (const float DeltaTime, bool bLockPhysics=true)
 
- Public Member Functions inherited from ASensor
bool AreClientsListening ()
 
 ASensor (const FObjectInitializer &ObjectInitializer)
 
void ClearReadyToTick ()
 
std::optional< FActorAttribute > GetAttribute (const FString Name)
 
const UCarlaEpisode & GetEpisode () const
 
URandomEngine * GetRandomEngine ()
 
float GetReadyToTickDeltaSeconds () const
 
int32 GetSeed () const
 
auto GetToken () const
 Return the token that allows subscribing to this sensor's stream.
 
bool IsReadyToTick () const
 
bool IsStreamReady ()
 
FDataStream MoveDataStream ()
 
virtual void OnFirstClientConnected ()
 
virtual void OnLastClientDisconnected ()
 
virtual void PostPhysTick (UWorld *World, ELevelTick TickType, float DeltaSeconds)
 
void PostPhysTickInternal (UWorld *World, ELevelTick TickType, float DeltaSeconds)
 
virtual void PrePhysTick (float DeltaSeconds)
 
void SetDataStream (FDataStream InStream)
 Replace the FDataStream associated with this sensor.
 
void SetEpisode (const UCarlaEpisode &InEpisode)
 
void SetPrimaryTick (float DeltaSeconds)
 Multi-GPU secondary: tick in this engine frame, with the primary's delta.
 
void SetSavingDataToDisk (bool bSavingData)
 
void SetSeed (int32 InSeed)
 
void Tick (const float DeltaTime) final
 

Static Public Member Functions

static FActorDefinition GetSensorDefinition ()
 
- Static Public Member Functions inherited from ARayCastSemanticLidar
static FActorDefinition GetSensorDefinition ()
 
- Static Public Member Functions inherited from ASensor
static FSensorCaptureContext MakeCaptureContext (const ASensor &Sensor)
 Call on the game thread right after CaptureScene().
 

Private Types

using FDetection = carla::sensor::data::LidarDetection
 
using FLidarData = carla::sensor::data::LidarData
 

Private Member Functions

void ComputeAndSaveDetections (const FTransform &SensorTransform) override
 Copies the per-channel detections into the LidarData structure.
 
FDetection ComputeDetection (const FHitResult &HitInfo, const FTransform &InverseSensorTransform) const
 
float ComputeIntensity (const FSemanticDetection &RawDetection) const
 Compute the received intensity of the point.
 
bool PostprocessDetection (FDetection &Detection) const
 
void PreprocessRays (uint32_t Channels, uint32_t MaxPointsPerChannel) override
 Method that allow to preprocess if the rays will be traced.
 
void ResetDetections (uint32_t Channels, uint32_t MaxPointsPerChannel) override
 Clear the per-channel detection buffers.
 
void WriteDetectionAsync (uint32_t Channel, const FHitResult &HitInfo, const FTransform &InverseSensorTransform, const FVector &SensorLocation) override
 Computes the detection of a hit inside the raycast ParallelFor.
 

Private Attributes

std::vector< std::vector< FDetection > > Detections
 
float DropOffAlpha
 Slope for the intensity dropoff of lidar points, it is calculated throught the dropoff limit and the dropoff at zero intensity The points is kept with a probality alpha*Intensity + beta where alpha = (1 - dropoff_zero_intensity) / droppoff_limit beta = (1 - dropoff_zero_intensity)
 
float DropOffBeta
 
bool DropOffGenActive
 Enable/Disable general dropoff of lidar points.
 
FLidarData LidarData
 
TArray< float > PointCloudLidarData
 

Additional Inherited Members

- Protected Types inherited from ARayCastSemanticLidar
using FSemanticDetection = carla::sensor::data::SemanticLidarDetection
 
using FSemanticLidarData = carla::sensor::data::SemanticLidarData
 
- Protected Member Functions inherited from ARayCastSemanticLidar
virtual void BeginPlay () override
 
void ComputeRawDetection (const FHitResult &HitInfo, const FTransform &InverseSensorTransform, const FVector &SensorLocation, FSemanticDetection &Detection) const
 Compute all raw detection information.
 
void CreateLasers ()
 Creates a Laser for each channel.
 
virtual void EndPlay (EEndPlayReason::Type EndPlayReason) override
 
bool ShootLaser (const float VerticalAngle, float HorizontalAngle, FHitResult &HitResult, FCollisionQueryParams &TraceParams, const FVector &LidarBodyLocation, const FRotator &LidarBodyRotation) const
 Shoot a laser ray-trace, return whether the laser hit something.
 
- Protected Member Functions inherited from ASensor
void EndPlay (EEndPlayReason::Type EndPlayReason) override
 
template<typename SensorType >
FAsyncDataStream GetDataStream (SensorType &&Self)
 Return the FDataStream associated with this sensor.
 
void PostActorCreated () override
 
- Static Protected Member Functions inherited from ARayCastSemanticLidar
template<typename DetectionT , typename LidarDataT , typename PostprocessT >
static void CompactAndWriteDetections (std::vector< std::vector< DetectionT > > &Detections, std::vector< uint32_t > &OutPointsPerChannel, uint32_t Channels, LidarDataT &LidarData, PostprocessT &&Postprocess)
 Post-processes the detections channel by channel, drops the rejected ones and writes the rest to LidarData.
 
template<typename DetectionT >
static void CopyDetectionsToPointCloud (const std::vector< std::vector< DetectionT > > &Detections, const std::vector< uint32_t > &InPointsPerChannel, TArray< float > &PointCloud)
 Copies the kept detections into a flat x, y, z, intensity array (editor debug point cloud).
 
template<typename DetectionT >
static void ResetChannelDetections (std::vector< std::vector< DetectionT > > &Detections, uint32_t Channels, uint32_t MaxPointsPerChannel)
 Clears every channel buffer and reserves room for a full scan.
 
- Static Protected Member Functions inherited from ASensor
template<typename SensorType , typename ElementType >
static void SendDataToClient (SensorType &&Sensor, TArrayView< ElementType > SensorData, const FSensorCaptureContext &CaptureContext)
 
- Protected Attributes inherited from ARayCastSemanticLidar
FLidarDescription Description
 
TArray< float > LaserAngles
 
std::vector< uint32_t > PointsPerChannel
 
std::vector< std::vector< bool > > RayPreprocessCondition
 
- Protected Attributes inherited from ASensor
bool bIsActive = false
 
bool bSavingDataToDisk = false
 
URandomEngine * RandomEngine = nullptr
 Random Engine used to provide noise for sensor output.
 
int32 Seed = 123456789
 Seed of the pseudo-random engine.
 

Detailed Description

A ray-cast based Lidar sensor.

Definition at line 24 of file RayCastLidar.h.

Member Typedef Documentation

◆ FDetection

Definition at line 29 of file RayCastLidar.h.

◆ FLidarData

Definition at line 28 of file RayCastLidar.h.

Constructor & Destructor Documentation

◆ ARayCastLidar()

ARayCastLidar::ARayCastLidar ( const FObjectInitializer &  ObjectInitializer)

Member Function Documentation

◆ ComputeAndSaveDetections()

void ARayCastLidar::ComputeAndSaveDetections ( const FTransform &  SensorTransform)
overrideprivatevirtual

◆ ComputeDetection()

ARayCastLidar::FDetection ARayCastLidar::ComputeDetection ( const FHitResult &  HitInfo,
const FTransform &  InverseSensorTransform 
) const
private

◆ ComputeIntensity()

float ARayCastLidar::ComputeIntensity ( const FSemanticDetection &  RawDetection) const
private

◆ GetSensorDefinition()

FActorDefinition ARayCastLidar::GetSensorDefinition ( )
static

◆ GetTestPointCloud()

const TArray< float > & ARayCastLidar::GetTestPointCloud ( ) const
inline

Definition at line 40 of file RayCastLidar.h.

◆ PostprocessDetection()

bool ARayCastLidar::PostprocessDetection ( FDetection &  Detection) const
private

◆ PreprocessRays()

void ARayCastLidar::PreprocessRays ( uint32_t  Channels,
uint32_t  MaxPointsPerChannel 
)
overrideprivatevirtual

◆ ResetDetections()

void ARayCastLidar::ResetDetections ( uint32_t  Channels,
uint32_t  MaxPointsPerChannel 
)
overrideprivatevirtual

Clear the per-channel detection buffers.

Reimplemented from ARayCastSemanticLidar.

Definition at line 157 of file RayCastLidar.cpp.

References Detections, and ARayCastSemanticLidar::ResetChannelDetections().

◆ SendData()

void ARayCastLidar::SendData ( const float  DeltaTime)
overridevirtual

◆ Set() [1/2]

void ARayCastLidar::Set ( const FActorDescription &  Description)
overridevirtual

Reimplemented from ARayCastSemanticLidar.

Definition at line 38 of file RayCastLidar.cpp.

References ASensor::Set(), Set(), and UActorBlueprintFunctionLibrary::SetLidar().

Referenced by Set().

◆ Set() [2/2]

void ARayCastLidar::Set ( const FLidarDescription &  LidarDescription)
overridevirtual

◆ WriteDetectionAsync()

void ARayCastLidar::WriteDetectionAsync ( uint32_t  Channel,
const FHitResult &  HitInfo,
const FTransform &  InverseSensorTransform,
const FVector &  SensorLocation 
)
overrideprivatevirtual

Computes the detection of a hit inside the raycast ParallelFor.

Reimplemented from ARayCastSemanticLidar.

Definition at line 162 of file RayCastLidar.cpp.

References ComputeDetection(), DEBUG_ASSERT, and Detections.

Member Data Documentation

◆ Detections

std::vector<std::vector<FDetection> > ARayCastLidar::Detections
private

Definition at line 56 of file RayCastLidar.h.

Referenced by ComputeAndSaveDetections(), ResetDetections(), and WriteDetectionAsync().

◆ DropOffAlpha

float ARayCastLidar::DropOffAlpha
private

Slope for the intensity dropoff of lidar points, it is calculated throught the dropoff limit and the dropoff at zero intensity The points is kept with a probality alpha*Intensity + beta where alpha = (1 - dropoff_zero_intensity) / droppoff_limit beta = (1 - dropoff_zero_intensity)

Definition at line 66 of file RayCastLidar.h.

Referenced by PostprocessDetection(), and Set().

◆ DropOffBeta

float ARayCastLidar::DropOffBeta
private

Definition at line 67 of file RayCastLidar.h.

Referenced by PostprocessDetection(), and Set().

◆ DropOffGenActive

bool ARayCastLidar::DropOffGenActive
private

Enable/Disable general dropoff of lidar points.

Definition at line 59 of file RayCastLidar.h.

Referenced by PreprocessRays(), and Set().

◆ LidarData

FLidarData ARayCastLidar::LidarData
private

Definition at line 54 of file RayCastLidar.h.

Referenced by ComputeAndSaveDetections(), SendData(), and Set().

◆ PointCloudLidarData

TArray<float> ARayCastLidar::PointCloudLidarData
private

Definition at line 70 of file RayCastLidar.h.

Referenced by ComputeAndSaveDetections().


The documentation for this class was generated from the following files: