Add MapInfo message and serialize OpenDrive file
This commit is contained in:
parent
9aed85ed37
commit
4f92ec758c
|
@ -76,6 +76,10 @@ namespace detail {
|
|||
return _pimpl->CallAndWait<rpc::EpisodeInfo>("get_episode_info");
|
||||
}
|
||||
|
||||
rpc::MapInfo Client::GetMapInfo() {
|
||||
return _pimpl->CallAndWait<rpc::MapInfo>("get_map_info");
|
||||
}
|
||||
|
||||
std::vector<rpc::ActorDefinition> Client::GetActorDefinitions() {
|
||||
return _pimpl->CallAndWait<std::vector<rpc::ActorDefinition>>("get_actor_definitions");
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "carla/rpc/Actor.h"
|
||||
#include "carla/rpc/ActorDefinition.h"
|
||||
#include "carla/rpc/EpisodeInfo.h"
|
||||
#include "carla/rpc/MapInfo.h"
|
||||
#include "carla/rpc/WeatherParameters.h"
|
||||
|
||||
#include <functional>
|
||||
|
@ -57,6 +58,8 @@ namespace detail {
|
|||
|
||||
rpc::EpisodeInfo GetEpisodeInfo();
|
||||
|
||||
rpc::MapInfo GetMapInfo();
|
||||
|
||||
std::vector<rpc::ActorDefinition> GetActorDefinitions();
|
||||
|
||||
rpc::Actor GetSpectator();
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "carla/MsgPack.h"
|
||||
|
||||
namespace carla {
|
||||
namespace rpc {
|
||||
|
||||
class MapInfo {
|
||||
public:
|
||||
|
||||
std::string name;
|
||||
|
||||
std::string open_drive_file;
|
||||
|
||||
MSGPACK_DEFINE_ARRAY(name, open_drive_file);
|
||||
};
|
||||
|
||||
} // namespace rpc
|
||||
} // namespace carla
|
|
@ -53,6 +53,7 @@ bSkipEditorContent=False
|
|||
+MapsToCook=(FilePath="/Game/Carla/Maps/Town02")
|
||||
+MapsToCook=(FilePath="/Game/Carla/Maps/Town03")
|
||||
+DirectoriesToAlwaysCook=(Path="Carla/Static/GenericMaterials/Licenseplates/Textures")
|
||||
+DirectoriesToAlwaysStageAsUFS=(Path="Carla/Maps/OpenDrive")
|
||||
bNativizeBlueprintAssets=False
|
||||
bNativizeOnlySelectedBlueprints=False
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "Carla/Server/TheNewCarlaServer.h"
|
||||
|
||||
#include "Carla/Sensor/Sensor.h"
|
||||
#include "Carla/Util/OpenDrive.h"
|
||||
#include "Carla/Vehicle/CarlaWheeledVehicle.h"
|
||||
|
||||
#include "GameFramework/SpectatorPawn.h"
|
||||
|
@ -18,6 +19,7 @@
|
|||
#include <carla/rpc/ActorDefinition.h>
|
||||
#include <carla/rpc/ActorDescription.h>
|
||||
#include <carla/rpc/EpisodeInfo.h>
|
||||
#include <carla/rpc/MapInfo.h>
|
||||
#include <carla/rpc/Server.h>
|
||||
#include <carla/rpc/Transform.h>
|
||||
#include <carla/rpc/VehicleControl.h>
|
||||
|
@ -189,6 +191,12 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
return {Episode->GetId(), cr::FromFString(Episode->GetMapName()), WorldObserver->GetStreamToken()};
|
||||
});
|
||||
|
||||
Server.BindSync("get_map_info", [this]() -> cr::MapInfo {
|
||||
RequireEpisode();
|
||||
auto FileContents = FOpenDrive::Load(Episode->GetMapName());
|
||||
return {cr::FromFString(Episode->GetMapName()), cr::FromFString(FileContents)};
|
||||
});
|
||||
|
||||
Server.BindSync("get_actor_definitions", [this]() {
|
||||
RequireEpisode();
|
||||
return MakeVectorFromTArray<cr::ActorDefinition>(Episode->GetActorDefinitions());
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "Carla.h"
|
||||
#include "Carla/Util/OpenDrive.h"
|
||||
|
||||
#include "Engine.h"
|
||||
|
||||
FString FOpenDrive::Load(FString MapName)
|
||||
{
|
||||
#if WITH_EDITOR
|
||||
{
|
||||
// When playing in editor the map name gets an extra prefix, here we
|
||||
// remove it.
|
||||
FString CorrectedMapName = MapName;
|
||||
constexpr auto PIEPrefix = TEXT("UEDPIE_0_");
|
||||
CorrectedMapName.RemoveFromStart(PIEPrefix);
|
||||
UE_LOG(LogCarla, Log, TEXT("Corrected map name from %s to %s"), *MapName, *CorrectedMapName);
|
||||
MapName = CorrectedMapName;
|
||||
}
|
||||
#endif // WITH_EDITOR
|
||||
|
||||
const FString FilePath =
|
||||
FPaths::ProjectContentDir() +
|
||||
TEXT("Carla/Maps/OpenDrive/") +
|
||||
MapName +
|
||||
TEXT(".xodr");
|
||||
|
||||
FString Content;
|
||||
UE_LOG(LogCarla, Log, TEXT("Loading OpenDrive file '%s'"), *FilePath);
|
||||
|
||||
if (!FFileHelper::LoadFileToString(Content, *FilePath))
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("Failed to load OpenDrive file '%s'"), *FilePath);
|
||||
}
|
||||
|
||||
return Content;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
class FOpenDrive
|
||||
{
|
||||
public:
|
||||
|
||||
static FString Load(FString MapName);
|
||||
};
|
|
@ -14,4 +14,4 @@
|
|||
0.8.3: 1z2XKOk9LoKI-EhxcrpI31W5TeYo2-jjn
|
||||
0.8.4: 1mFNS-w5atQ45yegiTepRIeKBYVm8N8He
|
||||
0.9.0: 1FtC00CrDb7Kz5StBAwb6vqOGbzZtpROx
|
||||
Latest: 1cx6YqT9ZlVQ6Dahg_bRCyQB8meGwGgVZ
|
||||
Latest: 1CnlblH9IDYaq30GZrAaDEah-FZ6YoaD_
|
||||
|
|
Loading…
Reference in New Issue