You've already forked LuckyWorld
REFAC - Rename things and remove includes
This commit is contained in:
@ -2,31 +2,19 @@
|
||||
|
||||
|
||||
#include "LuckyDataTransferSubsystem.h"
|
||||
|
||||
#include "AutomationBlueprintFunctionLibrary.h"
|
||||
#include "ImageUtils.h"
|
||||
#include "RenderingThread.h"
|
||||
#include "RenderUtils.h"
|
||||
#include "RenderGraphUtils.h"
|
||||
#include "RHI.h"
|
||||
#include "RHICommandList.h"
|
||||
#include "ImageWriteQueue.h"
|
||||
#include "ImageWriteTask.h"
|
||||
#include "ImagePixelData.h"
|
||||
#include "JsonUtilities.h"
|
||||
#include "JsonObjectConverter.h"
|
||||
#include "ReviewComments.h"
|
||||
#include "WebSocketsModule.h"
|
||||
#include "IWebSocket.h"
|
||||
#include "Kismet/KismetStringLibrary.h"
|
||||
#include "Camera/CameraActor.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Components/SceneCaptureComponent2D.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "Kismet/KismetRenderingLibrary.h"
|
||||
#include "Slate/SceneViewport.h"
|
||||
#include "Virtualization/VirtualizationTypes.h"
|
||||
|
||||
ULuckyDataTransferSubsystem::ULuckyDataTransferSubsystem()
|
||||
{
|
||||
@ -89,16 +77,16 @@ void ULuckyDataTransferSubsystem::Callback_OnConnected()
|
||||
UE_LOG(LogTemp, Warning, TEXT("WebSocket connected successfully"));
|
||||
}
|
||||
|
||||
void ULuckyDataTransferSubsystem::Callback_OnConnectionError(const FString& Error)
|
||||
void ULuckyDataTransferSubsystem::Callback_OnConnectionError(const FString& Error) const
|
||||
{
|
||||
UE_LOG(LogTemp, VeryVerbose, TEXT("Websocket connection error: %s"), *Error)
|
||||
}
|
||||
|
||||
void ULuckyDataTransferSubsystem::Callback_OnMessage(const FString& Message)
|
||||
void ULuckyDataTransferSubsystem::Callback_OnMessage(const FString& Message) const
|
||||
{
|
||||
if (!Message.IsEmpty())
|
||||
{
|
||||
CommandReady(InterpretData(Message));
|
||||
CommandReady(ParseJsonPayload(Message));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -130,9 +118,9 @@ void ULuckyDataTransferSubsystem::SendMessage(const FString& Message)
|
||||
UE_LOG(LogTemp, Warning, TEXT("WebSocket outgoing message failed"));
|
||||
}
|
||||
|
||||
FPayload ULuckyDataTransferSubsystem::InterpretData(const FString& Message)
|
||||
FRemoteControlPayload ULuckyDataTransferSubsystem::ParseJsonPayload(const FString& Message)
|
||||
{
|
||||
FPayload Payload = FPayload();
|
||||
FRemoteControlPayload Payload = FRemoteControlPayload();
|
||||
|
||||
if (!Message.IsEmpty())
|
||||
{
|
||||
@ -143,9 +131,9 @@ FPayload ULuckyDataTransferSubsystem::InterpretData(const FString& Message)
|
||||
{
|
||||
for (auto& Elem : JsonObj->Values)
|
||||
{
|
||||
FCommand Command = FCommand();
|
||||
Command.Key = FString(Elem.Key);
|
||||
Command.Value = Elem.Value->AsNumber();
|
||||
FRemoteControlActuatorCommand Command = FRemoteControlActuatorCommand();
|
||||
Command.ActuatorName = FString(Elem.Key);
|
||||
Command.ActuatorValue = Elem.Value->AsNumber();
|
||||
|
||||
Payload.Commands.Add(Command);
|
||||
}
|
||||
@ -161,7 +149,7 @@ void IncomingMessage(const FString& Message)
|
||||
UE_LOG(LogTemp, Warning, TEXT("Incoming message: %s"), *outMessage);
|
||||
}
|
||||
|
||||
void ULuckyDataTransferSubsystem::CommandReady(const FPayload& Payload)
|
||||
void ULuckyDataTransferSubsystem::CommandReady(const FRemoteControlPayload& Payload) const
|
||||
{
|
||||
if (OnCommandReady.IsBound())
|
||||
{
|
||||
@ -254,6 +242,7 @@ bool ULuckyDataTransferSubsystem::WriteImageToDisk(const double Timestamp, const
|
||||
FReadSurfaceDataFlags()
|
||||
);
|
||||
|
||||
// TODO This logs 1, it doesn't work?
|
||||
UE_LOG(LogTemp, Warning, TEXT("Logged pixels: %d"), OutPixels.Num())
|
||||
|
||||
FImageWriteTask* ImageTask = new FImageWriteTask();
|
||||
@ -264,6 +253,7 @@ bool ULuckyDataTransferSubsystem::WriteImageToDisk(const double Timestamp, const
|
||||
//Path = Path.Left(Path.Len() - 1);
|
||||
}
|
||||
|
||||
// TODO Replace by what?
|
||||
const FString RobotName = TEXT("Robot_Name");
|
||||
|
||||
const FString Filename = FString::Printf(
|
||||
@ -278,7 +268,7 @@ bool ULuckyDataTransferSubsystem::WriteImageToDisk(const double Timestamp, const
|
||||
FMath::Floor<int32>(Timestamp * 1000)
|
||||
);
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("FileName %s"), *Filename);
|
||||
UE_LOG(LogTemp, VeryVerbose, TEXT("FileName %s"), *Filename);
|
||||
|
||||
ImageTask->Format = EImageFormat::PNG;
|
||||
ImageTask->Filename = Filename;
|
||||
@ -290,7 +280,7 @@ bool ULuckyDataTransferSubsystem::WriteImageToDisk(const double Timestamp, const
|
||||
FModuleManager::LoadModuleChecked<IImageWriteQueueModule>("ImageWriteQueue").GetWriteQueue().Enqueue(TUniquePtr<IImageWriteTaskBase>(ImageTask));
|
||||
|
||||
ImageTask->OnCompleted = [](bool bSuccess) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("Image write completed: %s"), bSuccess ? TEXT("Success") : TEXT("Failed"));
|
||||
UE_LOG(LogTemp, VeryVerbose, TEXT("Image write completed: %s"), bSuccess ? TEXT("Success") : TEXT("Failed"));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -13,32 +13,32 @@
|
||||
*
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FCommand
|
||||
struct FRemoteControlActuatorCommand
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Command")
|
||||
FString Key = FString();
|
||||
FString ActuatorName = FString();
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Command")
|
||||
float Value = 0.f;
|
||||
float ActuatorValue = 0.f;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FPayload
|
||||
struct FRemoteControlPayload
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Command")
|
||||
TArray<FCommand> Commands;
|
||||
TArray<FRemoteControlActuatorCommand> Commands;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Command")
|
||||
int32 Index = 0;
|
||||
};
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCommandReady, const FPayload&, Payload);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCommandReady, const FRemoteControlPayload&, Payload);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSocketReady, bool, bSuccessful);
|
||||
|
||||
UCLASS()
|
||||
@ -61,7 +61,8 @@ public:
|
||||
|
||||
void Internal_OpenWebsocket(const FString& URL, const FString& Protocol);
|
||||
|
||||
FPayload InterpretData(const FString& Message);
|
||||
// Parse a JSON Payload received from a websocket connection into a Cpp struct
|
||||
static FRemoteControlPayload ParseJsonPayload(const FString& Message);
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FCommandReady OnCommandReady;
|
||||
@ -74,10 +75,10 @@ public:
|
||||
void Callback_OnConnected();
|
||||
|
||||
UFUNCTION()
|
||||
void Callback_OnConnectionError(const FString& Error);
|
||||
void Callback_OnConnectionError(const FString& Error) const;
|
||||
|
||||
UFUNCTION()
|
||||
void Callback_OnMessage(const FString& Message);
|
||||
void Callback_OnMessage(const FString& Message) const;
|
||||
|
||||
UFUNCTION()
|
||||
void Internal_OnMessageSent(const FString& Message);
|
||||
@ -93,7 +94,7 @@ public:
|
||||
void SendMessage(const FString& Message);
|
||||
|
||||
UFUNCTION()
|
||||
void CommandReady(const FPayload& Payload);
|
||||
void CommandReady(const FRemoteControlPayload& Payload) const;
|
||||
|
||||
//---Observations (Sent to server from Unreal)--------------//
|
||||
//Feature Data declarations
|
||||
|
Reference in New Issue
Block a user