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,41 @@
#include "Robot/PilotComponent/RobotPilotComponent.h"
#include "Actors/MujocoVolumeActor.h"
#include "Robot/RobotPawn.h"
URobotPilotComponent::URobotPilotComponent()
{
}
void URobotPilotComponent::BeginPlay()
{
Super::BeginPlay();
// Reference owning robot
RobotOwner = Cast<ARobotPawn>(GetOwner());
}
void URobotPilotComponent::TickComponent(float DeltaTime, enum ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
void URobotPilotComponent::InitPilotComponent()
{
if (RobotOwner.IsValid() && RobotOwner->PhysicSceneProxy.IsValid())
{
RobotOwner->PhysicSceneProxy->BindPostPhysicStepDelegate(this, &URobotPilotComponent::AnimateActuators);
}
}
void URobotPilotComponent::StartAnimation(const FRobotActuators& NewAnimationTarget)
{
AnimTargetRobotActuators = NewAnimationTarget;
}
void URobotPilotComponent::AnimateActuators(float SimulationTime)
{
// Override in each dedicated RobotPilotComponent
}

View File

@ -0,0 +1,5 @@
#include "Robot/PilotComponent/RobotPilotMultiRotorDrone.h"
URobotPilotMultiRotorDrone::URobotPilotMultiRotorDrone()
{
}

View File

@ -0,0 +1,22 @@
#include "Robot/PilotComponent/RobotPilotSO100Component.h"
URobotPilotSO100Component::URobotPilotSO100Component()
{
}
void URobotPilotSO100Component::BeginPlay()
{
Super::BeginPlay();
}
void URobotPilotSO100Component::TickComponent(float DeltaTime, enum ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
void URobotPilotSO100Component::StartAnimation(const FRobotActuators& NewAnimationTarget)
{
// Super::StartAnimation(NewAnimationTarget);
}

View File

@ -0,0 +1,68 @@
#include "Robot/RobotPawn.h"
#include "Robot/PilotComponent/RobotPilotMultiRotorDrone.h"
#include "Robot/PilotComponent/RobotPilotSO100Component.h"
ARobotPawn::ARobotPawn()
{
}
void ARobotPawn::BeginPlay()
{
Super::BeginPlay();
InitRobot(); // TODO Maybe move to GameInstance to control when we initialize the robot completely
}
void ARobotPawn::InitRobot()
{
InitPilotComponent();
// Other initialization tasks
}
void ARobotPawn::InitPilotComponent()
{
// Initialize pilot component based on robot type
switch (RobotType)
{
case ERobotsName::None:
break;
case ERobotsName::SO100Robot:
RobotPilotComponent = NewObject<URobotPilotSO100Component>(GetOwner());
break;
case ERobotsName::DJIDrone:
RobotPilotComponent = NewObject<URobotPilotMultiRotorDrone>(GetOwner());
break;
case ERobotsName::Luck_e:
break; // TODO or remove from enum
case ERobotsName::Stretch:
break; // TODO or remove from enum
case ERobotsName::LuckyDrone:
break; // TODO or remove from enum
case ERobotsName::ArmLucky:
break; // TODO or remove from enum
case ERobotsName::UnitreeG1:
break; // TODO or remove from enum
case ERobotsName::StretchRobotV1:
break; // TODO or remove from enum
case ERobotsName::PandaArmRobot:
break; // TODO or remove from enum
case ERobotsName::PuralinkRobot:
break; // TODO or remove from enum
case ERobotsName::UnitreeGo2:
break; // TODO or remove from enum
case ERobotsName::RevoluteRobot:
break; // TODO or remove from enum
case ERobotsName::BostonSpotRobot:
break; // TODO or remove from enum
}
// Register if this Robot has a Pilot Component
if (RobotPilotComponent)
{
RobotPilotComponent->RegisterComponent();
RobotPilotComponent->InitPilotComponent();
}
}