20#include "DrawDebugHelpers.h"
21#include "Engine/CollisionProfile.h"
22#include "Runtime/Engine/Classes/Kismet/KismetMathLibrary.h"
31 : Super(ObjectInitializer) {
33 RandomEngine = CreateDefaultSubobject<URandomEngine>(TEXT(
"RandomEngine"));
42 Set(LidarDescription);
64 auto SensorTransform = DataStream.GetSensorTransform();
67 TRACE_CPUPROFILER_EVENT_SCOPE_STR(
"Send Stream");
68 DataStream.SerializeAndSend(*
this,
LidarData, DataStream.PopBufferFromPool());
71 #if defined(WITH_ROS2)
73 if (ROS2->IsEnabled())
75 TRACE_CPUPROFILER_EVENT_SCOPE_STR(
"ROS2 Send");
77 AActor* ParentActor = GetAttachParentActor();
80 FTransform LocalTransformRelativeToParent = GetActorTransform().GetRelativeTransform(ParentActor->GetActorTransform());
81 ROS2->ProcessDataFromLidar(DataStream.GetSensorType(), StreamId, LocalTransformRelativeToParent,
LidarData,
this);
85 ROS2->ProcessDataFromLidar(DataStream.GetSensorType(), StreamId, SensorTransform,
LidarData,
this);
96 const float Distance = HitPoint.
Length();
99 const float AbsAtm = exp(-AttenAtm * Distance);
101 const float IntRec = AbsAtm;
109 const FVector HitPoint = HitInfo.ImpactPoint;
110 Detection.
point = SensorTransf.Inverse().TransformPosition(HitPoint);
115 const float AbsAtm = exp(-AttenAtm * Distance);
117 const float IntRec = AbsAtm;
125 Super::PreprocessRays(Channels, MaxPointsPerChannel);
127 for (
auto ch = 0u; ch < Channels; ch++) {
128 for (
auto p = 0u; p < MaxPointsPerChannel; p++) {
139 Detection.
point += Noise;
142 const float Intensity = Detection.
intensity;
carla::sensor::data::LidarData FLidarData
static FActorDefinition GetSensorDefinition()
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.
float DropOffAlpha
Slope for the intensity dropoff of lidar points, it is calculated throught the dropoff limit and the ...
virtual void Set(const FActorDescription &Description) override
bool DropOffGenActive
Enable/Disable general dropoff of lidar points
ARayCastLidar(const FObjectInitializer &ObjectInitializer)
virtual void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTime)
void ComputeAndSaveDetections(const FTransform &SensorTransform) override
This method uses all the saved FHitResults, compute the RawDetections and then send it to the LidarDa...
FDetection ComputeDetection(const FHitResult &HitInfo, const FTransform &SensorTransf) const
std::vector< uint32_t > PointsPerChannel
void SimulateLidar(const float DeltaTime)
Updates LidarMeasurement with the points read in DeltaTime.
void CreateLasers()
Creates a Laser for each channel.
std::vector< std::vector< bool > > RayPreprocessCondition
std::vector< std::vector< FHitResult > > RecordedHits
FLidarDescription Description
virtual void Set(const FActorDescription &Description)
auto GetToken() const
Return the token that allows subscribing to this sensor's stream.
FAsyncDataStream GetDataStream(const SensorT &Self)
Return the FDataStream associated with this sensor.
URandomEngine * RandomEngine
Random Engine used to provide noise for sensor output.
void SetSeed(int32 InSeed)
static void SetLidar(const FActorDescription &Description, FLidarDescription &Lidar)
static FActorDefinition MakeLidarDefinition(const FString &Id)
float GetNormalDistribution(float Mean, float StandardDeviation)
Vector3D MakeUnitVector() const
static std::shared_ptr< ROS2 > GetInstance()
virtual void ResetMemory(std::vector< uint32_t > points_per_channel)
void WritePointSync(LidarDetection &detection)
Helper class to store and serialize the data generated by a Lidar.
virtual void WriteChannelCount(std::vector< uint32_t > points_per_channel)
Helper class to store and serialize the data generated by a RawLidar.
Serializes a stream endpoint.
const auto & get_stream_id() const
A definition of a Carla Actor with all the variation and attributes.
A description of a Carla Actor with all its variation.
float DropOffAtZeroIntensity
General drop off rate.
int RandomSeed
Random seed for the noise/dropoff used by this sensor.
float DropOffGenRate
General drop off rate.
uint32 Channels
Number of lasers.
float DropOffIntensityLimit
General drop off rate.
float AtmospAttenRate
Attenuation Rate in the atmosphere in m^-1.