CARLA
 
载入中...
搜索中...
未找到
CarlaActor.h
浏览该文件的文档.
1// Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
15
18
20
21class AActor;
22
23/// A view over an actor and its properties.
25{
26public:
27
28 using IdType = uint32;
29
30 enum class ActorType : uint8
31 {
32 Other,
33 Vehicle,
34 Walker,
37 Sensor,
39 };
40
41 FCarlaActor() = default;
42 // FCarlaActor(const FCarlaActor &) = default;
43 // FCarlaActor(FCarlaActor &&) = default;
44
46 IdType ActorId,
47 AActor* Actor,
48 TSharedPtr<const FActorInfo> Info,
50 UWorld* World);
51
52 virtual ~FCarlaActor() {};
53
54
55 bool IsInValid() const
56 {
58 }
59
65
66 bool IsActive() const
67 {
69 }
70
71 bool IsDormant() const
72 {
74 }
75
76 bool IsPendingKill() const
77 {
79 }
80
82 {
83 return Id;
84 }
85
87 {
88 return Type;
89 }
90
92 {
93 return TheActor;
94 }
95
96 const AActor *GetActor() const
97 {
98 return TheActor;
99 }
100
102 {
103 return Info.Get();
104 }
105
107 {
108 return State;
109 }
110
112 {
113 State = InState;
114 }
115
116 void SetParent(IdType InParentId)
117 {
118 ParentId = InParentId;
119 }
120
122 {
123 return ParentId;
124 }
125
126 void AddChildren(IdType ChildId)
127 {
128 Children.Add(ChildId);
129 }
130
131 void RemoveChildren(IdType ChildId)
132 {
133 Children.Remove(ChildId);
134 }
135
136 const TArray<IdType>& GetChildren() const
137 {
138 return Children;
139 }
140
142 {
143 Attachment = InAttachmentType;
144 }
145
150
152
153 void PutActorToSleep(UCarlaEpisode* CarlaEpisode);
154
155 void WakeActorUp(UCarlaEpisode* CarlaEpisode);
156
158 {
159 return ActorData.Get();
160 }
161
163 {
164 return ActorData.Get();
165 }
166
167 template<typename T>
169 {
170 return dynamic_cast<T*>(ActorData.Get());
171 }
172
173 template<typename T>
174 const T* GetActorData() const
175 {
176 return dynamic_cast<T*>(ActorData.Get());
177 }
178
179 // Actor function interface ----------------------
180
181 // General functions
182
183 FTransform GetActorLocalTransform() const;
184
185 FTransform GetActorGlobalTransform() const;
186
187 FVector GetActorLocalLocation() const;
188
189 FVector GetActorGlobalLocation() const;
190
192 const FVector& Location,
193 ETeleportType Teleport = ETeleportType::TeleportPhysics);
194
196 const FVector& Location,
197 ETeleportType Teleport = ETeleportType::TeleportPhysics);
198
200 const FTransform& Transform,
201 ETeleportType Teleport = ETeleportType::TeleportPhysics);
202
204 const FTransform& Transform,
205 ETeleportType Teleport = ETeleportType::TeleportPhysics);
206
207 FVector GetActorVelocity() const;
208
209 FVector GetActorAngularVelocity() const;
210
211 ECarlaServerResponse SetActorTargetVelocity(const FVector& Velocity);
212
213 ECarlaServerResponse SetActorTargetAngularVelocity(const FVector& AngularVelocity);
214
215 ECarlaServerResponse AddActorImpulse(const FVector& Impulse);
216
217 ECarlaServerResponse AddActorImpulseAtLocation(const FVector& Impulse, const FVector& Location);
218
219 ECarlaServerResponse AddActorForce(const FVector& Force);
220
221 ECarlaServerResponse AddActorForceAtLocation(const FVector& Force, const FVector& Location);
222
223 ECarlaServerResponse AddActorAngularImpulse(const FVector& AngularInpulse);
224
225 ECarlaServerResponse AddActorTorque(const FVector& Torque);
226
227 virtual ECarlaServerResponse SetActorSimulatePhysics(bool bEnabled);
228
229 virtual ECarlaServerResponse SetActorCollisions(bool bEnabled);
230
231 virtual ECarlaServerResponse SetActorEnableGravity(bool bEnabled);
232
233 // Vehicle functions
238
243
248
253
258
263
268
273
278
283
288
294
300
305
310
315
320
321 virtual ECarlaServerResponse SetActorAutopilot(bool, bool bKeepState = false)
322 {
324 }
325
330
335
336 virtual ECarlaServerResponse EnableCarSim(const FString&)
337 {
339 }
340
345
347 const FString&, const FString&, const FString&, const FString&)
348 {
350 }
351
356
357 // Traffic light functions
358
363
365 {
366 return ETrafficLightState::Off;
367 }
368
370 {
371 return nullptr;
372 }
373
378
383
388
389 // Traffic sign functions
390
391 // Walker functions
393 const FTransform& Transform,
394 carla::rpc::WalkerControl WalkerControl)
395 {
397 }
398
403
408
413
418
419 virtual ECarlaServerResponse BlendPose(float Blend)
420 {
422 }
423
428
433
438
443
444 // Sensor functions
445
446 static TSharedPtr<FCarlaActor> ConstructCarlaActor(
447 IdType ActorId,
448 AActor* Actor,
449 TSharedPtr<const FActorInfo> Info,
450 ActorType Type,
452 UWorld* World);
453
454private:
455
456 friend class FActorRegistry;
457
458 AActor *TheActor = nullptr;
459
460 TSharedPtr<const FActorInfo> Info = nullptr;
461
462 IdType Id = 0u;
463
465
467
469
470 TArray<IdType> Children;
471
472protected:
473
475
476 TSharedPtr<FActorData> ActorData = nullptr;
477
478 UWorld *World = nullptr;
479
480};
481
483{
484public:
486 IdType ActorId,
487 AActor* Actor,
488 TSharedPtr<const FActorInfo> Info,
490 UWorld* World);
491
492 virtual ECarlaServerResponse EnableActorConstantVelocity(const FVector& Velocity) final;
493
495
497
499
501
502 virtual ECarlaServerResponse OpenVehicleDoor(const EVehicleDoor DoorIdx) final;
503
504 virtual ECarlaServerResponse CloseVehicleDoor(const EVehicleDoor DoorIdx) final;
505
508
510 const FVehicleLightState& LightState) final;
511
513 const EVehicleWheelLocation& WheelLocation, float AngleInDeg) final;
514
516 const EVehicleWheelLocation& WheelLocation, float& Angle);
517
518 virtual ECarlaServerResponse SetActorSimulatePhysics(bool bSimulatePhysics) final;
519
521 const FVehicleControl&, const EVehicleInputPriority&) final;
522
525
527
529
531
533
534 virtual ECarlaServerResponse SetActorAutopilot(bool bEnabled, bool bKeepState = false) final;
535
537
538 virtual ECarlaServerResponse ShowVehicleDebugTelemetry(bool bEnabled) final;
539
540 virtual ECarlaServerResponse EnableCarSim(const FString& SimfilePath) final;
541
542 virtual ECarlaServerResponse UseCarSimRoad(bool bEnabled) final;
543
545 uint64_t MaxSubsteps, float MaxSubstepDeltaTime,
546 const FString& VehicleJSON, const FString& PowertrainJSON,
547 const FString& TireJSON, const FString& BaseJSONPath) final;
548
550};
551
553{
554public:
556 IdType ActorId,
557 AActor* Actor,
558 TSharedPtr<const FActorInfo> Info,
560 UWorld* World);
561
562};
563
565{
566public:
568 IdType ActorId,
569 AActor* Actor,
570 TSharedPtr<const FActorInfo> Info,
572 UWorld* World);
573};
574
576{
577public:
579 IdType ActorId,
580 AActor* Actor,
581 TSharedPtr<const FActorInfo> Info,
583 UWorld* World);
584
586
587 virtual ETrafficLightState GetTrafficLightState() const final;
588
590
591 virtual ECarlaServerResponse SetLightGreenTime(float time) final;
592
593 virtual ECarlaServerResponse SetLightYellowTime(float time) final;
594
595 virtual ECarlaServerResponse SetLightRedTime(float time) final;
596
597 virtual ECarlaServerResponse FreezeTrafficLight(bool bFreeze) final;
598
600
601};
602
604{
605public:
607 IdType ActorId,
608 AActor* Actor,
609 TSharedPtr<const FActorInfo> Info,
611 UWorld* World);
612
614 const FTransform& Transform,
615 carla::rpc::WalkerControl WalkerControl) final;
616
617 virtual ECarlaServerResponse SetActorSimulatePhysics(bool bSimulatePhysics) final;
618
619 virtual ECarlaServerResponse SetActorEnableGravity(bool bEnabled) final;
620
622
624
626
628
629 virtual ECarlaServerResponse BlendPose(float Blend);
630
632
634};
635
637{
638public:
640 IdType ActorId,
641 AActor* Actor,
642 TSharedPtr<const FActorInfo> Info,
644 UWorld* World);
645
646};
ECarlaServerResponse
EVehicleWheelLocation
EVehicleDoor
Type of door to open/close
EVehicleInputPriority
A registry of all the Carla actors.
A view over an actor and its properties.
Definition CarlaActor.h:25
carla::rpc::ActorState State
Definition CarlaActor.h:466
UWorld * World
Definition CarlaActor.h:478
ECarlaServerResponse AddActorImpulseAtLocation(const FVector &Impulse, const FVector &Location)
virtual ECarlaServerResponse GetPhysicsControl(FVehiclePhysicsControl &)
Definition CarlaActor.h:244
carla::rpc::AttachmentType GetAttachmentType() const
Definition CarlaActor.h:146
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)
void RemoveChildren(IdType ChildId)
Definition CarlaActor.h:131
virtual ECarlaServerResponse SetActorEnableGravity(bool bEnabled)
virtual ECarlaServerResponse GetBonesTransform(FWalkerBoneControlOut &)
Definition CarlaActor.h:409
virtual ECarlaServerResponse GetAckermannControllerSettings(FAckermannControllerSettings &)
Definition CarlaActor.h:311
virtual ECarlaServerResponse SetLightRedTime(float)
Definition CarlaActor.h:384
virtual ECarlaServerResponse ResetTrafficLightGroup()
Definition CarlaActor.h:439
IdType GetParent() const
Definition CarlaActor.h:121
ActorType GetActorType() const
Definition CarlaActor.h:86
FVector GetActorLocalLocation() const
void SetActorLocalTransform(const FTransform &Transform, ETeleportType Teleport=ETeleportType::TeleportPhysics)
virtual ECarlaServerResponse GetVehicleAckermannControl(FVehicleAckermannControl &)
Definition CarlaActor.h:306
virtual ECarlaServerResponse SetLightYellowTime(float)
Definition CarlaActor.h:379
virtual ECarlaServerResponse GetPoseFromAnimation()
Definition CarlaActor.h:424
virtual ECarlaServerResponse SetActorAutopilot(bool, bool bKeepState=false)
Definition CarlaActor.h:321
carla::rpc::AttachmentType Attachment
Definition CarlaActor.h:468
ECarlaServerResponse AddActorTorque(const FVector &Torque)
bool IsAlive() const
Definition CarlaActor.h:60
ECarlaServerResponse SetActorTargetAngularVelocity(const FVector &AngularVelocity)
bool IsDormant() const
Definition CarlaActor.h:71
ECarlaServerResponse AddActorImpulse(const FVector &Impulse)
AActor * GetActor()
Definition CarlaActor.h:91
virtual ECarlaServerResponse SetVehicleLightState(const FVehicleLightState &)
Definition CarlaActor.h:274
T * GetActorData()
Definition CarlaActor.h:168
virtual ECarlaServerResponse SetActorDead()
Definition CarlaActor.h:429
virtual ECarlaServerResponse ApplyControlToVehicle(const FVehicleControl &, const EVehicleInputPriority &)
Definition CarlaActor.h:289
virtual ECarlaServerResponse GetWheelSteerAngle(const EVehicleWheelLocation &, float &)
Definition CarlaActor.h:284
virtual ECarlaServerResponse ApplyAckermannControllerSettings(const FAckermannControllerSettings &)
Definition CarlaActor.h:316
uint32 IdType
Definition CarlaActor.h:28
virtual ECarlaServerResponse SetActorCollisions(bool bEnabled)
virtual ECarlaServerResponse GetVehicleTelemetryData(FVehicleTelemetryData &)
Definition CarlaActor.h:326
virtual ECarlaServerResponse CloseVehicleDoor(const EVehicleDoor)
Definition CarlaActor.h:264
virtual ECarlaServerResponse RestorePhysXPhysics()
Definition CarlaActor.h:352
AActor * TheActor
Definition CarlaActor.h:458
virtual ECarlaServerResponse GetFailureState(carla::rpc::VehicleFailureState &)
Definition CarlaActor.h:249
carla::rpc::ActorState GetActorState() const
Definition CarlaActor.h:106
FVector GetActorAngularVelocity() const
virtual ECarlaServerResponse ApplyAckermannControlToVehicle(const FVehicleAckermannControl &, const EVehicleInputPriority &)
Definition CarlaActor.h:295
void SetParent(IdType InParentId)
Definition CarlaActor.h:116
void SetAttachmentType(carla::rpc::AttachmentType InAttachmentType)
Definition CarlaActor.h:141
virtual ECarlaServerResponse SetWalkerState(const FTransform &Transform, carla::rpc::WalkerControl WalkerControl)
Definition CarlaActor.h:392
virtual ECarlaServerResponse DisableActorConstantVelocity()
Definition CarlaActor.h:239
virtual ECarlaServerResponse GetVehicleLightState(FVehicleLightState &)
Definition CarlaActor.h:254
IdType ParentId
Definition CarlaActor.h:464
virtual ECarlaServerResponse SetBonesTransform(const FWalkerBoneControlIn &)
Definition CarlaActor.h:414
FTransform GetActorGlobalTransform() const
FVector GetActorVelocity() const
virtual ECarlaServerResponse FreezeTrafficLight(bool)
Definition CarlaActor.h:434
void SetActorGlobalTransform(const FTransform &Transform, ETeleportType Teleport=ETeleportType::TeleportPhysics)
virtual ECarlaServerResponse ApplyControlToWalker(const FWalkerControl &)
Definition CarlaActor.h:399
void SetActorState(carla::rpc::ActorState InState)
Definition CarlaActor.h:111
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl &)
Definition CarlaActor.h:301
void SetActorGlobalLocation(const FVector &Location, ETeleportType Teleport=ETeleportType::TeleportPhysics)
FActorData * GetActorData()
Definition CarlaActor.h:157
TSharedPtr< const FActorInfo > Info
Definition CarlaActor.h:460
FVector GetActorGlobalLocation() const
ActorType Type
Definition CarlaActor.h:474
bool IsPendingKill() const
Definition CarlaActor.h:76
virtual ECarlaServerResponse UseCarSimRoad(bool)
Definition CarlaActor.h:341
virtual ECarlaServerResponse ApplyPhysicsControl(const FVehiclePhysicsControl &)
Definition CarlaActor.h:269
TArray< IdType > Children
Definition CarlaActor.h:470
virtual ECarlaServerResponse SetLightGreenTime(float)
Definition CarlaActor.h:374
void AddChildren(IdType ChildId)
Definition CarlaActor.h:126
virtual ETrafficLightState GetTrafficLightState() const
Definition CarlaActor.h:364
virtual ECarlaServerResponse OpenVehicleDoor(const EVehicleDoor)
Definition CarlaActor.h:259
bool IsInValid() const
Definition CarlaActor.h:55
const T * GetActorData() const
Definition CarlaActor.h:174
const FActorData * GetActorData() const
Definition CarlaActor.h:162
virtual UTrafficLightController * GetTrafficLightController()
Definition CarlaActor.h:369
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl &)
Definition CarlaActor.h:404
bool IsActive() const
Definition CarlaActor.h:66
void SetActorLocalLocation(const FVector &Location, ETeleportType Teleport=ETeleportType::TeleportPhysics)
const FActorInfo * GetActorInfo() const
Definition CarlaActor.h:101
TSharedPtr< FActorData > ActorData
Definition CarlaActor.h:476
IdType GetActorId() const
Definition CarlaActor.h:81
virtual ~FCarlaActor()
Definition CarlaActor.h:52
virtual ECarlaServerResponse EnableActorConstantVelocity(const FVector &)
Definition CarlaActor.h:234
void BuildActorData()
FTransform GetActorLocalTransform() const
virtual ECarlaServerResponse SetWheelSteerDirection(const EVehicleWheelLocation &, float)
Definition CarlaActor.h:279
virtual ECarlaServerResponse EnableCarSim(const FString &)
Definition CarlaActor.h:336
ECarlaServerResponse SetActorTargetVelocity(const FVector &Velocity)
ECarlaServerResponse AddActorForce(const FVector &Force)
FCarlaActor()=default
virtual ECarlaServerResponse BlendPose(float Blend)
Definition CarlaActor.h:419
virtual ECarlaServerResponse ShowVehicleDebugTelemetry(bool)
Definition CarlaActor.h:331
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bEnabled)
virtual ECarlaServerResponse EnableChronoPhysics(uint64_t, float, const FString &, const FString &, const FString &, const FString &)
Definition CarlaActor.h:346
void WakeActorUp(UCarlaEpisode *CarlaEpisode)
ECarlaServerResponse AddActorAngularImpulse(const FVector &AngularInpulse)
virtual ECarlaServerResponse SetTrafficLightState(const ETrafficLightState &)
Definition CarlaActor.h:359
const TArray< IdType > & GetChildren() const
Definition CarlaActor.h:136
void PutActorToSleep(UCarlaEpisode *CarlaEpisode)
const AActor * GetActor() const
Definition CarlaActor.h:96
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
A simulation episode.
Maps a controller from OpenDrive.
A view over an actor and its properties.
Definition ActorInfo.h:23