14 #include "GameFramework/CharacterMovementComponent.h" 41 TSharedPtr<const FActorInfo> Info,
45 Info(
std::move(Info)),
54 TSharedPtr<const FActorInfo>
Info,
65 TSharedPtr<const FActorInfo>
Info,
71 ActorData = MakeShared<FActorSensorData>();
76 TSharedPtr<const FActorInfo>
Info,
82 ActorData = MakeShared<FTrafficSignData>();
87 TSharedPtr<const FActorInfo>
Info,
93 ActorData = MakeShared<FTrafficLightData>();
98 TSharedPtr<const FActorInfo>
Info,
101 :
FCarlaActor(ActorId, Actor, Info, InState, World)
109 TSharedPtr<const FActorInfo>
Info,
112 :
FCarlaActor(ActorId, Actor, Info, InState, World)
121 TSharedPtr<const FActorInfo>
Info,
129 return MakeShared<FTrafficSignActor>(
ActorId,
Actor, std::move(Info), InState,
World);
132 return MakeShared<FTrafficLightActor>(
ActorId,
Actor, std::move(Info), InState,
World);
135 return MakeShared<FVehicleActor>(
ActorId,
Actor, std::move(Info), InState,
World);
138 return MakeShared<FWalkerActor>(
ActorId,
Actor, std::move(Info), InState,
World);
141 return MakeShared<FSensorActor>(
ActorId,
Actor, std::move(Info), InState,
World);
156 ActorData->RecordActorData(
this, CarlaEpisode);
167 UE_LOG(LogCarla, Error, TEXT(
"Could not wake up dormant actor %d at location %s"),
GetActorId(), *(
ActorData->GetLocalTransform(CarlaEpisode).GetLocation().ToString()));
171 ActorData->RestoreActorData(
this, CarlaEpisode);
186 Transform = LargeMap->GlobalToLocalTransform(Transform);
192 return GetActor()->GetActorTransform();
233 return GetActor()->GetActorLocation();
271 GetActor()->SetActorRelativeLocation(
280 const FVector&
Location, ETeleportType TeleportType)
295 GetActor()->SetActorRelativeLocation(
304 const FTransform&
Transform, ETeleportType TeleportType)
317 ActorData->Rotation = GlobalTransform.GetRotation();
318 ActorData->Scale = GlobalTransform.GetScale3D();
322 GetActor()->SetActorRelativeTransform(
331 const FTransform&
Transform, ETeleportType TeleportType)
336 ActorData->Rotation = Transform.GetRotation();
337 ActorData->Scale = Transform.GetScale3D();
349 GetActor()->SetActorRelativeTransform(
378 Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
381 return Primitive->GetPhysicsAngularVelocityInDegrees();
395 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
396 if (RootComponent ==
nullptr)
400 RootComponent->SetPhysicsLinearVelocity(
412 ActorData->AngularVelocity = AngularVelocity;
417 if (RootComponent ==
nullptr)
421 RootComponent->SetPhysicsAngularVelocityInDegrees(
436 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
437 if (RootComponent ==
nullptr)
441 RootComponent->AddImpulse(
450 const FVector& Impulse,
const FVector&
Location)
457 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
458 if (RootComponent ==
nullptr)
463 UE_LOG(LogCarla, Warning, TEXT(
"AddImpulseAtLocation: Experimental feature, use carefully."));
465 RootComponent->AddImpulseAtLocation(
480 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
481 if (RootComponent ==
nullptr)
485 RootComponent->AddForce(
494 const FVector& Force,
const FVector&
Location)
501 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
502 if (RootComponent ==
nullptr)
507 UE_LOG(LogCarla, Warning, TEXT(
"AddForceAtLocation: Experimental feature, use carefully."));
509 RootComponent->AddForceAtLocation(
524 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
525 if (RootComponent ==
nullptr)
529 RootComponent->AddAngularImpulseInDegrees(
544 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
545 if (RootComponent ==
nullptr)
549 RootComponent->AddTorqueInDegrees(
567 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
568 if (RootComponent ==
nullptr)
573 RootComponent->SetSimulatePhysics(bEnabled);
574 RootComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
586 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
587 if (RootComponent ==
nullptr)
591 RootComponent->SetEnableGravity(bEnabled);
605 auto CarlaVehicle = Cast<ACarlaWheeledVehicle>(
GetActor());
606 if (CarlaVehicle ==
nullptr)
610 CarlaVehicle->ActivateVelocityControl(Velocity);
622 auto CarlaVehicle = Cast<ACarlaWheeledVehicle>(
GetActor());
623 if (CarlaVehicle ==
nullptr)
627 CarlaVehicle->DeactivateVelocityControl();
646 PhysicsControl =
Vehicle->GetVehiclePhysicsControl();
666 LightState =
Vehicle->GetVehicleLightState();
715 Vehicle->ApplyVehiclePhysicsControl(PhysicsControl);
736 Vehicle->SetVehicleLightState(LightState);
753 Vehicle->SetWheelSteerDirection(WheelLocation, AngleInDeg);
772 Angle =
Vehicle->GetWheelSteerAngle(WheelLocation);
785 auto* CarlaVehicle = Cast<ACarlaWheeledVehicle>(
GetActor());
787 if (CarlaVehicle ==
nullptr){
790 CarlaVehicle->SetSimulatePhysics(bEnabled);
810 Vehicle->ApplyVehicleControl(Control, Priority);
820 VehicleControl = ActorData->
Control;
829 VehicleControl =
Vehicle->GetVehicleControl();
846 auto Controller = Cast<AWheeledVehicleAIController>(
Vehicle->GetController());
847 if (Controller ==
nullptr)
851 Controller->SetAutopilot(bEnabled, bKeepState);
868 Vehicle->ShowDebugTelemetry(bEnabled);
916 uint64_t MaxSubsteps,
float MaxSubstepDeltaTime,
917 const FString& VehicleJSON,
const FString& PowertrainJSON,
918 const FString& TireJSON,
const FString& BaseJSONPath)
979 return ETrafficLightState::Off;
999 return TrafficLight->GetTrafficLightComponent()->GetController();
1088 TrafficLight->GetTrafficLightComponent()->GetGroup()->ResetGroup();
1099 FVector NewLocation = Transform.GetLocation();
1101 NewLocation.Z += 90.0f;
1105 if (NewLocation.Z - CurrentLocation.Z < 100.0f)
1106 NewLocation.Z = CurrentLocation.Z;
1109 NewTransform.SetLocation(NewLocation);
1113 FWalkerData* WalkerData = GetActorData<FWalkerData>();
1118 auto * Walker = Cast<AWalkerBase>(
GetActor());
1119 if (Walker && !Walker->bAlive)
1125 auto Pawn = Cast<APawn>(
GetActor());
1126 if (Pawn ==
nullptr)
1130 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1131 if (Controller ==
nullptr)
1135 Controller->ApplyWalkerControl(WalkerControl);
1146 FWalkerData* WalkerData = GetActorData<FWalkerData>();
1151 auto * Walker = Cast<AWalkerBase>(
GetActor());
1152 if (Walker && !Walker->bAlive)
1158 auto Pawn = Cast<APawn>(
GetActor());
1159 if (Pawn ==
nullptr)
1163 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1164 if (Controller ==
nullptr)
1168 Control = Controller->GetWalkerControl();
1188 auto CharacterMovement = Cast<UCharacterMovementComponent>(
Character->GetCharacterMovement());
1190 CharacterMovement->SetDefaultMovementMode();
1193 CharacterMovement->DisableMovement();
1213 auto CharacterMovement = Cast<UCharacterMovementComponent>(
Character->GetCharacterMovement());
1216 CharacterMovement->SetDefaultMovementMode();
1219 if (CharacterMovement->IsFlying() || CharacterMovement->IsFalling())
1220 CharacterMovement->DisableMovement();
1236 auto Pawn = Cast<APawn>(
GetActor());
1237 if (Pawn ==
nullptr)
1241 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1242 if (Controller ==
nullptr)
1246 Controller->ApplyWalkerControl(Control);
1258 auto Pawn = Cast<APawn>(
GetActor());
1259 if (Pawn ==
nullptr)
1263 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1264 if (Controller ==
nullptr)
1268 Controller->GetBonesTransform(Bones);
1280 auto Pawn = Cast<APawn>(
GetActor());
1281 if (Pawn ==
nullptr)
1285 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1286 if (Controller ==
nullptr)
1290 Controller->SetBonesTransform(Bones);
1302 auto Pawn = Cast<APawn>(
GetActor());
1303 if (Pawn ==
nullptr)
1307 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1308 if (Controller ==
nullptr)
1312 Controller->BlendPose(Blend);
1324 auto Pawn = Cast<APawn>(
GetActor());
1325 if (Pawn ==
nullptr)
1329 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1330 if (Controller ==
nullptr)
1334 Controller->GetPoseFromAnimation();
carla::rpc::ActorState State
virtual ECarlaServerResponse GetPoseFromAnimation()
virtual ECarlaServerResponse GetWheelSteerAngle(const EVehicleWheelLocation &WheelLocation, float &Angle)
virtual ECarlaServerResponse OpenVehicleDoor(const EVehicleDoor DoorIdx) final
FTrafficSignActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bSimulatePhysics) final
void WakeActorUp(UCarlaEpisode *CarlaEpisode)
virtual ECarlaServerResponse ShowVehicleDebugTelemetry(bool bEnabled) final
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &) final
FVector GetActorAngularVelocity() const
void PutActorToSleep(UCarlaEpisode *CarlaEpisode)
virtual ECarlaServerResponse EnableActorConstantVelocity(const FVector &Velocity) final
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl &) final
virtual ECarlaServerResponse SetActorEnableGravity(bool bEnabled)
FVector GlobalToLocalLocation(const FVector &InLocation) const
carla::rpc::WalkerControl WalkerControl
virtual ECarlaServerResponse SetTrafficLightState(const ETrafficLightState &State) final
virtual ECarlaServerResponse SetLightRedTime(float time) final
virtual ECarlaServerResponse SetLightGreenTime(float time) final
FSensorActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
static void CreateCarsimComponent(ACarlaWheeledVehicle *Vehicle, FString Simfile)
FOtherActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
virtual ECarlaServerResponse ApplyPhysicsControl(const FVehiclePhysicsControl &PhysicsControl) final
virtual ECarlaServerResponse ApplyControlToVehicle(const FVehicleControl &, const EVehicleInputPriority &) final
virtual ECarlaServerResponse EnableCarSim(const FString &SimfilePath) final
virtual ECarlaServerResponse SetLightYellowTime(float time) final
virtual ECarlaServerResponse GetVehicleLightState(FVehicleLightState &LightState) final
virtual ECarlaServerResponse FreezeTrafficLight(bool bFreeze) final
virtual ECarlaServerResponse BlendPose(float Blend)
void SetActorGlobalLocation(const FVector &Location, ETeleportType Teleport=ETeleportType::TeleportPhysics)
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bSimulatePhysics) final
virtual ETrafficLightState GetTrafficLightState() const final
ECarlaServerResponse AddActorImpulse(const FVector &Impulse)
ECarlaServerResponse SetActorTargetAngularVelocity(const FVector &AngularVelocity)
ECarlaServerResponse AddActorForceAtLocation(const FVector &Force, const FVector &Location)
ECarlaServerResponse AddActorTorque(const FVector &Torque)
FVehiclePhysicsControl PhysicsControl
carla::SharedPtr< cc::Actor > Actor
FWalkerActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
TSharedPtr< const FActorInfo > Info
void SetActorLocalLocation(const FVector &Location, ETeleportType Teleport=ETeleportType::TeleportPhysics)
virtual ECarlaServerResponse SetWheelSteerDirection(const EVehicleWheelLocation &WheelLocation, float AngleInDeg) final
virtual ECarlaServerResponse SetActorAutopilot(bool bEnabled, bool bKeepState=false) final
FTransform GetActorLocalTransform() const
virtual ECarlaServerResponse SetActorEnableGravity(bool bEnabled) final
FVector GetActorVelocity() const
virtual ECarlaServerResponse ApplyControlToWalker(const FWalkerControl &) final
virtual ECarlaServerResponse ResetTrafficLightGroup() final
static void CreateChronoMovementComponent(ACarlaWheeledVehicle *Vehicle, uint64_t MaxSubsteps, float MaxSubstepDeltaTime, FString VehicleJSON="", FString PowertrainJSON="", FString TireJSON="", FString BaseJSONPath="")
void UseCarSimRoad(bool bEnabled)
ETrafficLightState LightState
ECarlaServerResponse SetActorTargetVelocity(const FVector &Velocity)
virtual ECarlaServerResponse EnableChronoPhysics(uint64_t MaxSubsteps, float MaxSubstepDeltaTime, const FString &VehicleJSON, const FString &PowertrainJSON, const FString &TireJSON, const FString &BaseJSONPath) final
FTransform LocalToGlobalTransform(const FTransform &InTransform) const
virtual ECarlaServerResponse SetWalkerState(const FTransform &Transform, carla::rpc::WalkerControl WalkerControl) final
FTransform GlobalToLocalTransform(const FTransform &InTransform) const
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
ECarlaServerResponse AddActorImpulseAtLocation(const FVector &Impulse, const FVector &Location)
void SetActorLocalTransform(const FTransform &Transform, ETeleportType Teleport=ETeleportType::TeleportPhysics)
FVehicleActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
FTransform GetActorGlobalTransform() const
virtual ECarlaServerResponse CloseVehicleDoor(const EVehicleDoor DoorIdx) final
virtual ECarlaServerResponse SetBonesTransform(const FWalkerBoneControlIn &) final
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bEnabled)
virtual ECarlaServerResponse GetBonesTransform(FWalkerBoneControlOut &) final
IdType GetActorId() const
EVehicleDoor
Type of door to open/close.
ECarlaServerResponse AddActorForce(const FVector &Force)
virtual UTrafficLightController * GetTrafficLightController() final
FVector GetActorLocalLocation() const
TSharedPtr< FActorData > ActorData
virtual ECarlaServerResponse SetVehicleLightState(const FVehicleLightState &LightState) final
Maps a controller from OpenDrive.
FTrafficLightActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
UTrafficLightController * Controller
static TSharedPtr< FCarlaActor > ConstructCarlaActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, ActorType Type, carla::rpc::ActorState InState, UWorld *World)
void SetActorGlobalTransform(const FTransform &Transform, ETeleportType Teleport=ETeleportType::TeleportPhysics)
ECarlaServerResponse AddActorAngularImpulse(const FVector &AngularInpulse)
FVehicleLightState LightState
virtual ECarlaServerResponse DisableActorConstantVelocity() final
geom::Transform Transform
FVector LocalToGlobalLocation(const FVector &InLocation) const
FVector GetActorGlobalLocation() const
virtual ECarlaServerResponse GetPhysicsControl(FVehiclePhysicsControl &PhysicsControl) final
A view over an actor and its properties.
virtual ECarlaServerResponse UseCarSimRoad(bool bEnabled) final