From 878e8123da15e33973b64b1c59b1bb0d491c4b3b Mon Sep 17 00:00:00 2001 From: bernatx Date: Wed, 5 Feb 2020 10:48:11 +0100 Subject: [PATCH] Fix Road tag and add some sidewalk to semantic segmentation --- .../Carla/Commandlet/MoveAssetsCommandlet.cpp | 24 +++++++++++++++++-- .../PrepareAssetsForCookingCommandlet.cpp | 16 +++++++++---- .../PrepareAssetsForCookingCommandlet.h | 4 ++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/MoveAssetsCommandlet.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/MoveAssetsCommandlet.cpp index 55ccfef77..da223c5e5 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/MoveAssetsCommandlet.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/MoveAssetsCommandlet.cpp @@ -21,9 +21,13 @@ UMoveAssetsCommandlet::UMoveAssetsCommandlet() // and for specifying the path to these meshes when spawning them in a world. namespace SSTags { // Carla Semantic Segmentation Folder Tags - static const FString ROAD = TEXT("Roads"); + static const FString ROAD = TEXT("Road"); static const FString ROADLINES = TEXT("RoadLines"); static const FString TERRAIN = TEXT("Terrain"); + static const FString GRASS = TEXT("Terrain"); + static const FString SIDEWALK = TEXT("SideWalk"); + static const FString CURB = TEXT("SideWalk"); + static const FString GUTTER = TEXT("SideWalk"); // RoadRunner Tags // @@ -34,7 +38,11 @@ namespace SSTags { // meshSubType is a denomination of the tag (e.g. "Road", "Gutter", "Ground") static const FString R_ROAD = TEXT("Road_Road"); static const FString R_TERRAIN = TEXT("Terrain"); + static const FString R_GRASS = TEXT("Road_Grass"); static const FString R_MARKING = TEXT("Road_Marking"); + static const FString R_SIDEWALK = TEXT("Road_Sidewalk"); + static const FString R_CURB = TEXT("Road_Curb"); + static const FString R_GUTTER = TEXT("Road_Gutter"); } FMovePackageParams UMoveAssetsCommandlet::ParseParams(const FString &InParams) const @@ -112,7 +120,7 @@ void UMoveAssetsCommandlet::MoveAssetsFromMapForSemanticSegmentation( AssetsObjectLibrary->GetAssetDataList(MapContents); AssetsObjectLibrary->ClearLoaded(); - TArray DestinationPaths = {SSTags::ROAD, SSTags::ROADLINES, SSTags::TERRAIN}; + TArray DestinationPaths = {SSTags::ROAD, SSTags::ROADLINES, SSTags::TERRAIN, SSTags::GRASS, SSTags::SIDEWALK, SSTags::CURB, SSTags::GUTTER}; // Init Map with keys TMap> AssetDataMap; @@ -154,6 +162,18 @@ void UMoveAssetsCommandlet::MoveAssetsFromMapForSemanticSegmentation( { AssetDataMap[SSTags::TERRAIN].Add(MeshAsset); } + else if (AssetName.Contains(SSTags::R_SIDEWALK)) + { + AssetDataMap[SSTags::SIDEWALK].Add(MeshAsset); + } + else if (AssetName.Contains(SSTags::R_CURB)) + { + AssetDataMap[SSTags::CURB].Add(MeshAsset); + } + else if (AssetName.Contains(SSTags::R_GUTTER)) + { + AssetDataMap[SSTags::GUTTER].Add(MeshAsset); + } } } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/PrepareAssetsForCookingCommandlet.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/PrepareAssetsForCookingCommandlet.cpp index 3c446b48e..921b653bb 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/PrepareAssetsForCookingCommandlet.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/PrepareAssetsForCookingCommandlet.cpp @@ -24,17 +24,20 @@ UPrepareAssetsForCookingCommandlet::UPrepareAssetsForCookingCommandlet() // Get Carla Default materials, these will be used for maps that need to use // Carla materials static ConstructorHelpers::FObjectFinder MarkingNode(TEXT( - "Material'/Game/Carla/Static/GenericMaterials/LaneMarking/M_MarkingLane_W.M_MarkingLane_W'")); + "Material'/Game/Carla/Static/GenericMaterials/LaneMarking/M_MarkingLane_Y.M_MarkingLane_Y'")); static ConstructorHelpers::FObjectFinder RoadNode(TEXT( "Material'/Game/Carla/Static/GenericMaterials/Masters/LowComplexity/M_Road1.M_Road1'")); static ConstructorHelpers::FObjectFinder RoadNodeAux(TEXT( - "Material'/Game/Carla/Static/GenericMaterials/LaneMarking/M_MarkingLane_Y.M_MarkingLane_Y'")); + "Material'/Game/Carla/Static/GenericMaterials/LaneMarking/M_MarkingLane_W.M_MarkingLane_W'")); static ConstructorHelpers::FObjectFinder TerrainNodeMaterial(TEXT( "Material'/Game/Carla/Static/GenericMaterials/Grass/M_Grass01.M_Grass01'")); + static ConstructorHelpers::FObjectFinder SidewalkNode(TEXT( + "Material'/Game/Carla/Static/GenericMaterials/CheapMaterials/M_SideWalkCheap01'")); MarkingNodeMaterial = (UMaterial *) MarkingNode.Object; RoadNodeMaterial = (UMaterial *) RoadNode.Object; MarkingNodeMaterialAux = (UMaterial *) RoadNodeAux.Object; + SidewalkNodeMaterial = (UMaterial *) SidewalkNode.Object; #endif } #if WITH_EDITORONLY_DATA @@ -126,7 +129,7 @@ TArray UPrepareAssetsForCookingCommandlet::SpawnMeshesToWorl MeshAsset->MarkPackageDirty(); } - // rotate all meshes 180 degrees to fit with OpenDRIVE info + // rotate all meshes 180 degrees to fit with OpenDRIVE info // (seems that new version of RoadRunner is doing this) // MeshActor->SetActorRotation(FRotator(0.0f, 180.0f, 0.0f)); @@ -149,6 +152,10 @@ TArray UPrepareAssetsForCookingCommandlet::SpawnMeshesToWorl { MeshActor->GetStaticMeshComponent()->SetMaterial(0, TerrainNodeMaterial); } + else if (AssetName.Contains(SSTags::R_SIDEWALK)) + { + MeshActor->GetStaticMeshComponent()->SetMaterial(0, SidewalkNodeMaterial); + } } } } @@ -374,9 +381,10 @@ void UPrepareAssetsForCookingCommandlet::PrepareMapsForCooking( FString RoadsPath = BasePath + SSTags::ROAD + MapPath; FString RoadLinesPath = BasePath + SSTags::ROADLINES + MapPath; FString TerrainPath = BasePath + SSTags::TERRAIN + MapPath; + FString SidewalkPath = BasePath + SSTags::SIDEWALK + MapPath; // Spawn assets located in semantic segmentation fodlers - TArray DataPath = {DefaultPath, RoadsPath, RoadLinesPath, TerrainPath}; + TArray DataPath = {DefaultPath, RoadsPath, RoadLinesPath, TerrainPath, SidewalkPath}; TArray SpawnedActors = SpawnMeshesToWorld(DataPath, Map.bUseCarlaMapMaterials); diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/PrepareAssetsForCookingCommandlet.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/PrepareAssetsForCookingCommandlet.h index 47de8a98e..8158ef29b 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/PrepareAssetsForCookingCommandlet.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/PrepareAssetsForCookingCommandlet.h @@ -160,6 +160,10 @@ private: UPROPERTY() UMaterial *TerrainNodeMaterial; + /// Workaround material for the SidewalkNodes + UPROPERTY() + UMaterial *SidewalkNodeMaterial; + /// Saves @a Package in .umap format in path @a PackagePath inside Unreal /// Content folder bool SavePackage(const FString &PackagePath, UPackage *Package) const;