Updated CarlaRecorder and CarlaReplayer to use new FCarlaActor interface for vehicles, walkers and sensors.
This commit is contained in:
parent
e2ebdf8d89
commit
84c5995509
|
@ -803,7 +803,7 @@ ECarlaServerResponse FVehicleActor::GetVehicleControl(FVehicleControl& VehicleCo
|
||||||
return ECarlaServerResponse::Success;
|
return ECarlaServerResponse::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
ECarlaServerResponse FVehicleActor::SetActorAutopilot(bool bEnabled)
|
ECarlaServerResponse FVehicleActor::SetActorAutopilot(bool bEnabled, bool bKeepState)
|
||||||
{
|
{
|
||||||
if (IsDormant())
|
if (IsDormant())
|
||||||
{
|
{
|
||||||
|
@ -820,7 +820,7 @@ ECarlaServerResponse FVehicleActor::SetActorAutopilot(bool bEnabled)
|
||||||
{
|
{
|
||||||
return ECarlaServerResponse::AutoPilotNotSupported;
|
return ECarlaServerResponse::AutoPilotNotSupported;
|
||||||
}
|
}
|
||||||
Controller->SetAutopilot(bEnabled);
|
Controller->SetAutopilot(bEnabled, bKeepState);
|
||||||
}
|
}
|
||||||
return ECarlaServerResponse::Success;
|
return ECarlaServerResponse::Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,7 @@ public:
|
||||||
return ECarlaServerResponse::ActorTypeMismatch;
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetActorAutopilot(bool)
|
virtual ECarlaServerResponse SetActorAutopilot(bool, bool bKeepState = false)
|
||||||
{
|
{
|
||||||
return ECarlaServerResponse::ActorTypeMismatch;
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ public:
|
||||||
|
|
||||||
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl&) final;
|
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl&) final;
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetActorAutopilot(bool bEnabled) final;
|
virtual ECarlaServerResponse SetActorAutopilot(bool bEnabled, bool bKeepState = false) final;
|
||||||
|
|
||||||
virtual ECarlaServerResponse EnableCarSim(const FString& SimfilePath) final;
|
virtual ECarlaServerResponse EnableCarSim(const FString& SimfilePath) final;
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,11 @@ public:
|
||||||
return ActorDispatcher->GetActorRegistry();
|
return ActorDispatcher->GetActorRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FActorRegistry &GetActorRegistry()
|
||||||
|
{
|
||||||
|
return ActorDispatcher->GetActorRegistry();
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// -- Actor look up methods --------------------------------------------------
|
// -- Actor look up methods --------------------------------------------------
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
|
@ -201,21 +201,20 @@ void ACarlaRecorder::AddWalkerAnimation(FCarlaActor *CarlaActor)
|
||||||
void ACarlaRecorder::AddTrafficLightState(FCarlaActor *CarlaActor)
|
void ACarlaRecorder::AddTrafficLightState(FCarlaActor *CarlaActor)
|
||||||
{
|
{
|
||||||
check(CarlaActor != nullptr);
|
check(CarlaActor != nullptr);
|
||||||
|
// Todo: interface with FCarlaActor and UTrafficLightController
|
||||||
// get states
|
AActor *Actor = CarlaActor->GetActor();
|
||||||
UTrafficLightController* Controller =
|
if(Actor)
|
||||||
CarlaActor->GetTrafficLightController();
|
|
||||||
if (Controller != nullptr)
|
|
||||||
{
|
{
|
||||||
auto* Group = Controller->GetGroup();
|
// get states
|
||||||
if (Group)
|
auto TrafficLight = Cast<ATrafficLightBase>(Actor);
|
||||||
|
if (TrafficLight != nullptr)
|
||||||
{
|
{
|
||||||
AddState(CarlaRecorderStateTrafficLight
|
AddState(CarlaRecorderStateTrafficLight
|
||||||
{
|
{
|
||||||
CarlaActor->GetActorId(),
|
CarlaActor->GetActorId(),
|
||||||
Group->IsFrozen(),
|
TrafficLight->GetTimeIsFrozen(),
|
||||||
Controller->GetElapsedTime(),
|
TrafficLight->GetElapsedTime(),
|
||||||
static_cast<char>(Controller->GetCurrentState().State)
|
static_cast<char>(TrafficLight->GetTrafficLightState())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "Carla/Traffic/TrafficLightBase.h"
|
#include "Carla/Traffic/TrafficLightBase.h"
|
||||||
#include "Carla/Vehicle/CarlaWheeledVehicle.h"
|
#include "Carla/Vehicle/CarlaWheeledVehicle.h"
|
||||||
#include "Engine/StaticMeshActor.h"
|
#include "Engine/StaticMeshActor.h"
|
||||||
|
#include "Carla/Game/CarlaStatics.h"
|
||||||
|
#include "Carla/MapGen/LargeMapManager.h"
|
||||||
|
|
||||||
#include <compiler/disable-ue4-macros.h>
|
#include <compiler/disable-ue4-macros.h>
|
||||||
#include <carla/rpc/VehicleLightState.h>
|
#include <carla/rpc/VehicleLightState.h>
|
||||||
|
@ -38,16 +40,12 @@ std::pair<int, FCarlaActor*>CarlaReplayerHelper::TryToCreateReplayerActor(
|
||||||
{
|
{
|
||||||
check(Episode != nullptr);
|
check(Episode != nullptr);
|
||||||
|
|
||||||
FCarlaActor view_empty;
|
|
||||||
|
|
||||||
// check type of actor we need
|
// check type of actor we need
|
||||||
if (ActorDesc.Id.StartsWith("traffic."))
|
if (ActorDesc.Id.StartsWith("traffic."))
|
||||||
{
|
{
|
||||||
AActor *Actor = FindTrafficLightAt(Location);
|
FCarlaActor* CarlaActor = FindTrafficLightAt(Location);
|
||||||
if (Actor != nullptr)
|
if (CarlaActor != nullptr)
|
||||||
{
|
{
|
||||||
// actor found
|
|
||||||
FCarlaActor* CarlaActor = Episode->FindCarlaActor(Actor);
|
|
||||||
// reuse that actor
|
// reuse that actor
|
||||||
return std::pair<int, FCarlaActor*>(2, CarlaActor);
|
return std::pair<int, FCarlaActor*>(2, CarlaActor);
|
||||||
}
|
}
|
||||||
|
@ -85,6 +83,11 @@ std::pair<int, FCarlaActor*>CarlaReplayerHelper::TryToCreateReplayerActor(
|
||||||
// relocate
|
// relocate
|
||||||
FTransform Trans2(Rot, Location, FVector(1, 1, 1));
|
FTransform Trans2(Rot, Location, FVector(1, 1, 1));
|
||||||
Result.Value->GetActor()->SetActorTransform(Trans2, false, nullptr, ETeleportType::TeleportPhysics);
|
Result.Value->GetActor()->SetActorTransform(Trans2, false, nullptr, ETeleportType::TeleportPhysics);
|
||||||
|
ALargeMapManager * LargeMapManager = UCarlaStatics::GetLargeMapManager(Episode->GetWorld());
|
||||||
|
if (LargeMapManager)
|
||||||
|
{
|
||||||
|
LargeMapManager->OnActorSpawned(*Result.Value);
|
||||||
|
}
|
||||||
return std::pair<int, FCarlaActor*>(1, Result.Value);
|
return std::pair<int, FCarlaActor*>(1, Result.Value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -100,7 +103,7 @@ std::pair<int, FCarlaActor*>CarlaReplayerHelper::TryToCreateReplayerActor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AActor *CarlaReplayerHelper::FindTrafficLightAt(FVector Location)
|
FCarlaActor *CarlaReplayerHelper::FindTrafficLightAt(FVector Location)
|
||||||
{
|
{
|
||||||
check(Episode != nullptr);
|
check(Episode != nullptr);
|
||||||
auto World = Episode->GetWorld();
|
auto World = Episode->GetWorld();
|
||||||
|
@ -111,19 +114,22 @@ AActor *CarlaReplayerHelper::FindTrafficLightAt(FVector Location)
|
||||||
int y = static_cast<int>(Location.Y);
|
int y = static_cast<int>(Location.Y);
|
||||||
int z = static_cast<int>(Location.Z);
|
int z = static_cast<int>(Location.Z);
|
||||||
|
|
||||||
// search an "traffic." actor at that position
|
const FActorRegistry &Registry = Episode->GetActorRegistry();
|
||||||
for (TActorIterator<ATrafficSignBase> It(World); It; ++It)
|
// through all actors in registry
|
||||||
|
for (auto It = Registry.begin(); It != Registry.end(); ++It)
|
||||||
{
|
{
|
||||||
ATrafficSignBase *Actor = *It;
|
FCarlaActor* CarlaActor = It.Value().Get();
|
||||||
check(Actor != nullptr);
|
if(CarlaActor->GetActorType() == FCarlaActor::ActorType::TrafficLight)
|
||||||
FVector vec = Actor->GetTransform().GetTranslation();
|
|
||||||
int x2 = static_cast<int>(vec.X);
|
|
||||||
int y2 = static_cast<int>(vec.Y);
|
|
||||||
int z2 = static_cast<int>(vec.Z);
|
|
||||||
if ((x2 == x) && (y2 == y) && (z2 == z))
|
|
||||||
{
|
{
|
||||||
// actor found
|
FVector vec = CarlaActor->GetActorGlobalLocation();
|
||||||
return static_cast<AActor *>(Actor);
|
int x2 = static_cast<int>(vec.X);
|
||||||
|
int y2 = static_cast<int>(vec.Y);
|
||||||
|
int z2 = static_cast<int>(vec.Z);
|
||||||
|
if ((x2 == x) && (y2 == y) && (z2 == z))
|
||||||
|
{
|
||||||
|
// actor found
|
||||||
|
return CarlaActor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// actor not found
|
// actor not found
|
||||||
|
@ -131,41 +137,34 @@ AActor *CarlaReplayerHelper::FindTrafficLightAt(FVector Location)
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable / disable physics for an actor
|
// enable / disable physics for an actor
|
||||||
bool CarlaReplayerHelper::SetActorSimulatePhysics(const FCarlaActor* CarlaActor, bool bEnabled)
|
bool CarlaReplayerHelper::SetActorSimulatePhysics(FCarlaActor* CarlaActor, bool bEnabled)
|
||||||
{
|
{
|
||||||
if (!CarlaActor)
|
if (!CarlaActor)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto RootComponent = Cast<UPrimitiveComponent>(CarlaActor->GetActor()->GetRootComponent());
|
ECarlaServerResponse Response =
|
||||||
if (RootComponent == nullptr)
|
CarlaActor->SetActorSimulatePhysics(bEnabled);
|
||||||
|
if (Response != ECarlaServerResponse::Success)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RootComponent->SetSimulatePhysics(bEnabled);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable / disable autopilot for an actor
|
// enable / disable autopilot for an actor
|
||||||
bool CarlaReplayerHelper::SetActorAutopilot(const FCarlaActor* CarlaActor, bool bEnabled, bool bKeepState)
|
bool CarlaReplayerHelper::SetActorAutopilot(FCarlaActor* CarlaActor, bool bEnabled, bool bKeepState)
|
||||||
{
|
{
|
||||||
if (!CarlaActor)
|
if (!CarlaActor)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto Vehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
|
ECarlaServerResponse Response =
|
||||||
if (Vehicle == nullptr)
|
CarlaActor->SetActorAutopilot(bEnabled, bKeepState);
|
||||||
|
if (Response != ECarlaServerResponse::Success)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto Controller = Cast<AWheeledVehicleAIController>(Vehicle->GetController());
|
|
||||||
if (Controller == nullptr)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Controller->SetAutopilot(bEnabled, bKeepState);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,9 +222,9 @@ std::pair<int, uint32_t> CarlaReplayerHelper::ProcessReplayerEventAdd(
|
||||||
SetActorSimulatePhysics(result.second, true);
|
SetActorSimulatePhysics(result.second, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return std::make_pair(result.first, result.second->GetActorId());
|
||||||
}
|
}
|
||||||
|
return std::make_pair(result.first, 0);
|
||||||
return std::make_pair(result.first, result.second->GetActorId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// replay event for removing actor
|
// replay event for removing actor
|
||||||
|
@ -265,10 +264,10 @@ bool CarlaReplayerHelper::ProcessReplayerEventParent(uint32_t ChildId, uint32_t
|
||||||
bool CarlaReplayerHelper::ProcessReplayerPosition(CarlaRecorderPosition Pos1, CarlaRecorderPosition Pos2, double Per, double DeltaTime)
|
bool CarlaReplayerHelper::ProcessReplayerPosition(CarlaRecorderPosition Pos1, CarlaRecorderPosition Pos2, double Per, double DeltaTime)
|
||||||
{
|
{
|
||||||
check(Episode != nullptr);
|
check(Episode != nullptr);
|
||||||
AActor *Actor = Episode->FindCarlaActor(Pos1.DatabaseId)->GetActor();
|
FCarlaActor* CarlaActor = Episode->FindCarlaActor(Pos1.DatabaseId);
|
||||||
FVector Location;
|
FVector Location;
|
||||||
FRotator Rotation;
|
FRotator Rotation;
|
||||||
if (Actor && !Actor->IsPendingKill())
|
if(CarlaActor)
|
||||||
{
|
{
|
||||||
// check to assign first position or interpolate between both
|
// check to assign first position or interpolate between both
|
||||||
if (Per == 0.0)
|
if (Per == 0.0)
|
||||||
|
@ -285,7 +284,7 @@ bool CarlaReplayerHelper::ProcessReplayerPosition(CarlaRecorderPosition Pos1, Ca
|
||||||
}
|
}
|
||||||
// set new transform
|
// set new transform
|
||||||
FTransform Trans(Rotation, Location, FVector(1, 1, 1));
|
FTransform Trans(Rotation, Location, FVector(1, 1, 1));
|
||||||
Actor->SetActorTransform(Trans, false, nullptr, ETeleportType::None);
|
CarlaActor->SetActorGlobalTransform(Trans, ETeleportType::None);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -299,7 +298,10 @@ bool CarlaReplayerHelper::SetCameraPosition(uint32_t Id, FVector Offset, FQuat R
|
||||||
// get specator pawn
|
// get specator pawn
|
||||||
APawn *Spectator = Episode->GetSpectatorPawn();
|
APawn *Spectator = Episode->GetSpectatorPawn();
|
||||||
// get the actor to follow
|
// get the actor to follow
|
||||||
AActor *Actor = Episode->FindCarlaActor(Id)->GetActor();
|
FCarlaActor* CarlaActor = Episode->FindCarlaActor(Id);
|
||||||
|
if (!CarlaActor)
|
||||||
|
return false;
|
||||||
|
AActor *Actor = CarlaActor->GetActor();
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (!Spectator || !Actor)
|
if (!Spectator || !Actor)
|
||||||
|
@ -317,6 +319,7 @@ bool CarlaReplayerHelper::SetCameraPosition(uint32_t Id, FVector Offset, FQuat R
|
||||||
bool CarlaReplayerHelper::ProcessReplayerStateTrafficLight(CarlaRecorderStateTrafficLight State)
|
bool CarlaReplayerHelper::ProcessReplayerStateTrafficLight(CarlaRecorderStateTrafficLight State)
|
||||||
{
|
{
|
||||||
check(Episode != nullptr);
|
check(Episode != nullptr);
|
||||||
|
// Todo: interface with FCarlaActor and UTrafficLightController
|
||||||
AActor *Actor = Episode->FindCarlaActor(State.DatabaseId)->GetActor();
|
AActor *Actor = Episode->FindCarlaActor(State.DatabaseId)->GetActor();
|
||||||
if (Actor && !Actor->IsPendingKill())
|
if (Actor && !Actor->IsPendingKill())
|
||||||
{
|
{
|
||||||
|
@ -336,15 +339,9 @@ bool CarlaReplayerHelper::ProcessReplayerStateTrafficLight(CarlaRecorderStateTra
|
||||||
void CarlaReplayerHelper::ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Vehicle)
|
void CarlaReplayerHelper::ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Vehicle)
|
||||||
{
|
{
|
||||||
check(Episode != nullptr);
|
check(Episode != nullptr);
|
||||||
AActor *Actor = Episode->FindCarlaActor(Vehicle.DatabaseId)->GetActor();
|
FCarlaActor *CarlaActor = Episode->FindCarlaActor(Vehicle.DatabaseId);
|
||||||
if (Actor && !Actor->IsPendingKill())
|
if (CarlaActor)
|
||||||
{
|
{
|
||||||
auto Veh = Cast<ACarlaWheeledVehicle>(Actor);
|
|
||||||
if (Veh == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FVehicleControl Control;
|
FVehicleControl Control;
|
||||||
Control.Throttle = Vehicle.Throttle;
|
Control.Throttle = Vehicle.Throttle;
|
||||||
Control.Steer = Vehicle.Steering;
|
Control.Steer = Vehicle.Steering;
|
||||||
|
@ -353,7 +350,7 @@ void CarlaReplayerHelper::ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Ve
|
||||||
Control.bReverse = (Vehicle.Gear < 0);
|
Control.bReverse = (Vehicle.Gear < 0);
|
||||||
Control.Gear = Vehicle.Gear;
|
Control.Gear = Vehicle.Gear;
|
||||||
Control.bManualGearShift = false;
|
Control.bManualGearShift = false;
|
||||||
Veh->ApplyVehicleControl(Control, EVehicleInputPriority::User);
|
CarlaActor->ApplyControlToVehicle(Control, EVehicleInputPriority::User);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,17 +358,11 @@ void CarlaReplayerHelper::ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Ve
|
||||||
void CarlaReplayerHelper::ProcessReplayerLightVehicle(CarlaRecorderLightVehicle LightVehicle)
|
void CarlaReplayerHelper::ProcessReplayerLightVehicle(CarlaRecorderLightVehicle LightVehicle)
|
||||||
{
|
{
|
||||||
check(Episode != nullptr);
|
check(Episode != nullptr);
|
||||||
AActor *Actor = Episode->FindCarlaActor(LightVehicle.DatabaseId)->GetActor();
|
FCarlaActor * CarlaActor = Episode->FindCarlaActor(LightVehicle.DatabaseId);
|
||||||
if (Actor && !Actor->IsPendingKill())
|
if (CarlaActor)
|
||||||
{
|
{
|
||||||
auto Veh = Cast<ACarlaWheeledVehicle>(Actor);
|
|
||||||
if (Veh == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
carla::rpc::VehicleLightState LightState(LightVehicle.State);
|
carla::rpc::VehicleLightState LightState(LightVehicle.State);
|
||||||
Veh->SetVehicleLightState(FVehicleLightState(LightState));
|
CarlaActor->SetVehicleLightState(FVehicleLightState(LightState));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +401,7 @@ bool CarlaReplayerHelper::ProcessReplayerFinish(bool bApplyAutopilot, bool bIgno
|
||||||
const FActorRegistry& Registry = Episode->GetActorRegistry();
|
const FActorRegistry& Registry = Episode->GetActorRegistry();
|
||||||
for (auto& It : Registry)
|
for (auto& It : Registry)
|
||||||
{
|
{
|
||||||
const FCarlaActor* CarlaActor = It.Value.Get();
|
FCarlaActor* CarlaActor = It.Value.Get();
|
||||||
|
|
||||||
// enable physics only on vehicles
|
// enable physics only on vehicles
|
||||||
switch (CarlaActor->GetActorType())
|
switch (CarlaActor->GetActorType())
|
||||||
|
@ -452,21 +443,13 @@ bool CarlaReplayerHelper::ProcessReplayerFinish(bool bApplyAutopilot, bool bIgno
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CarlaReplayerHelper::SetActorVelocity(const FCarlaActor *CarlaActor, FVector Velocity)
|
void CarlaReplayerHelper::SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity)
|
||||||
{
|
{
|
||||||
if (!CarlaActor)
|
if (!CarlaActor)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto RootComponent = Cast<UPrimitiveComponent>(CarlaActor->GetActor()->GetRootComponent());
|
CarlaActor->SetActorTargetVelocity(Velocity);
|
||||||
if (RootComponent == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RootComponent->SetPhysicsLinearVelocity(
|
|
||||||
Velocity,
|
|
||||||
false,
|
|
||||||
"None");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the animation speed for walkers
|
// set the animation speed for walkers
|
||||||
|
@ -474,25 +457,13 @@ void CarlaReplayerHelper::SetWalkerSpeed(uint32_t ActorId, float Speed)
|
||||||
{
|
{
|
||||||
check(Episode != nullptr);
|
check(Episode != nullptr);
|
||||||
FCarlaActor * CarlaActor = Episode->FindCarlaActor(ActorId);
|
FCarlaActor * CarlaActor = Episode->FindCarlaActor(ActorId);
|
||||||
AActor *Actor = nullptr;
|
if (!CarlaActor)
|
||||||
if (CarlaActor)
|
|
||||||
{
|
{
|
||||||
Actor = CarlaActor->GetActor();
|
return;
|
||||||
}
|
|
||||||
if (Actor && !Actor->IsPendingKill())
|
|
||||||
{
|
|
||||||
auto Wal = Cast<APawn>(Actor);
|
|
||||||
if (Wal)
|
|
||||||
{
|
|
||||||
auto Controller = Cast<AWalkerController>(Wal->GetController());
|
|
||||||
if (Controller != nullptr)
|
|
||||||
{
|
|
||||||
FWalkerControl Control;
|
|
||||||
Control.Speed = Speed;
|
|
||||||
Controller->ApplyWalkerControl(Control);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
FWalkerControl Control;
|
||||||
|
Control.Speed = Speed;
|
||||||
|
CarlaActor->ApplyControlToWalker(Control);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CarlaReplayerHelper::RemoveStaticProps()
|
void CarlaReplayerHelper::RemoveStaticProps()
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
bool SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation);
|
bool SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation);
|
||||||
|
|
||||||
// set the velocity of the actor
|
// set the velocity of the actor
|
||||||
void SetActorVelocity(const FCarlaActor *CarlaActor, FVector Velocity);
|
void SetActorVelocity(FCarlaActor *CarlaActor, FVector Velocity);
|
||||||
|
|
||||||
// set the animation speed for walkers
|
// set the animation speed for walkers
|
||||||
void SetWalkerSpeed(uint32_t ActorId, float Speed);
|
void SetWalkerSpeed(uint32_t ActorId, float Speed);
|
||||||
|
@ -89,10 +89,10 @@ private:
|
||||||
uint32_t DesiredId,
|
uint32_t DesiredId,
|
||||||
bool SpawnSensors);
|
bool SpawnSensors);
|
||||||
|
|
||||||
AActor *FindTrafficLightAt(FVector Location);
|
FCarlaActor* FindTrafficLightAt(FVector Location);
|
||||||
|
|
||||||
// enable / disable physics for an actor
|
// enable / disable physics for an actor
|
||||||
bool SetActorSimulatePhysics(const FCarlaActor *CarlaActor, bool bEnabled);
|
bool SetActorSimulatePhysics(FCarlaActor *CarlaActor, bool bEnabled);
|
||||||
// enable / disable autopilot for an actor
|
// enable / disable autopilot for an actor
|
||||||
bool SetActorAutopilot(const FCarlaActor *CarlaActor, bool bEnabled, bool bKeepState = false);
|
bool SetActorAutopilot(FCarlaActor *CarlaActor, bool bEnabled, bool bKeepState = false);
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,6 +90,7 @@ bool UTrafficLightController::IsCycleFinished() const
|
||||||
|
|
||||||
void UTrafficLightController::SetTrafficLightsState(ETrafficLightState NewState)
|
void UTrafficLightController::SetTrafficLightsState(ETrafficLightState NewState)
|
||||||
{
|
{
|
||||||
|
SetCurrentLightState(NewState);
|
||||||
for(auto *Light : TrafficLights)
|
for(auto *Light : TrafficLights)
|
||||||
{
|
{
|
||||||
Light->SetLightState(NewState);
|
Light->SetLightState(NewState);
|
||||||
|
|
|
@ -120,6 +120,15 @@ public:
|
||||||
|
|
||||||
const ATrafficLightGroup* GetGroup() const;
|
const ATrafficLightGroup* GetGroup() const;
|
||||||
|
|
||||||
|
ETrafficLightState GetCurrentLightState() const
|
||||||
|
{
|
||||||
|
return CurrentLightState;
|
||||||
|
}
|
||||||
|
void SetCurrentLightState(ETrafficLightState NewState)
|
||||||
|
{
|
||||||
|
CurrentLightState = NewState;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void SetStateTime(const ETrafficLightState State, float NewTime);
|
void SetStateTime(const ETrafficLightState State, float NewTime);
|
||||||
|
@ -153,4 +162,5 @@ private:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
float ElapsedTime = 0;
|
float ElapsedTime = 0;
|
||||||
|
|
||||||
|
ETrafficLightState CurrentLightState = ETrafficLightState::Green;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue