You've already forked LuckyWorld
UNSTBL - Refacto
+ Exit CaptureImage faster in case of problem + Register cameras manually in Episode SubSystem + Make FilePath optional to keep the correct default value in saved games - Image capture doesn't work, image is empty
This commit is contained in:
@ -184,6 +184,21 @@ void UEpisodeSubSystem::FindRobotPawnFromScene()
|
||||
}
|
||||
}
|
||||
|
||||
void UEpisodeSubSystem::InitCameras()
|
||||
{
|
||||
// TODO Fix the spawning of sensors in Cpp and spawn them using a config?
|
||||
// TODO How people can move the camera themselves?
|
||||
|
||||
// Find all sensors in the scene
|
||||
TArray<AActor*> Sensors;
|
||||
UGameplayStatics::GetAllActorsOfClass(this->GetWorld(), ALuckySensorPawnBase::StaticClass(), Sensors);
|
||||
|
||||
for (const auto Sensor : Sensors)
|
||||
{
|
||||
if (const auto Camera = Cast<ALuckySensorPawnBase>(Sensor)) Cameras.Add(Camera);
|
||||
}
|
||||
}
|
||||
|
||||
void UEpisodeSubSystem::ConfigureDataCapture()
|
||||
{
|
||||
if (ULuckyDataTransferSubsystem* DataTransfer = GetWorld()->GetSubsystem<ULuckyDataTransferSubsystem>())
|
||||
@ -192,6 +207,13 @@ void UEpisodeSubSystem::ConfigureDataCapture()
|
||||
//Connect to websocket and create session id
|
||||
DataTransfer->ConnectToWebsocket("ws://127.0.0.1:3000", "");
|
||||
DataTransfer->CreateCaptureSessionID();
|
||||
|
||||
InitCameras();
|
||||
for (const auto& Cam : Cameras)
|
||||
{
|
||||
DataTransfer->RegisterSensor(Cam.Get());
|
||||
Cam->SensorInfo.bActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,17 +233,23 @@ FObservationPayload UEpisodeSubSystem::CreatePayload()
|
||||
// enter a message here - FString,
|
||||
// TMap of FString (Actuator name or index), and Float (value of actuator)
|
||||
// Camera info struct goes here, don't worry about this for now, just use TArray<FObservationCameraObject>()
|
||||
// What about episode success?
|
||||
// What about episode success? -> can be stated after the result is known
|
||||
// How to invalidate data
|
||||
|
||||
// Anuj -> How many frames do we need to store in a single parquet chunk
|
||||
// Exact data structure with correct data types
|
||||
};
|
||||
}
|
||||
|
||||
void UEpisodeSubSystem::SendEpisodeData(const FObservationPayload& Payload) const
|
||||
{
|
||||
// PayloadBuffer.Add(Payload)
|
||||
// Every X frames -> Write parquet chunk
|
||||
|
||||
if (ULuckyDataTransferSubsystem* DataTransfer = GetWorld()->GetSubsystem<ULuckyDataTransferSubsystem>())
|
||||
{
|
||||
// Here generate the path for each image?
|
||||
// DataTransfer->WriteImageToDisk(BaseImageDataPath, 0.f);
|
||||
DataTransfer->WriteImageToDisk(CurrentRobot->PhysicsSceneProxy->GetMujocoData().time);
|
||||
|
||||
// Don't send data if socket is disconnected
|
||||
if (!DataTransfer->Socket->IsConnected()) return;
|
||||
|
@ -54,11 +54,6 @@ FTransform URobotPilotSO100Component::GetReachableTransform()
|
||||
RewardAxis.Z = 0; // Nullify Z to keep a 2D vector -> ensure the geometry roll/pitch are 0
|
||||
const FRotator TowardPivotRotation = UKismetMathLibrary::MakeRotFromXZ(RewardAxis, FVector::UpVector);
|
||||
|
||||
// Debug
|
||||
// DrawDebugLine(this->GetWorld(), ArmPivotLocation + ArmWorldRotation.GetForwardVector() * 70, ArmPivotLocation, FColor::Green, true);
|
||||
// DrawDebugLine(this->GetWorld(), ArmPivotLocation + FVector::UpVector * 70, ArmPivotLocation, FColor::Red, true);
|
||||
// DrawDebugLine(this->GetWorld(), RandomLocation, RandomLocation + TowardPivotRotation.Quaternion().GetForwardVector() * -50 , FColor::Blue, true);
|
||||
|
||||
// Return the Object Transform
|
||||
return FTransform(TowardPivotRotation, RandomLocation);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ void ARobotPawn::BeginPlay()
|
||||
void ARobotPawn::InitRobot()
|
||||
{
|
||||
InitPilotComponent();
|
||||
InitCamera();
|
||||
}
|
||||
|
||||
void ARobotPawn::InitPilotComponent()
|
||||
@ -70,17 +69,3 @@ void ARobotPawn::InitPilotComponent()
|
||||
}
|
||||
}
|
||||
|
||||
void ARobotPawn::InitCamera()
|
||||
{
|
||||
// TODO Fix the spawning of sensors in Cpp and spawn them using a config?
|
||||
// TODO How people can move the camera themselves?
|
||||
|
||||
// Find all sensors in the scene
|
||||
TArray<AActor*> Sensors;
|
||||
UGameplayStatics::GetAllActorsOfClass(this->GetWorld(), ALuckySensorPawnBase::StaticClass(), Sensors);
|
||||
|
||||
for (const auto Sensor : Sensors)
|
||||
{
|
||||
if (const auto Camera = Cast<ALuckySensorPawnBase>(Sensor)) Cameras.Add(Camera);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "EpisodeSubSystem.generated.h"
|
||||
|
||||
|
||||
class ALuckySensorPawnBase;
|
||||
class ATextRenderActor;
|
||||
class AMujocoStaticMeshActor;
|
||||
class ARobotPawn;
|
||||
@ -85,6 +86,11 @@ private:
|
||||
UPROPERTY()
|
||||
TObjectPtr<ARobotPawn> CurrentRobot;
|
||||
|
||||
// ---------------------
|
||||
// ------ SENSORS ------
|
||||
// ---------------------
|
||||
void InitCameras();
|
||||
TArray<TObjectPtr<ALuckySensorPawnBase>> Cameras;
|
||||
|
||||
|
||||
|
||||
|
@ -40,11 +40,4 @@ public:
|
||||
URobotPilotComponent* RobotPilotComponent = nullptr;
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void InitPilotComponent(); // This should have Robot type as parameter?
|
||||
|
||||
// ---------------------
|
||||
// ------ SENSORS ------
|
||||
// ---------------------
|
||||
void InitCamera();
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TArray<TObjectPtr<ALuckySensorPawnBase>> Cameras;
|
||||
};
|
||||
|
Reference in New Issue
Block a user