14 #include "GameFramework/CharacterMovementComponent.h" 20 #include "Components/CapsuleComponent.h" 44 TSharedPtr<const FActorInfo> Info,
48 Info(
std::move(Info)),
57 TSharedPtr<const FActorInfo>
Info,
68 TSharedPtr<const FActorInfo>
Info,
74 ActorData = MakeShared<FActorSensorData>();
79 TSharedPtr<const FActorInfo>
Info,
85 ActorData = MakeShared<FTrafficSignData>();
90 TSharedPtr<const FActorInfo>
Info,
96 ActorData = MakeShared<FTrafficLightData>();
101 TSharedPtr<const FActorInfo>
Info,
104 :
FCarlaActor(ActorId, Actor, Info, InState, World)
112 TSharedPtr<const FActorInfo>
Info,
115 :
FCarlaActor(ActorId, Actor, Info, InState, World)
124 TSharedPtr<const FActorInfo>
Info,
132 return MakeShared<FTrafficSignActor>(
ActorId,
Actor, std::move(Info), InState,
World);
135 return MakeShared<FTrafficLightActor>(
ActorId,
Actor, std::move(Info), InState,
World);
138 return MakeShared<FVehicleActor>(
ActorId,
Actor, std::move(Info), InState,
World);
141 return MakeShared<FWalkerActor>(
ActorId,
Actor, std::move(Info), InState,
World);
144 return MakeShared<FSensorActor>(
ActorId,
Actor, std::move(Info), InState,
World);
159 ActorData->RecordActorData(
this, CarlaEpisode);
170 UE_LOG(LogCarla, Error, TEXT(
"Could not wake up dormant actor %d at location %s"),
GetActorId(), *(
ActorData->GetLocalTransform(CarlaEpisode).GetLocation().ToString()));
174 ActorData->RestoreActorData(
this, CarlaEpisode);
189 Transform = LargeMap->GlobalToLocalTransform(Transform);
195 return GetActor()->GetActorTransform();
236 return GetActor()->GetActorLocation();
274 GetActor()->SetActorRelativeLocation(
283 const FVector&
Location, ETeleportType TeleportType)
298 GetActor()->SetActorRelativeLocation(
307 const FTransform&
Transform, ETeleportType TeleportType)
320 ActorData->Rotation = GlobalTransform.GetRotation();
321 ActorData->Scale = GlobalTransform.GetScale3D();
325 GetActor()->SetActorRelativeTransform(
334 const FTransform&
Transform, ETeleportType TeleportType)
339 ActorData->Rotation = Transform.GetRotation();
340 ActorData->Scale = Transform.GetScale3D();
352 GetActor()->SetActorRelativeTransform(
381 Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
384 return Primitive->GetPhysicsAngularVelocityInDegrees();
398 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
399 if (RootComponent ==
nullptr)
403 RootComponent->SetPhysicsLinearVelocity(
415 ActorData->AngularVelocity = AngularVelocity;
420 if (RootComponent ==
nullptr)
424 RootComponent->SetPhysicsAngularVelocityInDegrees(
439 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
440 if (RootComponent ==
nullptr)
444 RootComponent->AddImpulse(
453 const FVector& Impulse,
const FVector&
Location)
460 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
461 if (RootComponent ==
nullptr)
466 UE_LOG(LogCarla, Warning, TEXT(
"AddImpulseAtLocation: Experimental feature, use carefully."));
468 RootComponent->AddImpulseAtLocation(
483 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
484 if (RootComponent ==
nullptr)
488 RootComponent->AddForce(
497 const FVector& Force,
const FVector&
Location)
504 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
505 if (RootComponent ==
nullptr)
510 UE_LOG(LogCarla, Warning, TEXT(
"AddForceAtLocation: Experimental feature, use carefully."));
512 RootComponent->AddForceAtLocation(
527 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
528 if (RootComponent ==
nullptr)
532 RootComponent->AddAngularImpulseInDegrees(
547 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
548 if (RootComponent ==
nullptr)
552 RootComponent->AddTorqueInDegrees(
570 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
571 if (RootComponent ==
nullptr)
576 RootComponent->SetSimulatePhysics(bEnabled);
577 RootComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
589 GetActor()->SetActorEnableCollision(bEnabled);
601 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
602 if (RootComponent ==
nullptr)
606 RootComponent->SetEnableGravity(bEnabled);
620 auto CarlaVehicle = Cast<ACarlaWheeledVehicle>(
GetActor());
621 if (CarlaVehicle ==
nullptr)
625 CarlaVehicle->ActivateVelocityControl(Velocity);
637 auto CarlaVehicle = Cast<ACarlaWheeledVehicle>(
GetActor());
638 if (CarlaVehicle ==
nullptr)
642 CarlaVehicle->DeactivateVelocityControl();
661 PhysicsControl =
Vehicle->GetVehiclePhysicsControl();
680 FailureState =
Vehicle->GetFailureState();
700 LightState =
Vehicle->GetVehicleLightState();
749 Vehicle->ApplyVehiclePhysicsControl(PhysicsControl);
770 Vehicle->SetVehicleLightState(LightState);
787 Vehicle->SetWheelSteerDirection(WheelLocation, AngleInDeg);
806 Angle =
Vehicle->GetWheelSteerAngle(WheelLocation);
819 auto* CarlaVehicle = Cast<ACarlaWheeledVehicle>(
GetActor());
821 if (CarlaVehicle ==
nullptr){
824 CarlaVehicle->SetSimulatePhysics(bEnabled);
845 Vehicle->ApplyVehicleControl(Control, Priority);
866 Vehicle->ApplyVehicleAckermannControl(AckermannControl, Priority);
876 VehicleControl = ActorData->
Control;
885 VehicleControl =
Vehicle->GetVehicleControl();
904 VehicleAckermannControl =
Vehicle->GetVehicleAckermannControl();
924 AckermannSettings =
Vehicle->GetAckermannControllerSettings();
945 Vehicle->ApplyAckermannControllerSettings(AckermannSettings);
962 auto Controller = Cast<AWheeledVehicleAIController>(
Vehicle->GetController());
963 if (Controller ==
nullptr)
967 Controller->SetAutopilot(bEnabled, bKeepState);
984 Vehicle->ShowDebugTelemetry(bEnabled);
1032 uint64_t MaxSubsteps,
float MaxSubstepDeltaTime,
1033 const FString& VehicleJSON,
const FString& PowertrainJSON,
1034 const FString& TireJSON,
const FString& BaseJSONPath)
1049 MaxSubstepDeltaTime,
1095 return ETrafficLightState::Off;
1115 return TrafficLight->GetTrafficLightComponent()->GetController();
1204 TrafficLight->GetTrafficLightComponent()->GetGroup()->ResetGroup();
1215 FVector NewLocation = Transform.GetLocation();
1221 UCapsuleComponent* Capsule = Cast<UCapsuleComponent>(
GetActor()->GetRootComponent());
1224 NewLocation.Z += Capsule->GetScaledCapsuleHalfHeight();
1228 NewTransform.SetLocation(NewLocation);
1232 FWalkerData* WalkerData = GetActorData<FWalkerData>();
1237 auto * Walker = Cast<AWalkerBase>(
GetActor());
1238 if (Walker && !Walker->bAlive)
1244 auto Pawn = Cast<APawn>(
GetActor());
1245 if (Pawn ==
nullptr)
1249 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1250 if (Controller ==
nullptr)
1254 Controller->ApplyWalkerControl(WalkerControl);
1265 FWalkerData* WalkerData = GetActorData<FWalkerData>();
1270 auto * Walker = Cast<AWalkerBase>(
GetActor());
1271 if (Walker && !Walker->bAlive)
1277 auto Pawn = Cast<APawn>(
GetActor());
1278 if (Pawn ==
nullptr)
1282 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1283 if (Controller ==
nullptr)
1287 Control = Controller->GetWalkerControl();
1307 auto CharacterMovement = Cast<UCharacterMovementComponent>(
Character->GetCharacterMovement());
1309 CharacterMovement->SetDefaultMovementMode();
1312 CharacterMovement->DisableMovement();
1332 auto CharacterMovement = Cast<UCharacterMovementComponent>(
Character->GetCharacterMovement());
1335 CharacterMovement->SetDefaultMovementMode();
1338 if (CharacterMovement->IsFlying() || CharacterMovement->IsFalling())
1339 CharacterMovement->DisableMovement();
1355 auto Pawn = Cast<APawn>(
GetActor());
1356 if (Pawn ==
nullptr)
1360 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1361 if (Controller ==
nullptr)
1365 Controller->ApplyWalkerControl(Control);
1377 auto Pawn = Cast<APawn>(
GetActor());
1378 if (Pawn ==
nullptr)
1382 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1383 if (Controller ==
nullptr)
1387 Controller->GetBonesTransform(Bones);
1399 auto Pawn = Cast<APawn>(
GetActor());
1400 if (Pawn ==
nullptr)
1404 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1405 if (Controller ==
nullptr)
1409 Controller->SetBonesTransform(Bones);
1421 auto Pawn = Cast<APawn>(
GetActor());
1422 if (Pawn ==
nullptr)
1426 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1427 if (Controller ==
nullptr)
1431 Controller->BlendPose(Blend);
1443 auto Pawn = Cast<APawn>(
GetActor());
1444 if (Pawn ==
nullptr)
1448 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1449 if (Controller ==
nullptr)
1453 Controller->GetPoseFromAnimation();
1465 auto Pawn = Cast<APawn>(
GetActor());
1466 if (Pawn ==
nullptr)
1470 auto Walker = Cast<AWalkerBase>(Pawn);
1471 if (Walker ==
nullptr)
1475 Walker->StartDeathLifeSpan();
1476 UE_LOG(LogCarla, Warning, TEXT(
"Walker starting life span by dead"));
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
virtual ECarlaServerResponse ApplyAckermannControllerSettings(const FAckermannControllerSettings &) final
void WakeActorUp(UCarlaEpisode *CarlaEpisode)
virtual ECarlaServerResponse ShowVehicleDebugTelemetry(bool bEnabled) final
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &) final
FVector GetActorAngularVelocity() const
FVehicleAckermannControl AckermannControl
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
virtual ECarlaServerResponse SetActorCollisions(bool bEnabled)
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 SetActorDead()
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)
bool bAckermannControlActive
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 GetVehicleAckermannControl(FVehicleAckermannControl &) 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.
FAckermannControllerSettings AckermannControllerSettings
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
carla::rpc::VehicleFailureState FailureState
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
virtual ECarlaServerResponse ApplyAckermannControlToVehicle(const FVehicleAckermannControl &, const EVehicleInputPriority &) final
FVector LocalToGlobalLocation(const FVector &InLocation) const
FVector GetActorGlobalLocation() const
virtual ECarlaServerResponse GetPhysicsControl(FVehiclePhysicsControl &PhysicsControl) final
virtual ECarlaServerResponse GetAckermannControllerSettings(FAckermannControllerSettings &) final
virtual ECarlaServerResponse GetFailureState(carla::rpc::VehicleFailureState &) final
A view over an actor and its properties.
virtual ECarlaServerResponse UseCarSimRoad(bool bEnabled) final