CARLA
AIControllerFactory.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 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 #include "Carla.h"
9 
12 
13 TArray<FActorDefinition> AAIControllerFactory::GetDefinitions()
14 {
15  using ABFL = UActorBlueprintFunctionLibrary;
16  auto WalkerController = ABFL::MakeGenericDefinition(
17  TEXT("controller"),
18  TEXT("ai"),
19  TEXT("walker"));
20  WalkerController.Class = AWalkerAIController::StaticClass();
21  return { WalkerController };
22 }
23 
25  const FTransform &Transform,
26  const FActorDescription &Description)
27 {
28  auto *World = GetWorld();
29  if (World == nullptr)
30  {
31  UE_LOG(LogCarla, Error, TEXT("AAIControllerFactory: cannot spawn controller into an empty world."));
32  return {};
33  }
34 
35  FActorSpawnParameters SpawnParameters;
36  SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
37  auto *Controller = World->SpawnActor<AActor>(Description.Class, Transform, SpawnParameters);
38 
39  if (Controller == nullptr)
40  {
41  UE_LOG(LogCarla, Error, TEXT("AAIControllerFactory: spawn controller failed."));
42  }
43  return FActorSpawnResult{Controller};
44 }
TArray< FActorDefinition > GetDefinitions() final
Retrieve the list of actor definitions that this class is able to spawn.
TSubclassOf< AActor > Class
Class of the actor to be spawned.
A description of a Carla Actor with all its variation.
FActorSpawnResult SpawnActor(const FTransform &SpawnAtTransform, const FActorDescription &ActorDescription) final
Spawn an actor based on ActorDescription and Transform.
Result of an actor spawn function.
geom::Transform Transform
Definition: rpc/Transform.h:16