25#include "GameFramework/CharacterMovementComponent.h"
42 SpawnTransform.AddToTranslation(FVector(0,0,15));
44 return CarlaEpisode->ReSpawnActorWithInfo(SpawnTransform,
Info.Description);
52 FTransform Transform =
Actor->GetTransform();
54 Location =
FDVector(Transform.GetLocation()) + CarlaEpisode->GetCurrentMapOrigin();
56 Scale = Transform.GetScale3D();
63 AngularVelocity = Component->GetPhysicsAngularVelocityInDegrees();
80 Component->SetPhysicsLinearVelocity(
82 Component->SetPhysicsAngularVelocityInDegrees(
83 AngularVelocity,
false,
"None");
87 auto* CarlaVehicle = Cast<ACarlaWheeledVehicle>(
Actor);
88 if (CarlaVehicle !=
nullptr){
101 auto RootComponent = Component;
102 if (RootComponent !=
nullptr)
105 RootComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
114 FVector LocalLocation = (
Location - CarlaEpisode->GetCurrentMapOrigin()).ToFVector();
135 auto Controller = Cast<AWheeledVehicleAIController>(
Vehicle->GetController());
157 Vehicle->ApplyVehicleControl(
Control, EVehicleInputPriority::Client);
164 auto Controller = Cast<AWheeledVehicleAIController>(
Vehicle->GetController());/ 获取车辆AI控制器
177 auto Walker = Cast<AWalkerBase>(
Actor);
178 auto Controller = Walker !=
nullptr ? Cast<AWalkerController>(Walker->GetController()) :
nullptr;
179 if (Controller !=
nullptr)
191 auto Walker = Cast<ACharacter>(
Actor);
192 auto Controller = Walker !=
nullptr ? Cast<AWalkerController>(Walker->GetController()) :
nullptr;
193 if (Controller !=
nullptr)
197 auto CharacterMovement = Cast<UCharacterMovementComponent>(Walker->GetCharacterMovement());
205 FActorSpawnParameters SpawnParams;
206 SpawnParams.SpawnCollisionHandlingOverride =
207 ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
224 USignComponent* TrafficSignComponent =
225 Cast<USignComponent>(TrafficSign->FindComponentByClass<USignComponent>());
226 if (TrafficSignComponent)
228 SignModel = TrafficSignComponent->GetClass();
229 SignId = TrafficSignComponent->GetSignId();
239 USignComponent* SignComponent =
241 SignComponent->SetSignId(
SignId);
243 SignComponent->RegisterComponent();
245 SignComponent->AttachToComponent(
246 Actor->GetRootComponent(),
247 FAttachmentTransformRules::KeepRelativeTransform);
251 SignComponent->InitializeSign(GameMode->
GetMap().get());
258 FActorSpawnParameters SpawnParams;
259 SpawnParams.SpawnCollisionHandlingOverride =
260 ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
273 UTrafficLightComponent* Component =
TrafficLight->GetTrafficLightComponent();
274 SignId = Component->GetSignId();
286 UTrafficLightComponent* Component =
TrafficLight->GetTrafficLightComponent();
287 Component->SetSignId(
SignId);
291 Component->InitializeSign(GameMode->
GetMap().get());
carla::rpc::VehicleFailureState FailureState
FVehicleLightState LightState
bool bAckermannControlActive
FAckermannControllerSettings AckermannControllerSettings
TSharedPtr< const FActorInfo > Info
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld Actor
const boost::optional< carla::road::Map > & GetMap() const
Base class for CARLA wheeled vehicles.
void SetDataStream(FDataStream InStream)
Replace the FDataStream associated with this sensor.
FDataStream MoveDataStream()
virtual void RecordActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode)
virtual AActor * RespawnActor(UCarlaEpisode *CarlaEpisode, const FActorInfo &Info)
virtual void RestoreActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode)
FTransform GetLocalTransform(UCarlaEpisode *CarlaEpisode) const
virtual void RestoreActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode) override
virtual void RecordActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode) override
virtual void RestoreActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode) override
ETrafficLightState LightState
TSubclassOf< AActor > Model
UTrafficLightController * Controller
virtual void RecordActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode) override
virtual AActor * RespawnActor(UCarlaEpisode *CarlaEpisode, const FActorInfo &Info) override
TSubclassOf< UObject > SignModel
virtual void RecordActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode) override
virtual AActor * RespawnActor(UCarlaEpisode *CarlaEpisode, const FActorInfo &Info) override
TSubclassOf< AActor > Model
virtual void RestoreActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode) override
FVehicleAckermannControl AckermannControl
FVehiclePhysicsControl PhysicsControl
carla::rpc::WalkerControl WalkerControl
virtual void RestoreActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode) override
virtual void RecordActorData(FCarlaActor *CarlaActor, UCarlaEpisode *CarlaEpisode) override
static ACarlaGameModeBase * GetGameMode(const UObject *WorldContextObject)
void RemoveCarlaActorTrafficLight(FCarlaActor *CarlaActor)
const FTrafficLightStage & GetCurrentState() const
void AddCarlaActorTrafficLight(FCarlaActor *CarlaActor)
void AddTrafficLight(UTrafficLightComponent *TrafficLight)
void RemoveTrafficLight(UTrafficLightComponent *TrafficLight)