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;
float DropOffGenRate
General drop off rate.
auto GetToken() const
Return the token that allows subscribing to this sensor's stream.
static FActorDefinition MakeLidarDefinition(const FString &Id)
void PreprocessRays(uint32_t Channels, uint32_t MaxPointsPerChannel) override
Method that allow to preprocess if the rays will be traced.
std::vector< std::vector< FHitResult > > RecordedHits
float DropOffIntensityLimit
General drop off rate.
virtual void ResetMemory(std::vector< uint32_t > points_per_channel)
virtual void PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTime)
virtual void WriteChannelCount(std::vector< uint32_t > points_per_channel)
void SetSeed(int32 InSeed)
static FActorDefinition GetSensorDefinition()
Helper class to store and serialize the data generated by a RawLidar.
void CreateLasers()
Creates a Laser for each channel.
ARayCastLidar(const FObjectInitializer &ObjectInitializer)
void SimulateLidar(const float DeltaTime)
Updates LidarMeasurement with the points read in DeltaTime.
A definition of a Carla Actor with all the variation and attributes.
FLidarDescription Description
FDetection ComputeDetection(const FHitResult &HitInfo, const FTransform &SensorTransf) const
carla::sensor::data::LidarData FLidarData
static void SetLidar(const FActorDescription &Description, FLidarDescription &Lidar)
A description of a Carla Actor with all its variation.
std::vector< std::vector< bool > > RayPreprocessCondition
float AtmospAttenRate
Attenuation Rate in the atmosphere in m^-1.
bool PostprocessDetection(FDetection &Detection) const
uint32 Channels
Number of lasers.
float DropOffAtZeroIntensity
General drop off rate.
float ComputeIntensity(const FSemanticDetection &RawDetection) const
Compute the received intensity of the point.
const auto & get_stream_id() const
float DropOffAlpha
Slope for the intensity dropoff of lidar points, it is calculated throught the dropoff limit and the ...
void WritePointSync(LidarDetection &detection)
bool DropOffGenActive
Enable/Disable general dropoff of lidar points.
FAsyncDataStream GetDataStream(const SensorT &Self)
Return the FDataStream associated with this sensor.
int RandomSeed
Random seed for the noise/dropoff used by this sensor.
static std::shared_ptr< ROS2 > GetInstance()
float GetNormalDistribution(float Mean, float StandardDeviation)
Vector3D MakeUnitVector() const
void ComputeAndSaveDetections(const FTransform &SensorTransform) override
This method uses all the saved FHitResults, compute the RawDetections and then send it to the LidarDa...
std::vector< uint32_t > PointsPerChannel
Helper class to store and serialize the data generated by a Lidar.
carla::streaming::detail::token_type token_type
virtual void Set(const FActorDescription &Description)
virtual void Set(const FActorDescription &Description) override
URandomEngine * RandomEngine
Random Engine used to provide noise for sensor output.