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 #include "Carla/Game/FrameData.h"
15 
16 #include "Misc/CoreDelegates.h"
17 
19 #include <carla/multigpu/router.h>
24 
25 #include <mutex>
26 
27 class UCarlaSettings;
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  std::shared_ptr<carla::multigpu::Router> GetSecondaryServer()
81  {
82  return SecondaryServer;
83  }
84 
85 private:
86 
87  void OnPreTick(UWorld *World, ELevelTick TickType, float DeltaSeconds);
88 
89  void OnPostTick(UWorld *World, ELevelTick TickType, float DeltaSeconds);
90 
91  void OnEpisodeSettingsChanged(const FEpisodeSettings &Settings);
92 
93  void ResetSimulationState();
94 
95  bool bIsRunning = false;
96 
97  bool bSynchronousMode = false;
98 
99  bool bMapChanged = false;
100 
102 
104 
106 
108 
110 
111  FDelegateHandle OnPreTickHandle;
112 
113  FDelegateHandle OnPostTickHandle;
114 
116 
117  bool bIsPrimaryServer = true;
118  bool bNewConnection = false;
119 
120  std::unordered_map<uint32_t, uint32_t> MappedId;
121 
122  std::shared_ptr<carla::multigpu::Router> SecondaryServer;
123  std::shared_ptr<carla::multigpu::Secondary> Secondary;
124 
125  std::vector<FFrameData> FramesToProcess;
127 };
128 
129 // Note: this has a circular dependency with FCarlaEngine; it must be included late.
UCarlaEpisode * GetCurrentEpisode()
Definition: CarlaEngine.h:54
bool bMapChanged
Definition: CarlaEngine.h:99
void OnEpisodeSettingsChanged(const FEpisodeSettings &Settings)
FDelegateHandle OnEpisodeSettingsChangeHandle
Definition: CarlaEngine.h:115
std::shared_ptr< carla::multigpu::Router > SecondaryServer
Definition: CarlaEngine.h:122
FCarlaServer Server
Definition: CarlaEngine.h:101
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:125
static uint64_t UpdateFrameCounter()
Definition: CarlaEngine.h:69
FDelegateHandle OnPostTickHandle
Definition: CarlaEngine.h:113
std::shared_ptr< carla::multigpu::Router > GetSecondaryServer()
Definition: CarlaEngine.h:80
FWorldObserver WorldObserver
Definition: CarlaEngine.h:103
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:71
void OnPostTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
static uint64_t FrameCounter
Definition: CarlaEngine.h:34
bool bIsRunning
Definition: CarlaEngine.h:95
A simulation episode.
Definition: CarlaEpisode.h:37
std::mutex FrameToProcessMutex
Definition: CarlaEngine.h:126
void NotifyBeginEpisode(UCarlaEpisode &Episode)
Recorder for the simulation.
Definition: CarlaRecorder.h:76
ACarlaRecorder * Recorder
Definition: CarlaEngine.h:109
bool bNewConnection
Definition: CarlaEngine.h:118
void NotifyEndEpisode()
std::unordered_map< uint32_t, uint32_t > MappedId
Definition: CarlaEngine.h:120
FEpisodeSettings CurrentSettings
Definition: CarlaEngine.h:107
Global settings for CARLA.
Definition: CarlaSettings.h:21
UCarlaEpisode * CurrentEpisode
Definition: CarlaEngine.h:105
void ResetSimulationState()
void OnPreTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
bool bSynchronousMode
Definition: CarlaEngine.h:97
bool bIsPrimaryServer
Definition: CarlaEngine.h:117
std::shared_ptr< carla::multigpu::Secondary > Secondary
Definition: CarlaEngine.h:123
FDelegateHandle OnPreTickHandle
Definition: CarlaEngine.h:111
const FCarlaServer & GetServer() const
Definition: CarlaEngine.h:44