diff --git a/CHANGELOG.md b/CHANGELOG.md index 96d0e88b1..35994951e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ ## Latest Changes * Prevent from segfault on failing SignalReference identification when loading OpenDrive files - * Added vehicle doors to the recorder + * Added vehicle doors to the recorder * Added functions to get actor' components transform + * Added posibility to Digital Twins to work with local files (osm and xodr) + * Enable proper material merging for Building in Digital Twins * Added functions to get actor' bones transforms * Added functions to get actor' bones and components names * Added functions to get actor' sockets transforms diff --git a/LibCarla/source/carla/road/Map.cpp b/LibCarla/source/carla/road/Map.cpp index 70bedbeee..282452c66 100644 --- a/LibCarla/source/carla/road/Map.cpp +++ b/LibCarla/source/carla/road/Map.cpp @@ -1238,7 +1238,11 @@ namespace road { geom::Transform lanetransform = lane->ComputeTransform(s_current); geom::Transform treeTransform(treeposition, lanetransform.rotation); const carla::road::element::RoadInfoSpeed* roadinfo = lane->GetInfo(s_current); - transforms.push_back(std::make_pair(treeTransform,roadinfo->GetType())); + if(roadinfo){ + transforms.push_back(std::make_pair(treeTransform, roadinfo->GetType())); + }else{ + transforms.push_back(std::make_pair(treeTransform, "urban")); + } } s_current += distancebetweentrees; } diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/BP_OpenDriveToMap.uasset b/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/BP_OpenDriveToMap.uasset index b73e2caa5..94bee4e50 100644 Binary files a/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/BP_OpenDriveToMap.uasset and b/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/BP_OpenDriveToMap.uasset differ diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/Blueprints/BP_BuildingGenerator.uasset b/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/Blueprints/BP_BuildingGenerator.uasset index 165501747..0e6e56b65 100644 Binary files a/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/Blueprints/BP_BuildingGenerator.uasset and b/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/Blueprints/BP_BuildingGenerator.uasset differ diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/MapPreview/W_MapPreview.uasset b/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/MapPreview/W_MapPreview.uasset index 3014c4eed..d978ae881 100644 Binary files a/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/MapPreview/W_MapPreview.uasset and b/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/MapPreview/W_MapPreview.uasset differ diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/UW_OnRoadMainWidget.uasset b/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/UW_OnRoadMainWidget.uasset index d1c30094b..3ca4126ad 100644 Binary files a/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/UW_OnRoadMainWidget.uasset and b/Unreal/CarlaUE4/Plugins/CarlaTools/Content/OnroadMapGenerator/UW_OnRoadMainWidget.uasset differ diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/OpenDriveToMap.cpp b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/OpenDriveToMap.cpp index 8ee027793..a3049125b 100644 --- a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/OpenDriveToMap.cpp +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/OpenDriveToMap.cpp @@ -154,16 +154,32 @@ void UOpenDriveToMap::CreateMap() UE_LOG(LogCarlaToolsMapGenerator, Error, TEXT("Map Name Is Empty") ); return; } - if ( !IsValid(FileDownloader) ) + + if( !Url.IsEmpty() ) { + if ( !IsValid(FileDownloader) ) + { + FileDownloader = NewObject(); + } + + FileDownloader->ResultFileName = MapName; + FileDownloader->Url = Url; + + FileDownloader->DownloadDelegate.BindUObject( this, &UOpenDriveToMap::ConvertOSMInOpenDrive ); + FileDownloader->StartDownload(); + } + else if(LocalFilePath.EndsWith(".xodr")) { - FileDownloader = NewObject(); + ImportXODR(); + } + else if(LocalFilePath.EndsWith(".osm")) + { + ImportOSM(); + } + else + { + UE_LOG(LogCarlaToolsMapGenerator, Error, TEXT("URL and Local FilePath are Empty. URL: %s Local FilePath: %s"), *Url, *LocalFilePath ); } - FileDownloader->ResultFileName = MapName; - FileDownloader->Url = Url; - - FileDownloader->DownloadDelegate.BindUObject( this, &UOpenDriveToMap::ConvertOSMInOpenDrive ); - FileDownloader->StartDownload(); } void UOpenDriveToMap::CreateTerrain( const int MeshGridSize, const float MeshGridSectionSize) @@ -490,7 +506,7 @@ void UOpenDriveToMap::GenerateAll(const boost::optional& Param { GenerateRoadMesh(ParamCarlaMap, MinLocation, MaxLocation); GenerateLaneMarks(ParamCarlaMap, MinLocation, MaxLocation); - //GenerateSpawnPoints(ParamCarlaMap); + GenerateSpawnPoints(ParamCarlaMap, MinLocation, MaxLocation); CreateTerrain(12800, 256); GenerateTreePositions(ParamCarlaMap, MinLocation, MaxLocation); GenerationFinished(MinLocation, MaxLocation); @@ -714,10 +730,14 @@ void UOpenDriveToMap::GenerateSpawnPoints( const boost::optionalComputeTransform(Wp); - AVehicleSpawnPoint *Spawner = UEditorLevelLibrary::GetEditorWorld()->SpawnActor(); - Spawner->SetActorRotation(Trans.GetRotation()); - Spawner->SetActorLocation(Trans.GetTranslation() + FVector(0.f, 0.f, SpawnersHeight)); - ActorsToMove.Add(Spawner); + if( Trans.GetLocation().X >= MinLocation.X && Trans.GetLocation().Y >= MinLocation.Y && + Trans.GetLocation().X <= MaxLocation.X && Trans.GetLocation().Y <= MaxLocation.Y) + { + AVehicleSpawnPoint *Spawner = UEditorLevelLibrary::GetEditorWorld()->SpawnActor(); + Spawner->SetActorRotation(Trans.GetRotation()); + Spawner->SetActorLocation(Trans.GetTranslation() + FVector(0.f, 0.f, SpawnersHeight)); + ActorsToMove.Add(Spawner); + } } } @@ -878,6 +898,41 @@ bool UOpenDriveToMap::IsInRoad( return false; } +void UOpenDriveToMap::ImportXODR(){ + IPlatformFile& FileManager = FPlatformFileManager::Get().GetPlatformFile(); + FString MyFileDestination = FPaths::ProjectContentDir() + "CustomMaps/" + MapName + "/OpenDrive/" + MapName + ".xodr"; + + if(FileManager.CopyFile( *MyFileDestination, *LocalFilePath, + EPlatformFileRead::None, + EPlatformFileWrite::None)) + { + UE_LOG(LogCarlaToolsMapGenerator, Verbose, TEXT("FilePaths: File Copied!")); + FilePath = MyFileDestination; + LoadMap(); + } + else + { + UE_LOG(LogCarlaToolsMapGenerator, Error, TEXT("FilePaths local xodr file not copied: File not Copied!")); + } +} + +void UOpenDriveToMap::ImportOSM(){ + IPlatformFile& FileManager = FPlatformFileManager::Get().GetPlatformFile(); + FString MyFileDestination = FPaths::ProjectContentDir() + "CustomMaps/" + MapName + "/OpenDrive/" + MapName + ".osm"; + + if(FileManager.CopyFile( *MyFileDestination, *LocalFilePath, + EPlatformFileRead::None, + EPlatformFileWrite::None)) + { + UE_LOG(LogCarlaToolsMapGenerator, Verbose, TEXT("FilePaths: File Copied!")); + ConvertOSMInOpenDrive(); + } + else + { + UE_LOG(LogCarlaToolsMapGenerator, Error, TEXT("FilePaths local osm file not copied: File not Copied!")); + } +} + void UOpenDriveToMap::MoveActorsToSubLevels(TArray ActorsToMove) { AActor* QueryActor = UGameplayStatics::GetActorOfClass( diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/OpenDriveToMap.h b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/OpenDriveToMap.h index 2002c8275..115b456bb 100644 --- a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/OpenDriveToMap.h +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/OpenDriveToMap.h @@ -91,6 +91,9 @@ public: UPROPERTY( EditAnywhere, BlueprintReadWrite, Category="Settings" ) FString Url; + UPROPERTY( EditAnywhere, BlueprintReadWrite, Category="Settings" ) + FString LocalFilePath; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings") FVector2D OriginGeoCoordinates; @@ -213,6 +216,9 @@ private: void InitTextureData(); + void ImportXODR(); + void ImportOSM(); + UPROPERTY() UCustomFileDownloader* FileDownloader; UPROPERTY()