Add command to LOAD_MAP in multi-gpu mode
This commit is contained in:
parent
182a48a2f9
commit
e608c8c55f
|
@ -31,9 +31,9 @@ void PrimaryCommands::SendFrameData(carla::Buffer buffer) {
|
|||
}
|
||||
|
||||
// broadcast to all secondary servers the map to load
|
||||
void PrimaryCommands::SendLoadMap(std::string) {
|
||||
// carla::Buffer buf((unsigned char *) map.c_str(), (size_t) map.size());
|
||||
log_info("sending load map command");
|
||||
void PrimaryCommands::SendLoadMap(std::string map) {
|
||||
carla::Buffer buf((unsigned char *) map.c_str(), (size_t) map.size() + 1);
|
||||
_router->Write(MultiGPUCommand::LOAD_MAP, std::move(buf));
|
||||
}
|
||||
|
||||
// send to who the router wants the request for a token
|
||||
|
|
|
@ -127,8 +127,11 @@ void FCarlaEngine::NotifyInitGame(const UCarlaSettings &Settings)
|
|||
break;
|
||||
}
|
||||
case carla::multigpu::MultiGPUCommand::LOAD_MAP:
|
||||
{
|
||||
FString FinalPath((char *) Data.data());
|
||||
UGameplayStatics::OpenLevel(CurrentEpisode->GetWorld(), *FinalPath, true);
|
||||
break;
|
||||
|
||||
}
|
||||
case carla::multigpu::MultiGPUCommand::GET_TOKEN:
|
||||
{
|
||||
// get the sensor id
|
||||
|
|
|
@ -77,6 +77,11 @@ public:
|
|||
FCarlaEngine::FrameCounter = Value;
|
||||
}
|
||||
|
||||
std::shared_ptr<carla::multigpu::Router> GetSecondaryServer()
|
||||
{
|
||||
return SecondaryServer;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void OnPreTick(UWorld *World, ELevelTick TickType, float DeltaSeconds);
|
||||
|
|
|
@ -103,6 +103,21 @@ bool UCarlaEpisode::LoadNewEpisode(const FString &MapString, bool ResetSettings)
|
|||
UGameplayStatics::OpenLevel(GetWorld(), *FinalPath, true);
|
||||
if (ResetSettings)
|
||||
ApplySettings(FEpisodeSettings{});
|
||||
|
||||
// send 'LOAD_MAP' command to all secondary servers (if any)
|
||||
if (bIsPrimaryServer)
|
||||
{
|
||||
UCarlaGameInstance *GameInstance = UCarlaStatics::GetGameInstance(GetWorld());
|
||||
if(GameInstance)
|
||||
{
|
||||
FCarlaEngine *CarlaEngine = GameInstance->GetCarlaEngine();
|
||||
auto SecondaryServer = CarlaEngine->GetSecondaryServer();
|
||||
if (SecondaryServer->HasClientsConnected())
|
||||
{
|
||||
SecondaryServer->GetCommander().SendLoadMap(std::string(TCHAR_TO_UTF8(*FinalPath)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return bIsFileFound;
|
||||
}
|
||||
|
|
|
@ -108,6 +108,11 @@ public:
|
|||
return CurrentMapLayer;
|
||||
}
|
||||
|
||||
FCarlaEngine* GetCarlaEngine()
|
||||
{
|
||||
return &CarlaEngine;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(Category = "CARLA Settings", EditAnywhere)
|
||||
|
|
Loading…
Reference in New Issue