19#include "Components/BoxComponent.h"
20#include "Components/SkeletalMeshComponent.h"
21#include "VehicleAnimInstance.h"
35 PrimaryActorTick.TickGroup = TG_PrePhysics;
40 : Super(ObjectInitializer)
42 PrimaryActorTick.TickGroup = TG_PrePhysics;
62 uint32_t FollowId,
bool ReplaySensors)
91 Super::Tick(DeltaSeconds);
105 for (
auto It = Registry.begin(); It != Registry.end(); ++It)
149 else if (
Episode->GetReplayer()->IsEnabled())
152 Episode->GetReplayer()->Tick(DeltaSeconds);
158 PrimaryActorTick.bCanEverTick =
true;
164 PrimaryActorTick.bCanEverTick =
false;
170 check(CarlaActor !=
nullptr);
177 Transform.GetLocation(),
178 Transform.GetRotation().Euler()
184 check(CarlaActor !=
nullptr);
207 check(CarlaActor !=
nullptr)
214 if (CarlaVehicle ==
nullptr)
217 USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
218 if (SkeletalMesh ==
nullptr)
221 UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
222 if (VehicleAnim ==
nullptr)
225 const UWheeledVehicleMovementComponent* WheeledVehicleMovementComponent = VehicleAnim->GetWheeledVehicleMovementComponent();
226 if (WheeledVehicleMovementComponent ==
nullptr)
231 Record.
WheelValues.reserve(WheeledVehicleMovementComponent->Wheels.Num());
234 for (
auto Wheel : WheeledVehicleMovementComponent->Wheels)
239 Info.TireRotation = Wheel->GetRotationAngle();
251 WheeledVehicleMovementComponent->GetForwardSpeed(),
252 WheeledVehicleMovementComponent->GetEngineRotationSpeed() / WheeledVehicleMovementComponent->GetEngineMaxRotationSpeed()
259 check(CarlaActor !=
nullptr);
275 check(CarlaActor !=
nullptr);
297 check(CarlaActor !=
nullptr);
318 check(CarlaActor !=
nullptr);
320 FVector Velocity, AngularVelocity;
321 constexpr float TO_METERS = 1e-2;
335 check(CarlaActor !=
nullptr);
341 {Box.Origin, Box.Extent}
356 UBoxComponent* Trigger = Triggers.Top();
357 auto VolumeOrigin = Trigger->GetComponentLocation();
358 auto VolumeExtent = Trigger->GetScaledBoxExtent();
361 Episode->GetActorRegistry().FindCarlaActor(&TrafficSign)->GetActorId(),
362 {VolumeOrigin, VolumeExtent}
374 Control.VehiclePhysicsControl =
Vehicle.GetVehiclePhysicsControl();
396 check(CarlaActor !=
nullptr);
406 FString Name = Bone.Get<0>();
407 auto Transforms = Bone.Get<1>();
408 FVector Loc = Transforms.Relative.GetTranslation();
409 FVector Rot = Transforms.Relative.GetRotation().Euler();
411 Walker.
Bones.push_back(Entry);
432 File.open(Filename, std::ios::binary);
457 return std::string(Filename);
586 if (FoundActor1 !=
nullptr) {
591 Collision.IsActor1Hero = (Role->Value ==
"hero");
601 if (FoundActor2 !=
nullptr) {
606 Collision.IsActor2Hero = (Role->Value ==
"hero");
681 Light->GetLightIntensity(),
682 Light->GetLightColor(),
684 static_cast<uint8
>(Light->GetLightType())
711 for (
auto& It : Registry)
714 if (CarlaActor !=
nullptr)
725 UWorld *
World = GetWorld();
729 const auto& Lights = CarlaLightSubsystem->
GetLights();
730 for (
const auto& LightPair : Lights)
732 UCarlaLight* Light = LightPair.Value;
742 const FTransform &Transform,
746 Description.
UId = ActorDescription.
UId;
747 Description.
Id = ActorDescription.
Id;
751 for (
const auto &item : ActorDescription.
Variations)
754 Attr.
Type =
static_cast<uint8_t
>(item.Value.Type);
755 Attr.
Id = item.Value.Id;
756 Attr.
Value = item.Value.Value;
758 if (!Attr.
Id.IsEmpty())
760 Description.
Attributes.emplace_back(std::move(Attr));
769 Transform.GetTranslation(),
770 Transform.GetRotation().Euler(),
771 std::move(Description)
FVehicleLightState LightState
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld * World
std::string GetRecorderFilename(std::string Filename)
EVehicleDoor
Type of door to open/close
CarlaRecorderEventsAdd EventsAdd
void AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels)
void AddState(const CarlaRecorderStateTrafficLight &State)
void Ticking(float DeltaSeconds)
void AddVehicleWheelsAnimation(FCarlaActor *CarlaActor)
CarlaRecorderTrafficLightTimes TrafficLightTimes
CarlaRecorderPhysicsControls PhysicsControls
CarlaRecorderLightScenes LightScenes
void AddEvent(const CarlaRecorderEventAdd &Event)
std::string ShowFileCollisions(std::string Name, char Type1, char Type2)
CarlaRecorderAnimBikers Bikers
void AddVehicleDoor(const ACarlaWheeledVehicle &Vehicle, const EVehicleDoor SDoors, bool bIsOpen)
void StopReplayer(bool KeepActors=false)
std::string ShowFileInfo(std::string Name, bool bShowAll=false)
void AddActorBoundingBox(FCarlaActor *CarlaActor)
void AddTriggerVolume(const ATrafficSignBase &TrafficSign)
void AddActorBones(FCarlaActor *CarlaActor)
void AddVehicleLight(FCarlaActor *CarlaActor)
CarlaRecorderActorBoundingBoxes BoundingBoxes
CarlaRecorderLightVehicles LightVehicles
std::string ReplayFile(std::string Name, double TimeStart, double Duration, uint32_t FollowId, bool ReplaySensors)
CarlaRecorderVisualTime VisualTime
void AddEventLightSceneChanged(const UCarlaLight *Light)
void AddKinematics(const CarlaRecorderKinematics &ActorKinematics)
CarlaRecorderPlatformTime PlatformTime
CarlaRecorderActorTriggerVolumes TriggerVolumes
void AddExistingActors(void)
std::string ShowFileActorsBlocked(std::string Name, double MinTime=30, double MinDistance=10)
void AddActorKinematics(FCarlaActor *CarlaActor)
void AddCollision(AActor *Actor1, AActor *Actor2)
void SetReplayerIgnoreSpectator(bool IgnoreSpectator)
CarlaRecorderWalkersBones WalkersBones
void AddVehicleAnimation(FCarlaActor *CarlaActor)
void SetReplayerIgnoreHero(bool IgnoreHero)
void AddAnimBiker(const CarlaRecorderAnimBiker &Biker)
void AddPhysicsControl(const ACarlaWheeledVehicle &Vehicle)
void AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle)
void AddTrafficLightState(FCarlaActor *CarlaActor)
void AddWalkerAnimation(FCarlaActor *CarlaActor)
void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle)
void SetReplayerTimeFactor(double TimeFactor)
std::string Start(std::string Name, FString MapName, bool AdditionalData=false)
void AddTrafficLightTime(const ATrafficLightBase &TrafficLight)
void CreateRecorderEventAdd(uint32_t DatabaseId, uint8_t Type, const FTransform &Transform, FActorDescription ActorDescription)
CarlaRecorderEventsParent EventsParent
void AddPosition(const CarlaRecorderPosition &Position)
CarlaRecorderCollisions Collisions
void AddBoundingBox(const CarlaRecorderActorBoundingBox &ActorBoundingBox)
CarlaRecorderActorsKinematics Kinematics
CarlaRecorderPositions Positions
CarlaRecorderAnimWalkers Walkers
CarlaRecorderAnimVehicleWheels Wheels
void AddAnimWalker(const CarlaRecorderAnimWalker &Walker)
CarlaRecorderStates States
void AddDoorVehicle(const CarlaRecorderDoorVehicle &DoorVehicle)
void AddActorPosition(FCarlaActor *CarlaActor)
CarlaRecorderEventsDel EventsDel
void Write(double DeltaSeconds)
CarlaRecorderFrames Frames
CarlaRecorderAnimVehicles Vehicles
CarlaRecorderDoorVehicles DoorVehicles
Base class for CARLA wheeled vehicles.
bool IsTwoWheeledVehicle()
float GetWheelSteerAngle(EVehicleWheelLocation WheelLocation)
如果你的类继承自UObject,你的类名上方需要加入 UCLASS() 宏 实现交通信号灯状态改变的类
TArray< UBoxComponent * > GetTriggerVolumes() const
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Add(const CarlaRecorderKinematics &InObj)
void Write(std::ostream &OutFile)
void Write(std::ostream &OutFile) const
void Add(const CarlaRecorderAnimBiker &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderAnimWheels &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderAnimVehicle &InObj)
void Add(const CarlaRecorderAnimWalker &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderCollision &Collision)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderEventAdd &Event)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderEventDel &Event)
void Write(std::ostream &OutFile)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderEventParent &Event)
void SetFrame(double DeltaSeconds)
void WriteEnd(std::ostream &OutFile)
void WriteStart(std::ostream &OutFile)
void Add(const CarlaRecorderPhysicsControl &InObj)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderPosition &InObj)
void Write(std::ostream &OutFile)
std::string QueryBlocked(std::string Filename, double MinTime=30, double MinDistance=10)
std::string QueryCollisions(std::string Filename, char Category1='a', char Category2='a')
std::string QueryInfo(std::string Filename, bool bShowAll=false)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderStateTrafficLight &State)
void Add(const CarlaRecorderTrafficLightTime &InObj)
void Write(std::ostream &OutFile)
void Write(std::ofstream &OutFile)
void Add(const CarlaRecorderWalkerBones &InObj)
void SetIgnoreHero(bool InIgnoreHero)
std::string ReplayFile(std::string Filename, double TimeStart=0.0f, double Duration=0.0f, uint32_t FollowId=0, bool ReplaySensors=false)
void SetIgnoreSpectator(bool InIgnoreSpectator)
void SetTimeFactor(double NewTimeFactor)
void Stop(bool KeepActors=false)
virtual ECarlaServerResponse GetBonesTransform(FWalkerBoneControlOut &)
ActorType GetActorType() const
FVector GetActorAngularVelocity() const
virtual ECarlaServerResponse GetVehicleLightState(FVehicleLightState &)
FTransform GetActorGlobalTransform() const
FVector GetActorVelocity() const
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &)
bool IsPendingKill() const
virtual ETrafficLightState GetTrafficLightState() const
virtual UTrafficLightController * GetTrafficLightController()
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl &)
const FActorInfo * GetActorInfo() const
IdType GetActorId() const
std::vector< carla::rpc::LightState > GetLights(FString Client)
从 OpenDrive 映射一个控制器。控制相关交通信号灯并包含其循环
ATrafficLightGroup * GetGroup()
float GetElapsedTime() const
flag_type light_state
灯光状态标志,默认情况下全部关闭
std::vector< CarlaRecorderActorAttribute > Attributes
std::vector< WheelInfo > WheelValues
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderDoorVehicle &InObj)
void Write(std::ostream &File)
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightScene &InObj)
VehicleLightStateType State
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderLightVehicle &InObj)
void Write(std::ofstream &OutFile)
void SetTime(double ThisTime)
std::vector< CarlaRecorderWalkerBone > Bones
TMap< FString, FActorAttribute > Variations
用户选择了参与者的变化版本。请注意,此时是 由不可修改的属性表示
FActorDescription Description
TMap< FString, FWalkerBoneControlOutData > BoneTransforms