CARLA
CarlaEngine.h
Go to the documentation of this file.
1 // Copyright (c) 2017 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 
13 #include "Carla/Util/NonCopyable.h"
14 
15 #include "Misc/CoreDelegates.h"
16 
18 #include <carla/multigpu/router.h>
23 
24 #include <mutex>
25 
26 class UCarlaSettings;
27 class FFrameData;
28 struct FEpisodeSettings;
29 
30 class FCarlaEngine : private NonCopyable
31 {
32 public:
33 
34  static uint64_t FrameCounter;
35 
36  ~FCarlaEngine();
37 
38  void NotifyInitGame(const UCarlaSettings &Settings);
39 
40  void NotifyBeginEpisode(UCarlaEpisode &Episode);
41 
42  void NotifyEndEpisode();
43 
44  const FCarlaServer &GetServer() const
45  {
46  return Server;
47  }
48 
50  {
51  return Server;
52  }
53 
55  {
56  return CurrentEpisode;
57  }
58 
59  void SetRecorder(ACarlaRecorder *InRecorder)
60  {
61  Recorder = InRecorder;
62  }
63 
64  static uint64_t GetFrameCounter()
65  {
67  }
68 
69  static uint64_t UpdateFrameCounter()
70  {
73  }
74 
75  static void ResetFrameCounter(uint64_t Value = 0)
76  {
78  }
79 
80 private:
81 
82  void OnPreTick(UWorld *World, ELevelTick TickType, float DeltaSeconds);
83 
84  void OnPostTick(UWorld *World, ELevelTick TickType, float DeltaSeconds);
85 
86  void OnEpisodeSettingsChanged(const FEpisodeSettings &Settings);
87 
88  void ResetSimulationState();
89 
90  bool bIsRunning = false;
91 
92  bool bSynchronousMode = false;
93 
94  bool bMapChanged = false;
95 
97 
99 
101 
103 
105 
106  FDelegateHandle OnPreTickHandle;
107 
108  FDelegateHandle OnPostTickHandle;
109 
111 
112  bool bIsPrimaryServer = true;
113 
114  std::unordered_map<uint32_t, uint32_t> MappedId;
115 
116  std::shared_ptr<carla::multigpu::Router> SecondaryServer;
117  std::shared_ptr<carla::multigpu::Secondary> Secondary;
118 
119  std::vector<FFrameData> FramesToProcess;
121 };
UCarlaEpisode * GetCurrentEpisode()
Definition: CarlaEngine.h:54
bool bMapChanged
Definition: CarlaEngine.h:94
void OnEpisodeSettingsChanged(const FEpisodeSettings &Settings)
FDelegateHandle OnEpisodeSettingsChangeHandle
Definition: CarlaEngine.h:110
std::shared_ptr< carla::multigpu::Router > SecondaryServer
Definition: CarlaEngine.h:116
FCarlaServer Server
Definition: CarlaEngine.h:96
FCarlaServer & GetServer()
Definition: CarlaEngine.h:49
Serializes and sends all the actors in the current UCarlaEpisode.
Definition: WorldObserver.h:14
std::vector< FFrameData > FramesToProcess
Definition: CarlaEngine.h:119
static uint64_t UpdateFrameCounter()
Definition: CarlaEngine.h:69
FDelegateHandle OnPostTickHandle
Definition: CarlaEngine.h:108
FWorldObserver WorldObserver
Definition: CarlaEngine.h:98
void SetRecorder(ACarlaRecorder *InRecorder)
Definition: CarlaEngine.h:59
static void ResetFrameCounter(uint64_t Value=0)
Definition: CarlaEngine.h:75
static uint64_t GetFrameCounter()
Definition: CarlaEngine.h:64
void NotifyInitGame(const UCarlaSettings &Settings)
Definition: CarlaEngine.cpp:70
void OnPostTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
static uint64_t FrameCounter
Definition: CarlaEngine.h:34
bool bIsRunning
Definition: CarlaEngine.h:90
A simulation episode.
Definition: CarlaEpisode.h:36
std::mutex FrameToProcessMutex
Definition: CarlaEngine.h:120
void NotifyBeginEpisode(UCarlaEpisode &Episode)
Recorder for the simulation.
Definition: CarlaRecorder.h:68
ACarlaRecorder * Recorder
Definition: CarlaEngine.h:104
void NotifyEndEpisode()
std::unordered_map< uint32_t, uint32_t > MappedId
Definition: CarlaEngine.h:114
FEpisodeSettings CurrentSettings
Definition: CarlaEngine.h:102
Global settings for CARLA.
Definition: CarlaSettings.h:21
UCarlaEpisode * CurrentEpisode
Definition: CarlaEngine.h:100
void ResetSimulationState()
void OnPreTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
bool bSynchronousMode
Definition: CarlaEngine.h:92
bool bIsPrimaryServer
Definition: CarlaEngine.h:112
std::shared_ptr< carla::multigpu::Secondary > Secondary
Definition: CarlaEngine.h:117
FDelegateHandle OnPreTickHandle
Definition: CarlaEngine.h:106
const FCarlaServer & GetServer() const
Definition: CarlaEngine.h:44