13#include "GameFramework/CharacterMovementComponent.h"
19#include "Components/CapsuleComponent.h"
43 TSharedPtr<const FActorInfo>
Info,
59 TSharedPtr<const FActorInfo>
Info,
72 TSharedPtr<const FActorInfo>
Info,
80 TSharedPtr<const FActorInfo>
Info,
85 Type = ActorType::Sensor;
92 TSharedPtr<const FActorInfo>
Info,
98 ActorData = MakeShared<FTrafficSignData>();
104 TSharedPtr<const FActorInfo>
Info,
110 ActorData = MakeShared<FTrafficLightData>();
116 TSharedPtr<const FActorInfo>
Info,
128 TSharedPtr<const FActorInfo>
Info,
141 TSharedPtr<const FActorInfo>
Info,
177 ActorData->RecordActorData(
this, CarlaEpisode);
188 UE_LOG(LogCarla, Error, TEXT(
"Could not wake up dormant actor %d at location %s"),
GetActorId(), *(
ActorData->GetLocalTransform(CarlaEpisode).GetLocation().ToString()));
192 ActorData->RestoreActorData(
this, CarlaEpisode);
199 FTransform Transform = FTransform(
213 return GetActor()->GetActorTransform();
228 FTransform Transform =
GetActor()->GetActorTransform();
243 FVector Location =
ActorData->Location.ToFVector();
254 return GetActor()->GetActorLocation();
266 FVector Location =
GetActor()->GetActorLocation();
281 FVector GlobalLocation = Location;
292 GetActor()->SetActorRelativeLocation(
301 const FVector& Location, ETeleportType TeleportType)
309 FVector LocalLocation = Location;
316 GetActor()->SetActorRelativeLocation(
325 const FTransform& Transform, ETeleportType TeleportType)
329 FTransform GlobalTransform = Transform;
338 ActorData->Rotation = GlobalTransform.GetRotation();
339 ActorData->Scale = GlobalTransform.GetScale3D();
343 GetActor()->SetActorRelativeTransform(
352 const FTransform& Transform, ETeleportType TeleportType)
357 ActorData->Rotation = Transform.GetRotation();
358 ActorData->Scale = Transform.GetScale3D();
362 FTransform LocalTransform = Transform;
370 GetActor()->SetActorRelativeTransform(
399 Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
402 return Primitive->GetPhysicsAngularVelocityInDegrees();
416 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
417 if (RootComponent ==
nullptr)
421 RootComponent->SetPhysicsLinearVelocity(
433 ActorData->AngularVelocity = AngularVelocity;
438 if (RootComponent ==
nullptr)
442 RootComponent->SetPhysicsAngularVelocityInDegrees(
457 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
458 if (RootComponent ==
nullptr)
462 RootComponent->AddImpulse(
471 const FVector& Impulse,
const FVector& Location)
478 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
479 if (RootComponent ==
nullptr)
484 UE_LOG(LogCarla, Warning, TEXT(
"AddImpulseAtLocation: Experimental feature, use carefully."));
486 RootComponent->AddImpulseAtLocation(
501 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
502 if (RootComponent ==
nullptr)
506 RootComponent->AddForce(
515 const FVector& Force,
const FVector& Location)
522 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
523 if (RootComponent ==
nullptr)
528 UE_LOG(LogCarla, Warning, TEXT(
"AddForceAtLocation: Experimental feature, use carefully."));
530 RootComponent->AddForceAtLocation(
545 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
546 if (RootComponent ==
nullptr)
550 RootComponent->AddAngularImpulseInDegrees(
565 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
566 if (RootComponent ==
nullptr)
570 RootComponent->AddTorqueInDegrees(
588 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
589 if (RootComponent ==
nullptr)
594 RootComponent->SetSimulatePhysics(bEnabled);
595 RootComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
607 GetActor()->SetActorEnableCollision(bEnabled);
619 auto RootComponent = Cast<UPrimitiveComponent>(
GetActor()->GetRootComponent());
620 if (RootComponent ==
nullptr)
624 RootComponent->SetEnableGravity(bEnabled);
638 auto CarlaVehicle = Cast<ACarlaWheeledVehicle>(
GetActor());
639 if (CarlaVehicle ==
nullptr)
643 CarlaVehicle->ActivateVelocityControl(Velocity);
655 auto CarlaVehicle = Cast<ACarlaWheeledVehicle>(
GetActor());
656 if (CarlaVehicle ==
nullptr)
660 CarlaVehicle->DeactivateVelocityControl();
805 Vehicle->SetWheelSteerDirection(WheelLocation, AngleInDeg);
824 Angle =
Vehicle->GetWheelSteerAngle(WheelLocation);
837 auto* CarlaVehicle = Cast<ACarlaWheeledVehicle>(
GetActor());
839 if (CarlaVehicle ==
nullptr){
842 CarlaVehicle->SetSimulatePhysics(bEnabled);
854 ActorData->bAckermannControlActive =
false;
875 ActorData->bAckermannControlActive =
true;
903 VehicleControl =
Vehicle->GetVehicleControl();
913 VehicleAckermannControl =
ActorData->AckermannControl;
922 VehicleAckermannControl =
Vehicle->GetVehicleAckermannControl();
933 AckermannSettings =
ActorData->AckermannControllerSettings;
942 AckermannSettings =
Vehicle->GetAckermannControllerSettings();
953 ActorData->AckermannControllerSettings = AckermannSettings;
963 Vehicle->ApplyAckermannControllerSettings(AckermannSettings);
980 auto Controller = Cast<AWheeledVehicleAIController>(
Vehicle->GetController());
981 if (Controller ==
nullptr)
985 Controller->SetAutopilot(bEnabled, bKeepState);
995 TelemetryData = EmptyTelemetryData;
1004 TelemetryData =
Vehicle->GetVehicleTelemetryData();
1021 Vehicle->ShowDebugTelemetry(bEnabled);
1069 uint64_t MaxSubsteps,
float MaxSubstepDeltaTime,
1070 const FString& VehicleJSON,
const FString& PowertrainJSON,
1071 const FString& TireJSON,
const FString& BaseJSONPath)
1086 MaxSubstepDeltaTime,
1109 if(MovementComponent)
1154 return ETrafficLightState::Off;
1174 return TrafficLight->GetTrafficLightComponent()->GetController();
1263 TrafficLight->GetTrafficLightComponent()->GetGroup()->ResetGroup();
1271 const FTransform& Transform,
1274 FVector NewLocation = Transform.GetLocation();
1280 UCapsuleComponent* Capsule = Cast<UCapsuleComponent>(
GetActor()->GetRootComponent());
1283 NewLocation.Z += Capsule->GetScaledCapsuleHalfHeight();
1286 FTransform NewTransform = Transform;
1287 NewTransform.SetLocation(NewLocation);
1291 FWalkerData* WalkerData = GetActorData<FWalkerData>();
1303 auto Pawn = Cast<APawn>(
GetActor());
1304 if (Pawn ==
nullptr)
1308 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1309 if (Controller ==
nullptr)
1313 Controller->ApplyWalkerControl(WalkerControl);
1324 FWalkerData* WalkerData = GetActorData<FWalkerData>();
1336 auto Pawn = Cast<APawn>(
GetActor());
1337 if (Pawn ==
nullptr)
1341 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1342 if (Controller ==
nullptr)
1346 Control = Controller->GetWalkerControl();
1366 auto CharacterMovement = Cast<UCharacterMovementComponent>(
Character->GetCharacterMovement());
1368 CharacterMovement->SetDefaultMovementMode();
1371 CharacterMovement->DisableMovement();
1391 auto CharacterMovement = Cast<UCharacterMovementComponent>(
Character->GetCharacterMovement());
1394 CharacterMovement->SetDefaultMovementMode();
1397 if (CharacterMovement->IsFlying() || CharacterMovement->IsFalling())
1398 CharacterMovement->DisableMovement();
1414 auto Pawn = Cast<APawn>(
GetActor());
1415 if (Pawn ==
nullptr)
1419 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1420 if (Controller ==
nullptr)
1424 Controller->ApplyWalkerControl(
Control);
1436 auto Pawn = Cast<APawn>(
GetActor());
1437 if (Pawn ==
nullptr)
1441 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1442 if (Controller ==
nullptr)
1446 Controller->GetBonesTransform(Bones);
1458 auto Pawn = Cast<APawn>(
GetActor());
1459 if (Pawn ==
nullptr)
1463 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1464 if (Controller ==
nullptr)
1468 Controller->SetBonesTransform(Bones);
1480 auto Pawn = Cast<APawn>(
GetActor());
1481 if (Pawn ==
nullptr)
1485 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1486 if (Controller ==
nullptr)
1490 Controller->BlendPose(Blend);
1502 auto Pawn = Cast<APawn>(
GetActor());
1503 if (Pawn ==
nullptr)
1507 auto Controller = Cast<AWalkerController>(Pawn->GetController());
1508 if (Controller ==
nullptr)
1512 Controller->GetPoseFromAnimation();
1524 auto Pawn = Cast<APawn>(
GetActor());
1525 if (Pawn ==
nullptr)
1529 auto Walker = Cast<AWalkerBase>(Pawn);
1534 Walker->StartDeathLifeSpan();
1535 UE_LOG(LogCarla, Warning, TEXT(
"Walker starting life span by dead"));
carla::rpc::VehicleFailureState FailureState
FVehicleLightState LightState
FVehiclePhysicsControl PhysicsControl
FVehicleAckermannControl AckermannControl
UE_LOG(LogCarla, Log, TEXT("UActorDispatcher::Destroying actor: '%s' %x"), *Id, Actor)
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld * World
TSharedPtr< const FActorInfo > carla::rpc::ActorState InState
TSharedPtr< const FActorInfo > Info
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld Actor
@ WalkerIncompatibleController
EVehicleDoor
Type of door to open/close
FTransform GlobalToLocalTransform(const FTransform &InTransform) const
FVector GlobalToLocalLocation(const FVector &InLocation) const
FTransform LocalToGlobalTransform(const FTransform &InTransform) const
FVector LocalToGlobalLocation(const FVector &InLocation) const
carla::rpc::ActorState State
ECarlaServerResponse AddActorImpulseAtLocation(const FVector &Impulse, const FVector &Location)
static TSharedPtr< FCarlaActor > ConstructCarlaActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, ActorType Type, carla::rpc::ActorState InState, UWorld *World)
ECarlaServerResponse AddActorForceAtLocation(const FVector &Force, const FVector &Location)
virtual ECarlaServerResponse SetActorEnableGravity(bool bEnabled)
FVector GetActorLocalLocation() const
void SetActorLocalTransform(const FTransform &Transform, ETeleportType Teleport=ETeleportType::TeleportPhysics)
ECarlaServerResponse AddActorTorque(const FVector &Torque)
ECarlaServerResponse SetActorTargetAngularVelocity(const FVector &AngularVelocity)
ECarlaServerResponse AddActorImpulse(const FVector &Impulse)
virtual ECarlaServerResponse SetActorCollisions(bool bEnabled)
FVector GetActorAngularVelocity() const
FTransform GetActorGlobalTransform() const
FVector GetActorVelocity() const
void SetActorGlobalTransform(const FTransform &Transform, ETeleportType Teleport=ETeleportType::TeleportPhysics)
void SetActorGlobalLocation(const FVector &Location, ETeleportType Teleport=ETeleportType::TeleportPhysics)
TSharedPtr< const FActorInfo > Info
FVector GetActorGlobalLocation() const
void SetActorLocalLocation(const FVector &Location, ETeleportType Teleport=ETeleportType::TeleportPhysics)
TSharedPtr< FActorData > ActorData
IdType GetActorId() const
FTransform GetActorLocalTransform() const
ECarlaServerResponse SetActorTargetVelocity(const FVector &Velocity)
ECarlaServerResponse AddActorForce(const FVector &Force)
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bEnabled)
void WakeActorUp(UCarlaEpisode *CarlaEpisode)
ECarlaServerResponse AddActorAngularImpulse(const FVector &AngularInpulse)
void PutActorToSleep(UCarlaEpisode *CarlaEpisode)
FOtherActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
FSensorActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
virtual ECarlaServerResponse SetLightGreenTime(float time) final
virtual ECarlaServerResponse FreezeTrafficLight(bool bFreeze) final
virtual ETrafficLightState GetTrafficLightState() const final
FTrafficLightActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
virtual ECarlaServerResponse SetTrafficLightState(const ETrafficLightState &State) final
virtual ECarlaServerResponse ResetTrafficLightGroup() final
virtual UTrafficLightController * GetTrafficLightController() final
virtual ECarlaServerResponse SetLightRedTime(float time) final
virtual ECarlaServerResponse SetLightYellowTime(float time) final
FTrafficSignActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
virtual ECarlaServerResponse SetActorAutopilot(bool bEnabled, bool bKeepState=false) final
virtual ECarlaServerResponse EnableChronoPhysics(uint64_t MaxSubsteps, float MaxSubstepDeltaTime, const FString &VehicleJSON, const FString &PowertrainJSON, const FString &TireJSON, const FString &BaseJSONPath) final
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bSimulatePhysics) final
FVehicleActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
virtual ECarlaServerResponse DisableActorConstantVelocity() final
virtual ECarlaServerResponse GetVehicleLightState(FVehicleLightState &LightState) final
virtual ECarlaServerResponse GetFailureState(carla::rpc::VehicleFailureState &) final
virtual ECarlaServerResponse GetWheelSteerAngle(const EVehicleWheelLocation &WheelLocation, float &Angle)
virtual ECarlaServerResponse ApplyControlToVehicle(const FVehicleControl &, const EVehicleInputPriority &) final
virtual ECarlaServerResponse EnableActorConstantVelocity(const FVector &Velocity) final
virtual ECarlaServerResponse SetVehicleLightState(const FVehicleLightState &LightState) final
virtual ECarlaServerResponse EnableCarSim(const FString &SimfilePath) final
virtual ECarlaServerResponse GetPhysicsControl(FVehiclePhysicsControl &PhysicsControl) final
virtual ECarlaServerResponse SetWheelSteerDirection(const EVehicleWheelLocation &WheelLocation, float AngleInDeg) final
virtual ECarlaServerResponse UseCarSimRoad(bool bEnabled) final
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &) final
virtual ECarlaServerResponse ApplyAckermannControllerSettings(const FAckermannControllerSettings &) final
virtual ECarlaServerResponse GetVehicleTelemetryData(FVehicleTelemetryData &) final
virtual ECarlaServerResponse ApplyAckermannControlToVehicle(const FVehicleAckermannControl &, const EVehicleInputPriority &) final
virtual ECarlaServerResponse ApplyPhysicsControl(const FVehiclePhysicsControl &PhysicsControl) final
virtual ECarlaServerResponse OpenVehicleDoor(const EVehicleDoor DoorIdx) final
virtual ECarlaServerResponse CloseVehicleDoor(const EVehicleDoor DoorIdx) final
virtual ECarlaServerResponse GetVehicleAckermannControl(FVehicleAckermannControl &) final
virtual ECarlaServerResponse RestorePhysXPhysics()
virtual ECarlaServerResponse ShowVehicleDebugTelemetry(bool bEnabled) final
virtual ECarlaServerResponse GetAckermannControllerSettings(FAckermannControllerSettings &) final
virtual ECarlaServerResponse BlendPose(float Blend)
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bSimulatePhysics) final
virtual ECarlaServerResponse SetActorEnableGravity(bool bEnabled) final
virtual ECarlaServerResponse GetPoseFromAnimation()
FWalkerActor(IdType ActorId, AActor *Actor, TSharedPtr< const FActorInfo > Info, carla::rpc::ActorState InState, UWorld *World)
virtual ECarlaServerResponse SetBonesTransform(const FWalkerBoneControlIn &) final
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl &) final
virtual ECarlaServerResponse SetWalkerState(const FTransform &Transform, carla::rpc::WalkerControl WalkerControl) final
virtual ECarlaServerResponse SetActorDead()
virtual ECarlaServerResponse ApplyControlToWalker(const FWalkerControl &) final
virtual ECarlaServerResponse GetBonesTransform(FWalkerBoneControlOut &) final
carla::rpc::WalkerControl WalkerControl
virtual void DisableSpecialPhysics()
static void CreateCarsimComponent(ACarlaWheeledVehicle *Vehicle, FString Simfile)
void UseCarSimRoad(bool bEnabled)
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
static void CreateChronoMovementComponent(ACarlaWheeledVehicle *Vehicle, uint64_t MaxSubsteps, float MaxSubstepDeltaTime, FString VehicleJSON="", FString PowertrainJSON="", FString TireJSON="", FString BaseJSONPath="")
从 OpenDrive 映射一个控制器。控制相关交通信号灯并包含其循环