FT - PilotComponent to drive so100

+ Base class for RobotPawn -> might be replaced by an Actor instead?
This commit is contained in:
Jb win
2025-04-30 21:28:42 +07:00
parent 470cac8f6a
commit c6f63317b6
9 changed files with 282 additions and 0 deletions

View File

@ -0,0 +1,46 @@
#pragma once
#include "CoreMinimal.h"
#include "RobotPilotComponent.generated.h"
USTRUCT(BlueprintType)
struct FRobotActuators
{
GENERATED_BODY()
// Do we need a prent struct?
// What will be in common?
};
class ARobotPawn;
UCLASS(Blueprintable)
class LUCKYWORLDV2_API URobotPilotComponent : public UActorComponent
{
GENERATED_BODY()
public:
URobotPilotComponent();
virtual void BeginPlay() override;
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
virtual void InitPilotComponent();
private:
// Only to easy access within the component
TWeakObjectPtr<ARobotPawn> RobotOwner = nullptr;
// ----------------
// ----- ANIM -----
// ----------------
public:
virtual void StartAnimation(const FRobotActuators& NewAnimationTarget);
private:
virtual void AnimateActuators(float SimulationTime); // Bound to the PhysicProxy post-update delegate
float AnimationDuration = 0.f;
float AnimationStartTime = 0.f;
FRobotActuators CurrentRobotActuators; // This will be updated by the post-physic delegate
FRobotActuators AnimStartRobotActuators;
FRobotActuators AnimTargetRobotActuators;
};

View File

@ -0,0 +1,13 @@
#pragma once
#include "CoreMinimal.h"
#include "Robot/PilotComponent/RobotPilotComponent.h"
#include "RobotPilotMultiRotorDrone.generated.h"
UCLASS(Blueprintable)
class LUCKYWORLDV2_API URobotPilotMultiRotorDrone : public URobotPilotComponent
{
GENERATED_BODY()
public:
URobotPilotMultiRotorDrone();
};

View File

@ -0,0 +1,50 @@
#pragma once
#include "CoreMinimal.h"
#include "Robot/PilotComponent/RobotPilotComponent.h"
#include "RobotPilotSO100Component.generated.h"
USTRUCT(BlueprintType)
struct FSo100Actuators : public FRobotActuators
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float Rotation = 0.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float Pitch = 0.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float Elbow = 0.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float WristPitch = 0.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float WristRoll = 0.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float Jaw = 0.f;
};
UCLASS(Blueprintable)
class LUCKYWORLDV2_API URobotPilotSO100Component : public URobotPilotComponent
{
GENERATED_BODY()
public:
URobotPilotSO100Component();
virtual void BeginPlay() override;
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UFUNCTION(BlueprintCallable)
virtual void StartAnimation(const FRobotActuators& NewAnimationTarget) override;
// Here let's write the code trying to match with Constantin class
// After both classes have been designed around specific needs, see what can be migrated in the parent class and update both children
// Tick where it can have targets
// Open Claw (ClawIndex)
// Presets to move certain joints into certain positions -> HardCode
// Move the arm myself JB + Capture LOG
};

View File

@ -0,0 +1,37 @@
#pragma once
#include "CoreMinimal.h"
#include "SharedDef.h"
#include "RobotPawn.generated.h"
class AMujocoVolumeActor;
class URobotPilotComponent;
// Enum of bots
UCLASS(Blueprintable)
class LUCKYWORLDV2_API ARobotPawn : public APawn // Should be an actor?
{
GENERATED_BODY()
public:
ARobotPawn();
virtual void BeginPlay() override;
// TODO Called by GameInstance after robot has been spawned
void InitRobot();
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ERobotsName RobotType = ERobotsName::None; // This value must be set in the pawn
UPROPERTY(EditAnywhere, BlueprintReadWrite) // TODO Remove UPROPERTY once we migrate physics proxy initialization from Pawn
TWeakObjectPtr<AMujocoVolumeActor> PhysicSceneProxy;
// -------------------
// ------ PILOT ------
// -------------------
UPROPERTY(EditAnywhere, BlueprintReadWrite)
URobotPilotComponent* RobotPilotComponent = nullptr;
UFUNCTION(BlueprintCallable)
void InitPilotComponent(); // This should have Robot type as parameter?
};