Aaron/digital twins add local file (#7167)

* Added timers to setup.sh for downloading and unzipping

* Adding support for local XODRs

* Added allowtorendering to generate tile commandlet and make sure it works with local files

* Update Changelog

* Updated OpenDrive To Map
This commit is contained in:
Blyron 2024-02-20 15:01:30 +01:00 committed by GitHub
parent 8430a5c33b
commit c0abf59983
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 81 additions and 14 deletions

View File

@ -1,7 +1,9 @@
## Latest Changes ## Latest Changes
* Prevent from segfault on failing SignalReference identification when loading OpenDrive files * 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 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 transforms
* Added functions to get actor' bones and components names * Added functions to get actor' bones and components names
* Added functions to get actor' sockets transforms * Added functions to get actor' sockets transforms

View File

@ -1238,7 +1238,11 @@ namespace road {
geom::Transform lanetransform = lane->ComputeTransform(s_current); geom::Transform lanetransform = lane->ComputeTransform(s_current);
geom::Transform treeTransform(treeposition, lanetransform.rotation); geom::Transform treeTransform(treeposition, lanetransform.rotation);
const carla::road::element::RoadInfoSpeed* roadinfo = lane->GetInfo<carla::road::element::RoadInfoSpeed>(s_current); const carla::road::element::RoadInfoSpeed* roadinfo = lane->GetInfo<carla::road::element::RoadInfoSpeed>(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; s_current += distancebetweentrees;
} }

View File

@ -154,16 +154,32 @@ void UOpenDriveToMap::CreateMap()
UE_LOG(LogCarlaToolsMapGenerator, Error, TEXT("Map Name Is Empty") ); UE_LOG(LogCarlaToolsMapGenerator, Error, TEXT("Map Name Is Empty") );
return; return;
} }
if ( !IsValid(FileDownloader) )
if( !Url.IsEmpty() ) {
if ( !IsValid(FileDownloader) )
{
FileDownloader = NewObject<UCustomFileDownloader>();
}
FileDownloader->ResultFileName = MapName;
FileDownloader->Url = Url;
FileDownloader->DownloadDelegate.BindUObject( this, &UOpenDriveToMap::ConvertOSMInOpenDrive );
FileDownloader->StartDownload();
}
else if(LocalFilePath.EndsWith(".xodr"))
{ {
FileDownloader = NewObject<UCustomFileDownloader>(); 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) void UOpenDriveToMap::CreateTerrain( const int MeshGridSize, const float MeshGridSectionSize)
@ -490,7 +506,7 @@ void UOpenDriveToMap::GenerateAll(const boost::optional<carla::road::Map>& Param
{ {
GenerateRoadMesh(ParamCarlaMap, MinLocation, MaxLocation); GenerateRoadMesh(ParamCarlaMap, MinLocation, MaxLocation);
GenerateLaneMarks(ParamCarlaMap, MinLocation, MaxLocation); GenerateLaneMarks(ParamCarlaMap, MinLocation, MaxLocation);
//GenerateSpawnPoints(ParamCarlaMap); GenerateSpawnPoints(ParamCarlaMap, MinLocation, MaxLocation);
CreateTerrain(12800, 256); CreateTerrain(12800, 256);
GenerateTreePositions(ParamCarlaMap, MinLocation, MaxLocation); GenerateTreePositions(ParamCarlaMap, MinLocation, MaxLocation);
GenerationFinished(MinLocation, MaxLocation); GenerationFinished(MinLocation, MaxLocation);
@ -714,10 +730,14 @@ void UOpenDriveToMap::GenerateSpawnPoints( const boost::optional<carla::road::Ma
for (const auto &Wp : Waypoints) for (const auto &Wp : Waypoints)
{ {
const FTransform Trans = ParamCarlaMap->ComputeTransform(Wp); const FTransform Trans = ParamCarlaMap->ComputeTransform(Wp);
AVehicleSpawnPoint *Spawner = UEditorLevelLibrary::GetEditorWorld()->SpawnActor<AVehicleSpawnPoint>(); if( Trans.GetLocation().X >= MinLocation.X && Trans.GetLocation().Y >= MinLocation.Y &&
Spawner->SetActorRotation(Trans.GetRotation()); Trans.GetLocation().X <= MaxLocation.X && Trans.GetLocation().Y <= MaxLocation.Y)
Spawner->SetActorLocation(Trans.GetTranslation() + FVector(0.f, 0.f, SpawnersHeight)); {
ActorsToMove.Add(Spawner); AVehicleSpawnPoint *Spawner = UEditorLevelLibrary::GetEditorWorld()->SpawnActor<AVehicleSpawnPoint>();
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; 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<AActor*> ActorsToMove) void UOpenDriveToMap::MoveActorsToSubLevels(TArray<AActor*> ActorsToMove)
{ {
AActor* QueryActor = UGameplayStatics::GetActorOfClass( AActor* QueryActor = UGameplayStatics::GetActorOfClass(

View File

@ -91,6 +91,9 @@ public:
UPROPERTY( EditAnywhere, BlueprintReadWrite, Category="Settings" ) UPROPERTY( EditAnywhere, BlueprintReadWrite, Category="Settings" )
FString Url; FString Url;
UPROPERTY( EditAnywhere, BlueprintReadWrite, Category="Settings" )
FString LocalFilePath;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
FVector2D OriginGeoCoordinates; FVector2D OriginGeoCoordinates;
@ -213,6 +216,9 @@ private:
void InitTextureData(); void InitTextureData();
void ImportXODR();
void ImportOSM();
UPROPERTY() UPROPERTY()
UCustomFileDownloader* FileDownloader; UCustomFileDownloader* FileDownloader;
UPROPERTY() UPROPERTY()