CARLA
 
载入中...
搜索中...
未找到
AIControllerFactory.cpp
浏览该文件的文档.
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
13TArray<FActorDefinition> AAIControllerFactory::GetDefinitions()
14{
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}
FActorSpawnResult SpawnActor(const FTransform &SpawnAtTransform, const FActorDescription &ActorDescription) final
Spawn an actor based on ActorDescription and Transform.
TArray< FActorDefinition > GetDefinitions() final
Retrieve the list of actor definitions that this class is able to spawn.
A description of a Carla Actor with all its variation.
TSubclassOf< AActor > Class
Class of the actor to be spawned.
Result of an actor spawn function.