CARLA
 
载入中...
搜索中...
未找到
CarlaEngine.h
浏览该文件的文档.
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
15
16#include "Misc/CoreDelegates.h"
17
23#include <carla/ros2/ROS2.h>
25
26#include <mutex>
27
28class UCarlaSettings;
29struct FEpisodeSettings;
30
32{
33public:
34
35 static uint64_t FrameCounter;
36
38
39 void NotifyInitGame(const UCarlaSettings &Settings);
40
41 void NotifyBeginEpisode(UCarlaEpisode &Episode);
42
43 void NotifyEndEpisode();
44
45 const FCarlaServer &GetServer() const
46 {
47 return Server;
48 }
49
51 {
52 return Server;
53 }
54
59
60 void SetRecorder(ACarlaRecorder *InRecorder)
61 {
62 Recorder = InRecorder;
63 }
64
65 static uint64_t GetFrameCounter()
66 {
68 }
69
70 static uint64_t UpdateFrameCounter()
71 {
73 #if defined(WITH_ROS2)
75 if (ROS2->IsEnabled())
76 ROS2->SetFrame(FCarlaEngine::FrameCounter);
77 #endif
79 }
80
81 static void ResetFrameCounter(uint64_t Value = 0)
82 {
84 #if defined(WITH_ROS2)
86 if (ROS2->IsEnabled())
87 ROS2->SetFrame(FCarlaEngine::FrameCounter);
88 #endif
89 }
90
91 std::shared_ptr<carla::multigpu::Router> GetSecondaryServer()
92 {
93 return SecondaryServer;
94 }
95
96private:
97
98 void OnPreTick(UWorld *World, ELevelTick TickType, float DeltaSeconds);
99
100 void OnPostTick(UWorld *World, ELevelTick TickType, float DeltaSeconds);
101
102 void OnEpisodeSettingsChanged(const FEpisodeSettings &Settings);
103
105
106 bool bIsRunning = false;
107
108 bool bSynchronousMode = false;
109
110 bool bMapChanged = false;
111
113
115
117
119
121
122 FDelegateHandle OnPreTickHandle;
123
124 FDelegateHandle OnPostTickHandle;
125
127
128 bool bIsPrimaryServer = true;
129 bool bNewConnection = false;
130
131 std::unordered_map<uint32_t, uint32_t> MappedId;
132
133 std::shared_ptr<carla::multigpu::Router> SecondaryServer;
134 std::shared_ptr<carla::multigpu::Secondary> Secondary;
135
136 std::vector<FFrameData> FramesToProcess;
138};
139
140// Note: this has a circular dependency with FCarlaEngine; it must be included late.
Recorder for the simulation
void OnEpisodeSettingsChanged(const FEpisodeSettings &Settings)
FDelegateHandle OnEpisodeSettingsChangeHandle
std::shared_ptr< carla::multigpu::Router > SecondaryServer
std::mutex FrameToProcessMutex
void OnPreTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
static uint64_t FrameCounter
Definition CarlaEngine.h:35
static uint64_t GetFrameCounter()
Definition CarlaEngine.h:65
void ResetSimulationState()
const FCarlaServer & GetServer() const
Definition CarlaEngine.h:45
FWorldObserver WorldObserver
FCarlaServer Server
static void ResetFrameCounter(uint64_t Value=0)
Definition CarlaEngine.h:81
void NotifyEndEpisode()
std::unordered_map< uint32_t, uint32_t > MappedId
std::shared_ptr< carla::multigpu::Router > GetSecondaryServer()
Definition CarlaEngine.h:91
FEpisodeSettings CurrentSettings
bool bNewConnection
static uint64_t UpdateFrameCounter()
Definition CarlaEngine.h:70
UCarlaEpisode * CurrentEpisode
std::vector< FFrameData > FramesToProcess
void NotifyBeginEpisode(UCarlaEpisode &Episode)
void NotifyInitGame(const UCarlaSettings &Settings)
ACarlaRecorder * Recorder
void SetRecorder(ACarlaRecorder *InRecorder)
Definition CarlaEngine.h:60
bool bIsPrimaryServer
FCarlaServer & GetServer()
Definition CarlaEngine.h:50
bool bSynchronousMode
FDelegateHandle OnPreTickHandle
FDelegateHandle OnPostTickHandle
std::shared_ptr< carla::multigpu::Secondary > Secondary
UCarlaEpisode * GetCurrentEpisode()
Definition CarlaEngine.h:55
void OnPostTick(UWorld *World, ELevelTick TickType, float DeltaSeconds)
Serializes and sends all the actors in the current UCarlaEpisode.
A simulation episode.
Global settings for CARLA.
static std::shared_ptr< ROS2 > GetInstance()
Definition ROS2.h:51