CARLA
Loading...
Searching...
No Matches
CarlaLidarSubsystem.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include <util/ue-header-guard-begin.h>
10#include "CoreMinimal.h"
11#include "Subsystems/WorldSubsystem.h"
12#include "Async/TaskGraphInterfaces.h"
13#include <util/ue-header-guard-end.h>
14
15#include "CarlaLidarSubsystem.generated.h"
16
18
19/// Subsystem responsible for simulating all ray-cast LiDARs of a world.
20///
21/// Registered LiDARs are simulated asynchronously via TaskGraph high-priority
22/// worker tasks while the Game Thread processes remaining sensors (cameras, etc.).
23/// FSensorManager::PostPhysTick calls StartLidarSimulations() at the beginning of
24/// the post-physics tick, and FinishLidarSimulations() after other sensors finish.
25UCLASS()
26class CARLA_API UCarlaLidarSubsystem : public UWorldSubsystem
27{
28 GENERATED_BODY()
29
30public:
31
32 virtual void Deinitialize() override;
33
34 void RegisterLidar(ARayCastSemanticLidar *Lidar);
35
36 void UnregisterLidar(ARayCastSemanticLidar *Lidar);
37
38 bool HasActiveLidars() const
39 {
40 return ActiveLidars.Num() > 0;
41 }
42
43 int32 GetActiveLidarCount() const
44 {
45 return ActiveLidars.Num();
46 }
47
48 void StartLidarSimulations(UWorld *World, float DeltaSeconds);
49
50 void FinishLidarSimulations(UWorld *World, float DeltaSeconds);
51
52private:
53
54 TArray<TWeakObjectPtr<ARayCastSemanticLidar>> ActiveLidars;
55
56 /// LiDARs due this frame, snapshotted on the game thread for the simulation task.
57 TArray<TObjectPtr<ARayCastSemanticLidar>> LidarsToSimulate;
58
59 FGraphEventRef LidarSimulationTask;
60};
A ray-cast based Lidar sensor.
Subsystem responsible for simulating all ray-cast LiDARs of a world.
int32 GetActiveLidarCount() const
TArray< TObjectPtr< ARayCastSemanticLidar > > LidarsToSimulate
LiDARs due this frame, snapshotted on the game thread for the simulation task.
FGraphEventRef LidarSimulationTask
TArray< TWeakObjectPtr< ARayCastSemanticLidar > > ActiveLidars