This repository has been archived on 2024-11-16. You can view files and clone it, but cannot push or open issues or pull requests.
MecanumVehicle/Source/MecanumVehicle/MecanumVehicleAdapter.h
2023-10-28 21:33:23 +08:00

60 lines
1.2 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MecanumVehicleAdapter.generated.h"
class FSocket;
class ISocketSubsystem;
UCLASS()
class MECANUMVEHICLE_API AMecanumVehicleAdapter : public AActor
{
GENERATED_BODY()
public:
AMecanumVehicleAdapter(const FObjectInitializer& ObjectInitializer);
UPROPERTY(BlueprintReadOnly)
double PingTime;
UFUNCTION(BlueprintCallable)
void UpdataCompensation(const TArray<double>& Value);
UFUNCTION(BlueprintCallable)
void UpdataSocket(const FString& IP, const int32 Port = 6000);
UFUNCTION(BlueprintCallable)
void UpdataInput(const FVector Value, const bool bIsBrake);
UFUNCTION(BlueprintCallable)
//~ Begin AActor Interface.
virtual void BeginPlay() override;
virtual void Tick(float DeltaSeconds) override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
//~ End AActor Interface.
private:
ISocketSubsystem* SocketSubsystem;
FSocket* UDPSocket;
TSharedPtr<FInternetAddr> Addr;
TArray<uint8> UDPBuffer;
int32 UDPSequenceIndex = 0;
FDateTime UDPLastTime;
FDateTime UDPRecvTime[(int32)MAX_uint8 + 1];
double SpeedCompensationMax[4] = { 1.0, 1.0, 1.0, 1.0 };
double SpeedCompensationMin[4] = { 0.0, 0.0, 0.0, 0.0 };
};