Added functions to interface the FCarlaActor object with recorder. Started adapting recorder to new FCarlaActor object.
This commit is contained in:
parent
3b8fda28db
commit
bd1725b2d2
|
@ -183,7 +183,10 @@ TSharedPtr<FCarlaActor> FActorRegistry::MakeCarlaActor(
|
||||||
}
|
}
|
||||||
auto Type = FActorRegistry_GetActorType(&Actor);
|
auto Type = FActorRegistry_GetActorType(&Actor);
|
||||||
TSharedPtr<FCarlaActor> CarlaActor =
|
TSharedPtr<FCarlaActor> CarlaActor =
|
||||||
FCarlaActor::ConstructCarlaActor(Id, &Actor, std::move(Info), Type, InState);
|
FCarlaActor::ConstructCarlaActor(
|
||||||
|
Id, &Actor,
|
||||||
|
std::move(Info), Type,
|
||||||
|
InState, Actor.GetWorld());
|
||||||
return CarlaActor;
|
return CarlaActor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "Carla/Vehicle/MovementComponents/CarSimManagerComponent.h"
|
#include "Carla/Vehicle/MovementComponents/CarSimManagerComponent.h"
|
||||||
#include "Carla/Vehicle/MovementComponents/ChronoMovementComponent.h"
|
#include "Carla/Vehicle/MovementComponents/ChronoMovementComponent.h"
|
||||||
#include "Carla/Traffic/TrafficLightBase.h"
|
#include "Carla/Traffic/TrafficLightBase.h"
|
||||||
|
#include "Carla/Game/CarlaStatics.h"
|
||||||
|
|
||||||
#include <compiler/disable-ue4-macros.h>
|
#include <compiler/disable-ue4-macros.h>
|
||||||
#include "carla/rpc/LabelledPoint.h"
|
#include "carla/rpc/LabelledPoint.h"
|
||||||
|
@ -37,19 +38,22 @@ FCarlaActor::FCarlaActor(
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState)
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World)
|
||||||
: TheActor(Actor),
|
: TheActor(Actor),
|
||||||
Info(std::move(Info)),
|
Info(std::move(Info)),
|
||||||
Id(ActorId),
|
Id(ActorId),
|
||||||
State(InState)
|
State(InState),
|
||||||
|
World(World)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
FVehicleActor::FVehicleActor(
|
FVehicleActor::FVehicleActor(
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState)
|
carla::rpc::ActorState InState,
|
||||||
: FCarlaActor(ActorId, Actor, Info, InState)
|
UWorld* World)
|
||||||
|
: FCarlaActor(ActorId, Actor, Info, InState, World)
|
||||||
{
|
{
|
||||||
Type = ActorType::Vehicle;
|
Type = ActorType::Vehicle;
|
||||||
ActorData = MakeShared<FVehicleData>();
|
ActorData = MakeShared<FVehicleData>();
|
||||||
|
@ -58,8 +62,9 @@ FSensorActor::FSensorActor(
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState)
|
carla::rpc::ActorState InState,
|
||||||
: FCarlaActor(ActorId, Actor, Info, InState)
|
UWorld* World)
|
||||||
|
: FCarlaActor(ActorId, Actor, Info, InState, World)
|
||||||
{
|
{
|
||||||
Type = ActorType::Sensor;
|
Type = ActorType::Sensor;
|
||||||
ActorData = MakeShared<FActorSensorData>();
|
ActorData = MakeShared<FActorSensorData>();
|
||||||
|
@ -68,8 +73,9 @@ FTrafficSignActor::FTrafficSignActor(
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState)
|
carla::rpc::ActorState InState,
|
||||||
: FCarlaActor(ActorId, Actor, Info, InState)
|
UWorld* World)
|
||||||
|
: FCarlaActor(ActorId, Actor, Info, InState, World)
|
||||||
{
|
{
|
||||||
Type = ActorType::TrafficSign;
|
Type = ActorType::TrafficSign;
|
||||||
ActorData = MakeShared<FTrafficSignData>();
|
ActorData = MakeShared<FTrafficSignData>();
|
||||||
|
@ -78,8 +84,9 @@ FTrafficLightActor::FTrafficLightActor(
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState)
|
carla::rpc::ActorState InState,
|
||||||
: FCarlaActor(ActorId, Actor, Info, InState)
|
UWorld* World)
|
||||||
|
: FCarlaActor(ActorId, Actor, Info, InState, World)
|
||||||
{
|
{
|
||||||
Type = ActorType::TrafficLight;
|
Type = ActorType::TrafficLight;
|
||||||
ActorData = MakeShared<FTrafficLightData>();
|
ActorData = MakeShared<FTrafficLightData>();
|
||||||
|
@ -88,8 +95,9 @@ FWalkerActor::FWalkerActor(
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState)
|
carla::rpc::ActorState InState,
|
||||||
: FCarlaActor(ActorId, Actor, Info, InState)
|
UWorld* World)
|
||||||
|
: FCarlaActor(ActorId, Actor, Info, InState, World)
|
||||||
{
|
{
|
||||||
Type = ActorType::Walker;
|
Type = ActorType::Walker;
|
||||||
ActorData = MakeShared<FWalkerData>();
|
ActorData = MakeShared<FWalkerData>();
|
||||||
|
@ -98,8 +106,9 @@ FOtherActor::FOtherActor(
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState)
|
carla::rpc::ActorState InState,
|
||||||
: FCarlaActor(ActorId, Actor, Info, InState)
|
UWorld* World)
|
||||||
|
: FCarlaActor(ActorId, Actor, Info, InState, World)
|
||||||
{
|
{
|
||||||
Type = ActorType::Other;
|
Type = ActorType::Other;
|
||||||
ActorData = MakeShared<FActorData>();
|
ActorData = MakeShared<FActorData>();
|
||||||
|
@ -110,27 +119,28 @@ TSharedPtr<FCarlaActor> FCarlaActor::ConstructCarlaActor(
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
ActorType Type,
|
ActorType Type,
|
||||||
carla::rpc::ActorState InState)
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World)
|
||||||
{
|
{
|
||||||
switch(Type)
|
switch(Type)
|
||||||
{
|
{
|
||||||
case ActorType::TrafficSign:
|
case ActorType::TrafficSign:
|
||||||
return MakeShared<FTrafficSignActor>(ActorId, Actor, std::move(Info), InState);
|
return MakeShared<FTrafficSignActor>(ActorId, Actor, std::move(Info), InState, World);
|
||||||
break;
|
break;
|
||||||
case ActorType::TrafficLight:
|
case ActorType::TrafficLight:
|
||||||
return MakeShared<FTrafficLightActor>(ActorId, Actor, std::move(Info), InState);
|
return MakeShared<FTrafficLightActor>(ActorId, Actor, std::move(Info), InState, World);
|
||||||
break;
|
break;
|
||||||
case ActorType::Vehicle:
|
case ActorType::Vehicle:
|
||||||
return MakeShared<FVehicleActor>(ActorId, Actor, std::move(Info), InState);
|
return MakeShared<FVehicleActor>(ActorId, Actor, std::move(Info), InState, World);
|
||||||
break;
|
break;
|
||||||
case ActorType::Walker:
|
case ActorType::Walker:
|
||||||
return MakeShared<FWalkerActor>(ActorId, Actor, std::move(Info), InState);
|
return MakeShared<FWalkerActor>(ActorId, Actor, std::move(Info), InState, World);
|
||||||
break;
|
break;
|
||||||
case ActorType::Sensor:
|
case ActorType::Sensor:
|
||||||
return MakeShared<FSensorActor>(ActorId, Actor, std::move(Info), InState);
|
return MakeShared<FSensorActor>(ActorId, Actor, std::move(Info), InState, World);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return MakeShared<FOtherActor>(ActorId, Actor, std::move(Info), InState);
|
return MakeShared<FOtherActor>(ActorId, Actor, std::move(Info), InState, World);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,11 +171,100 @@ void FCarlaActor::WakeActorUp(UCarlaEpisode* CarlaEpisode)
|
||||||
ActorData->RestoreActorData(TheActor, CarlaEpisode);
|
ActorData->RestoreActorData(TheActor, CarlaEpisode);
|
||||||
}
|
}
|
||||||
|
|
||||||
ECarlaServerResponse FCarlaActor::SetActorLocation(const FVector& Location, ETeleportType TeleportType)
|
FTransform FCarlaActor::GetActorLocalTransform() const
|
||||||
{
|
{
|
||||||
if (IsDormant())
|
if (IsDormant())
|
||||||
{
|
{
|
||||||
ActorData->Location = FDVector(Location);
|
FTransform Transform = FTransform(
|
||||||
|
ActorData->Rotation,
|
||||||
|
ActorData->Location.ToFVector(),
|
||||||
|
ActorData->Scale);
|
||||||
|
ALargeMapManager* LargeMap =
|
||||||
|
UCarlaStatics::GetLargeMapManager(World);
|
||||||
|
if (LargeMap)
|
||||||
|
{
|
||||||
|
Transform = LargeMap->GlobalToLocalTransform(Transform);
|
||||||
|
}
|
||||||
|
return Transform;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GetActor()->GetActorTransform();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FTransform FCarlaActor::GetActorGlobalTransform() const
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
return FTransform(
|
||||||
|
ActorData->Rotation,
|
||||||
|
ActorData->Location.ToFVector(),
|
||||||
|
ActorData->Scale);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FTransform Transform = GetActor()->GetActorTransform();
|
||||||
|
ALargeMapManager* LargeMap =
|
||||||
|
UCarlaStatics::GetLargeMapManager(World);
|
||||||
|
if (LargeMap)
|
||||||
|
{
|
||||||
|
Transform = LargeMap->LocalToGlobalTransform(Transform);
|
||||||
|
}
|
||||||
|
return Transform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector FCarlaActor::GetActorLocalLocation() const
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
FVector Location = ActorData->Location.ToFVector();
|
||||||
|
ALargeMapManager* LargeMap =
|
||||||
|
UCarlaStatics::GetLargeMapManager(World);
|
||||||
|
if (LargeMap)
|
||||||
|
{
|
||||||
|
Location = LargeMap->GlobalToLocalLocation(Location);
|
||||||
|
}
|
||||||
|
return Location;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GetActor()->GetActorLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector FCarlaActor::GetActorGlobalLocation() const
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
return ActorData->Location.ToFVector();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FVector Location = GetActor()->GetActorLocation();
|
||||||
|
ALargeMapManager* LargeMap =
|
||||||
|
UCarlaStatics::GetLargeMapManager(World);
|
||||||
|
if (LargeMap)
|
||||||
|
{
|
||||||
|
Location = LargeMap->LocalToGlobalLocation(Location);
|
||||||
|
}
|
||||||
|
return Location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCarlaActor::SetActorLocalLocation(const FVector& Location, ETeleportType TeleportType)
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
FVector GlobalLocation = Location;
|
||||||
|
ALargeMapManager* LargeMap =
|
||||||
|
UCarlaStatics::GetLargeMapManager(World);
|
||||||
|
if (LargeMap)
|
||||||
|
{
|
||||||
|
GlobalLocation = LargeMap->LocalToGlobalLocation(GlobalLocation);
|
||||||
|
}
|
||||||
|
ActorData->Location = FDVector(GlobalLocation);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -175,16 +274,48 @@ ECarlaServerResponse FCarlaActor::SetActorLocation(const FVector& Location, ETel
|
||||||
nullptr,
|
nullptr,
|
||||||
TeleportType);
|
TeleportType);
|
||||||
}
|
}
|
||||||
return ECarlaServerResponse::Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ECarlaServerResponse FCarlaActor::SetActorTransform(const FTransform& Transform, ETeleportType TeleportType)
|
void FCarlaActor::SetActorGlobalLocation(
|
||||||
|
const FVector& Location, ETeleportType TeleportType)
|
||||||
{
|
{
|
||||||
if (IsDormant())
|
if (IsDormant())
|
||||||
{
|
{
|
||||||
ActorData->Location = FDVector(Transform.GetLocation());
|
ActorData->Location = FDVector(Location);;
|
||||||
ActorData->Rotation = Transform.GetRotation();
|
}
|
||||||
ActorData->Scale = Transform.GetScale3D();
|
else
|
||||||
|
{
|
||||||
|
FVector LocalLocation = Location;
|
||||||
|
ALargeMapManager* LargeMap =
|
||||||
|
UCarlaStatics::GetLargeMapManager(World);
|
||||||
|
if (LargeMap)
|
||||||
|
{
|
||||||
|
LocalLocation = LargeMap->GlobalToLocalLocation(Location);
|
||||||
|
}
|
||||||
|
GetActor()->SetActorRelativeLocation(
|
||||||
|
LocalLocation,
|
||||||
|
false,
|
||||||
|
nullptr,
|
||||||
|
TeleportType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FCarlaActor::SetActorLocalTransform(
|
||||||
|
const FTransform& Transform, ETeleportType TeleportType)
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
FTransform GlobalTransform = Transform;
|
||||||
|
ALargeMapManager* LargeMap =
|
||||||
|
UCarlaStatics::GetLargeMapManager(World);
|
||||||
|
if (LargeMap)
|
||||||
|
{
|
||||||
|
GlobalTransform =
|
||||||
|
LargeMap->LocalToGlobalTransform(GlobalTransform);
|
||||||
|
}
|
||||||
|
ActorData->Location = FDVector(GlobalTransform.GetLocation());
|
||||||
|
ActorData->Rotation = GlobalTransform.GetRotation();
|
||||||
|
ActorData->Scale = GlobalTransform.GetScale3D();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -194,7 +325,63 @@ ECarlaServerResponse FCarlaActor::SetActorTransform(const FTransform& Transform,
|
||||||
nullptr,
|
nullptr,
|
||||||
TeleportType);
|
TeleportType);
|
||||||
}
|
}
|
||||||
return ECarlaServerResponse::Success;
|
}
|
||||||
|
|
||||||
|
void FCarlaActor::SetActorGlobalTransform(
|
||||||
|
const FTransform& Transform, ETeleportType TeleportType)
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
ActorData->Location = FDVector(Transform.GetLocation());
|
||||||
|
ActorData->Rotation = Transform.GetRotation();
|
||||||
|
ActorData->Scale = Transform.GetScale3D();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FTransform LocalTransform = Transform;
|
||||||
|
ALargeMapManager* LargeMap =
|
||||||
|
UCarlaStatics::GetLargeMapManager(World);
|
||||||
|
if (LargeMap)
|
||||||
|
{
|
||||||
|
LocalTransform =
|
||||||
|
LargeMap->GlobalToLocalTransform(LocalTransform);
|
||||||
|
}
|
||||||
|
GetActor()->SetActorRelativeTransform(
|
||||||
|
LocalTransform,
|
||||||
|
false,
|
||||||
|
nullptr,
|
||||||
|
TeleportType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector FCarlaActor::GetActorVelocity() const
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
return ActorData->Velocity;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GetActor()->GetVelocity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector FCarlaActor::GetActorAngularVelocity() const
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
return ActorData->AngularVelocity;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UPrimitiveComponent* Primitive =
|
||||||
|
Cast<UPrimitiveComponent>(GetActor()->GetRootComponent());
|
||||||
|
if (Primitive)
|
||||||
|
{
|
||||||
|
return Primitive->GetPhysicsAngularVelocityInDegrees();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FVector();
|
||||||
}
|
}
|
||||||
|
|
||||||
ECarlaServerResponse FCarlaActor::SetActorTargetVelocity(const FVector& Velocity)
|
ECarlaServerResponse FCarlaActor::SetActorTargetVelocity(const FVector& Velocity)
|
||||||
|
@ -597,6 +784,25 @@ ECarlaServerResponse FVehicleActor::ApplyControlToVehicle(
|
||||||
return ECarlaServerResponse::Success;
|
return ECarlaServerResponse::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ECarlaServerResponse FVehicleActor::GetVehicleControl(FVehicleControl& VehicleControl)
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
FVehicleData* ActorData = GetActorData<FVehicleData>();
|
||||||
|
VehicleControl = ActorData->Control;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto Vehicle = Cast<ACarlaWheeledVehicle>(GetActor());
|
||||||
|
if (Vehicle == nullptr)
|
||||||
|
{
|
||||||
|
return ECarlaServerResponse::NotAVehicle;
|
||||||
|
}
|
||||||
|
VehicleControl = Vehicle->GetVehicleControl();
|
||||||
|
}
|
||||||
|
return ECarlaServerResponse::Success;
|
||||||
|
}
|
||||||
|
|
||||||
ECarlaServerResponse FVehicleActor::SetActorAutopilot(bool bEnabled)
|
ECarlaServerResponse FVehicleActor::SetActorAutopilot(bool bEnabled)
|
||||||
{
|
{
|
||||||
if (IsDormant())
|
if (IsDormant())
|
||||||
|
@ -712,6 +918,24 @@ ECarlaServerResponse FTrafficLightActor::SetTrafficLightState(const ETrafficLigh
|
||||||
return ECarlaServerResponse::Success;
|
return ECarlaServerResponse::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UTrafficLightController* FTrafficLightActor::GetTrafficLightController()
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
FTrafficLightData* ActorData = GetActorData<FTrafficLightData>();
|
||||||
|
return ActorData->Controller;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto TrafficLight = Cast<ATrafficLightBase>(GetActor());
|
||||||
|
if (TrafficLight == nullptr)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return TrafficLight->GetTrafficLightComponent()->GetController();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ECarlaServerResponse FTrafficLightActor::SetLightGreenTime(float time)
|
ECarlaServerResponse FTrafficLightActor::SetLightGreenTime(float time)
|
||||||
{
|
{
|
||||||
if (IsDormant())
|
if (IsDormant())
|
||||||
|
@ -806,16 +1030,24 @@ ECarlaServerResponse FTrafficLightActor::ResetTrafficLightGroup()
|
||||||
|
|
||||||
ECarlaServerResponse FWalkerActor::SetWalkerState(
|
ECarlaServerResponse FWalkerActor::SetWalkerState(
|
||||||
const FTransform& Transform,
|
const FTransform& Transform,
|
||||||
carla::rpc::WalkerControl WalkerControl,
|
carla::rpc::WalkerControl WalkerControl)
|
||||||
float Speed)
|
|
||||||
{
|
{
|
||||||
|
FVector NewLocation = Transform.GetLocation();
|
||||||
|
FVector CurrentLocation = GetActorGlobalLocation();
|
||||||
|
NewLocation.Z += 90.0f; // move point up because in Unreal walker is centered in the middle height
|
||||||
|
|
||||||
|
// if difference between Z position is small, then we keep current, otherwise we set the new one
|
||||||
|
// (to avoid Z fighting position and falling pedestrians)
|
||||||
|
if (NewLocation.Z - CurrentLocation.Z < 100.0f)
|
||||||
|
NewLocation.Z = CurrentLocation.Z;
|
||||||
|
|
||||||
|
FTransform NewTransform = Transform;
|
||||||
|
NewTransform.SetLocation(NewLocation);
|
||||||
|
SetActorGlobalTransform(NewTransform);
|
||||||
if (IsDormant())
|
if (IsDormant())
|
||||||
{
|
{
|
||||||
FWalkerData* WalkerData = GetActorData<FWalkerData>();
|
FWalkerData* WalkerData = GetActorData<FWalkerData>();
|
||||||
WalkerData->WalkerControl = WalkerControl;
|
WalkerData->WalkerControl = WalkerControl;
|
||||||
WalkerData->Location = FDVector(Transform.GetLocation());
|
|
||||||
WalkerData->Rotation = Transform.GetRotation();
|
|
||||||
WalkerData->Scale = Transform.GetScale3D();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -824,11 +1056,6 @@ ECarlaServerResponse FWalkerActor::SetWalkerState(
|
||||||
{
|
{
|
||||||
return ECarlaServerResponse::WalkerDead;
|
return ECarlaServerResponse::WalkerDead;
|
||||||
}
|
}
|
||||||
GetActor()->SetActorRelativeTransform(
|
|
||||||
Transform,
|
|
||||||
false,
|
|
||||||
nullptr,
|
|
||||||
ETeleportType::TeleportPhysics);
|
|
||||||
|
|
||||||
// apply walker speed
|
// apply walker speed
|
||||||
auto Pawn = Cast<APawn>(GetActor());
|
auto Pawn = Cast<APawn>(GetActor());
|
||||||
|
@ -846,6 +1073,38 @@ ECarlaServerResponse FWalkerActor::SetWalkerState(
|
||||||
return ECarlaServerResponse::Success;
|
return ECarlaServerResponse::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ECarlaServerResponse FWalkerActor::GetWalkerControl(
|
||||||
|
FWalkerControl& Control)
|
||||||
|
{
|
||||||
|
if (IsDormant())
|
||||||
|
{
|
||||||
|
FWalkerData* WalkerData = GetActorData<FWalkerData>();
|
||||||
|
Control = WalkerData->WalkerControl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto * Walker = Cast<AWalkerBase>(GetActor());
|
||||||
|
if (Walker && !Walker->bAlive)
|
||||||
|
{
|
||||||
|
return ECarlaServerResponse::WalkerDead;
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply walker speed
|
||||||
|
auto Pawn = Cast<APawn>(GetActor());
|
||||||
|
if (Pawn == nullptr)
|
||||||
|
{
|
||||||
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
|
}
|
||||||
|
auto Controller = Cast<AWalkerController>(Pawn->GetController());
|
||||||
|
if (Controller == nullptr)
|
||||||
|
{
|
||||||
|
return ECarlaServerResponse::WalkerIncompatibleController;
|
||||||
|
}
|
||||||
|
Control = Controller->GetWalkerControl();
|
||||||
|
}
|
||||||
|
return ECarlaServerResponse::Success;
|
||||||
|
}
|
||||||
|
|
||||||
ECarlaServerResponse FWalkerActor::SetActorSimulatePhysics(bool bEnabled)
|
ECarlaServerResponse FWalkerActor::SetActorSimulatePhysics(bool bEnabled)
|
||||||
{
|
{
|
||||||
if (IsDormant())
|
if (IsDormant())
|
||||||
|
|
|
@ -45,7 +45,8 @@ public:
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState);
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World);
|
||||||
|
|
||||||
virtual ~FCarlaActor() {};
|
virtual ~FCarlaActor() {};
|
||||||
|
|
||||||
|
@ -171,9 +172,34 @@ public:
|
||||||
// Actor function interface ----------------------
|
// Actor function interface ----------------------
|
||||||
|
|
||||||
// General functions
|
// General functions
|
||||||
ECarlaServerResponse SetActorLocation(const FVector& Location, ETeleportType Teleport);
|
|
||||||
|
|
||||||
ECarlaServerResponse SetActorTransform(const FTransform& Transform, ETeleportType Teleport);
|
FTransform GetActorLocalTransform() const;
|
||||||
|
|
||||||
|
FTransform GetActorGlobalTransform() const;
|
||||||
|
|
||||||
|
FVector GetActorLocalLocation() const;
|
||||||
|
|
||||||
|
FVector GetActorGlobalLocation() const;
|
||||||
|
|
||||||
|
void SetActorLocalLocation(
|
||||||
|
const FVector& Location,
|
||||||
|
ETeleportType Teleport = ETeleportType::TeleportPhysics);
|
||||||
|
|
||||||
|
void SetActorGlobalLocation(
|
||||||
|
const FVector& Location,
|
||||||
|
ETeleportType Teleport = ETeleportType::TeleportPhysics);
|
||||||
|
|
||||||
|
void SetActorLocalTransform(
|
||||||
|
const FTransform& Transform,
|
||||||
|
ETeleportType Teleport = ETeleportType::TeleportPhysics);
|
||||||
|
|
||||||
|
void SetActorGlobalTransform(
|
||||||
|
const FTransform& Transform,
|
||||||
|
ETeleportType Teleport = ETeleportType::TeleportPhysics);
|
||||||
|
|
||||||
|
FVector GetActorVelocity() const;
|
||||||
|
|
||||||
|
FVector GetActorAngularVelocity() const;
|
||||||
|
|
||||||
ECarlaServerResponse SetActorTargetVelocity(const FVector& Velocity);
|
ECarlaServerResponse SetActorTargetVelocity(const FVector& Velocity);
|
||||||
|
|
||||||
|
@ -242,6 +268,11 @@ public:
|
||||||
return ECarlaServerResponse::ActorTypeMismatch;
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl&)
|
||||||
|
{
|
||||||
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetActorAutopilot(bool)
|
virtual ECarlaServerResponse SetActorAutopilot(bool)
|
||||||
{
|
{
|
||||||
return ECarlaServerResponse::ActorTypeMismatch;
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
|
@ -270,6 +301,11 @@ public:
|
||||||
return ECarlaServerResponse::ActorTypeMismatch;
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual UTrafficLightController* GetTrafficLightController()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetLightGreenTime(float)
|
virtual ECarlaServerResponse SetLightGreenTime(float)
|
||||||
{
|
{
|
||||||
return ECarlaServerResponse::ActorTypeMismatch;
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
|
@ -290,8 +326,7 @@ public:
|
||||||
// Walker functions
|
// Walker functions
|
||||||
virtual ECarlaServerResponse SetWalkerState(
|
virtual ECarlaServerResponse SetWalkerState(
|
||||||
const FTransform& Transform,
|
const FTransform& Transform,
|
||||||
carla::rpc::WalkerControl WalkerControl,
|
carla::rpc::WalkerControl WalkerControl)
|
||||||
float Speed)
|
|
||||||
{
|
{
|
||||||
return ECarlaServerResponse::ActorTypeMismatch;
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
}
|
}
|
||||||
|
@ -301,6 +336,11 @@ public:
|
||||||
return ECarlaServerResponse::ActorTypeMismatch;
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl&)
|
||||||
|
{
|
||||||
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ECarlaServerResponse ApplyBoneControlToWalker(const FWalkerBoneControl&)
|
virtual ECarlaServerResponse ApplyBoneControlToWalker(const FWalkerBoneControl&)
|
||||||
{
|
{
|
||||||
return ECarlaServerResponse::ActorTypeMismatch;
|
return ECarlaServerResponse::ActorTypeMismatch;
|
||||||
|
@ -323,7 +363,8 @@ public:
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
ActorType Type,
|
ActorType Type,
|
||||||
carla::rpc::ActorState InState);
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -349,6 +390,8 @@ protected:
|
||||||
|
|
||||||
TSharedPtr<FActorData> ActorData = nullptr;
|
TSharedPtr<FActorData> ActorData = nullptr;
|
||||||
|
|
||||||
|
UWorld *World = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FVehicleActor : public FCarlaActor
|
class FVehicleActor : public FCarlaActor
|
||||||
|
@ -358,7 +401,8 @@ public:
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState);
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World);
|
||||||
|
|
||||||
virtual ECarlaServerResponse EnableActorConstantVelocity(const FVector& Velocity) final;
|
virtual ECarlaServerResponse EnableActorConstantVelocity(const FVector& Velocity) final;
|
||||||
|
|
||||||
|
@ -385,6 +429,8 @@ public:
|
||||||
virtual ECarlaServerResponse ApplyControlToVehicle(
|
virtual ECarlaServerResponse ApplyControlToVehicle(
|
||||||
const FVehicleControl&, const EVehicleInputPriority&) final;
|
const FVehicleControl&, const EVehicleInputPriority&) final;
|
||||||
|
|
||||||
|
virtual ECarlaServerResponse GetVehicleControl(FVehicleControl&) final;
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetActorAutopilot(bool bEnabled) final;
|
virtual ECarlaServerResponse SetActorAutopilot(bool bEnabled) final;
|
||||||
|
|
||||||
virtual ECarlaServerResponse EnableCarSim(const FString& SimfilePath) final;
|
virtual ECarlaServerResponse EnableCarSim(const FString& SimfilePath) final;
|
||||||
|
@ -404,7 +450,8 @@ public:
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState);
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -415,7 +462,8 @@ public:
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState);
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World);
|
||||||
};
|
};
|
||||||
|
|
||||||
class FTrafficLightActor : public FCarlaActor
|
class FTrafficLightActor : public FCarlaActor
|
||||||
|
@ -425,10 +473,13 @@ public:
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState);
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World);
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetTrafficLightState(const ETrafficLightState& State) final;
|
virtual ECarlaServerResponse SetTrafficLightState(const ETrafficLightState& State) final;
|
||||||
|
|
||||||
|
virtual UTrafficLightController* GetTrafficLightController() final;
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetLightGreenTime(float time) final;
|
virtual ECarlaServerResponse SetLightGreenTime(float time) final;
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetLightYellowTime(float time) final;
|
virtual ECarlaServerResponse SetLightYellowTime(float time) final;
|
||||||
|
@ -448,12 +499,12 @@ public:
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState);
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World);
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetWalkerState(
|
virtual ECarlaServerResponse SetWalkerState(
|
||||||
const FTransform& Transform,
|
const FTransform& Transform,
|
||||||
carla::rpc::WalkerControl WalkerControl,
|
carla::rpc::WalkerControl WalkerControl) final;
|
||||||
float Speed) final;
|
|
||||||
|
|
||||||
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bSimulatePhysics) final;
|
virtual ECarlaServerResponse SetActorSimulatePhysics(bool bSimulatePhysics) final;
|
||||||
|
|
||||||
|
@ -461,6 +512,8 @@ public:
|
||||||
|
|
||||||
virtual ECarlaServerResponse ApplyControlToWalker(const FWalkerControl&) final;
|
virtual ECarlaServerResponse ApplyControlToWalker(const FWalkerControl&) final;
|
||||||
|
|
||||||
|
virtual ECarlaServerResponse GetWalkerControl(FWalkerControl&) final;
|
||||||
|
|
||||||
virtual ECarlaServerResponse ApplyBoneControlToWalker(const FWalkerBoneControl&) final;
|
virtual ECarlaServerResponse ApplyBoneControlToWalker(const FWalkerBoneControl&) final;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -471,6 +524,7 @@ public:
|
||||||
IdType ActorId,
|
IdType ActorId,
|
||||||
AActor* Actor,
|
AActor* Actor,
|
||||||
TSharedPtr<const FActorInfo> Info,
|
TSharedPtr<const FActorInfo> Info,
|
||||||
carla::rpc::ActorState InState);
|
carla::rpc::ActorState InState,
|
||||||
|
UWorld* World);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -129,6 +129,10 @@ void ALargeMapManager::RegisterInitialObjects()
|
||||||
const FActorRegistry& ActorRegistry = CurrentEpisode->GetActorRegistry();
|
const FActorRegistry& ActorRegistry = CurrentEpisode->GetActorRegistry();
|
||||||
for (const auto& CarlaActorPair : ActorRegistry)
|
for (const auto& CarlaActorPair : ActorRegistry)
|
||||||
{
|
{
|
||||||
|
if (CarlaActorPair.Value->GetActorInfo()->Description.Id == "spectator")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
OnActorSpawned(*CarlaActorPair.Value.Get());
|
OnActorSpawned(*CarlaActorPair.Value.Get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,7 +516,7 @@ ULevelStreamingDynamic* ALargeMapManager::AddNewTile(FString TileName, FVector T
|
||||||
FString LongLevelPackageName = FPackageName::FilenameToLongPackageName(PackageFileName);
|
FString LongLevelPackageName = FPackageName::FilenameToLongPackageName(PackageFileName);
|
||||||
FString UniqueLevelPackageName = LongLevelPackageName + TileName;
|
FString UniqueLevelPackageName = LongLevelPackageName + TileName;
|
||||||
|
|
||||||
ULevelStreamingDynamic* StreamingLevel = NewObject<ULevelStreamingDynamic>(World, *TileName, RF_Transient);
|
ULevelStreamingDynamic* StreamingLevel = NewObject<ULevelStreamingDynamic>(World, *TileName);
|
||||||
check(StreamingLevel);
|
check(StreamingLevel);
|
||||||
|
|
||||||
StreamingLevel->SetWorldAssetByPackageName(*UniqueLevelPackageName);
|
StreamingLevel->SetWorldAssetByPackageName(*UniqueLevelPackageName);
|
||||||
|
|
|
@ -86,9 +86,9 @@ void ACarlaRecorder::Ticking(float DeltaSeconds)
|
||||||
// through all actors in registry
|
// through all actors in registry
|
||||||
for (auto It = Registry.begin(); It != Registry.end(); ++It)
|
for (auto It = Registry.begin(); It != Registry.end(); ++It)
|
||||||
{
|
{
|
||||||
FCarlaActor& View = *It.Value().Get();
|
FCarlaActor* View = It.Value().Get();
|
||||||
|
|
||||||
switch (View.GetActorType())
|
switch (View->GetActorType())
|
||||||
{
|
{
|
||||||
// save the transform for props
|
// save the transform for props
|
||||||
case FCarlaActor::ActorType::Other:
|
case FCarlaActor::ActorType::Other:
|
||||||
|
@ -145,41 +145,35 @@ void ACarlaRecorder::Disable(void)
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACarlaRecorder::AddActorPosition(FCarlaActor &View)
|
void ACarlaRecorder::AddActorPosition(FCarlaActor *CarlaActor)
|
||||||
{
|
{
|
||||||
AActor *Actor = View.GetActor();
|
check(CarlaActor != nullptr);
|
||||||
check(Actor != nullptr);
|
|
||||||
|
|
||||||
|
FTransform Transform = CarlaActor->GetActorGlobalTransform();
|
||||||
// get position of the vehicle
|
// get position of the vehicle
|
||||||
AddPosition(CarlaRecorderPosition
|
AddPosition(CarlaRecorderPosition
|
||||||
{
|
{
|
||||||
View.GetActorId(),
|
CarlaActor->GetActorId(),
|
||||||
Actor->GetTransform().GetTranslation(),
|
Transform.GetTranslation(),
|
||||||
Actor->GetTransform().GetRotation().Euler()
|
Transform.GetRotation().Euler()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACarlaRecorder::AddVehicleAnimation(FCarlaActor &View)
|
void ACarlaRecorder::AddVehicleAnimation(FCarlaActor *CarlaActor)
|
||||||
{
|
{
|
||||||
AActor *Actor = View.GetActor();
|
check(CarlaActor != nullptr);
|
||||||
check(Actor != nullptr);
|
|
||||||
|
|
||||||
if (Actor->IsPendingKill())
|
if (CarlaActor->IsPendingKill())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Vehicle = Cast<ACarlaWheeledVehicle>(Actor);
|
FVehicleControl Control;
|
||||||
if (Vehicle == nullptr)
|
CarlaActor->GetVehicleControl(Control);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FVehicleControl Control = Vehicle->GetVehicleControl();
|
|
||||||
|
|
||||||
// save
|
// save
|
||||||
CarlaRecorderAnimVehicle Record;
|
CarlaRecorderAnimVehicle Record;
|
||||||
Record.DatabaseId = View.GetActorId();
|
Record.DatabaseId = CarlaActor->GetActorId();
|
||||||
Record.Steering = Control.Steer;
|
Record.Steering = Control.Steer;
|
||||||
Record.Throttle = Control.Throttle;
|
Record.Throttle = Control.Throttle;
|
||||||
Record.Brake = Control.Brake;
|
Record.Brake = Control.Brake;
|
||||||
|
@ -188,112 +182,81 @@ void ACarlaRecorder::AddVehicleAnimation(FCarlaActor &View)
|
||||||
AddAnimVehicle(Record);
|
AddAnimVehicle(Record);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACarlaRecorder::AddWalkerAnimation(FCarlaActor &View)
|
void ACarlaRecorder::AddWalkerAnimation(FCarlaActor *CarlaActor)
|
||||||
{
|
{
|
||||||
AActor *Actor = View.GetActor();
|
check(CarlaActor != nullptr);
|
||||||
check(Actor != nullptr);
|
|
||||||
|
|
||||||
if (!Actor->IsPendingKill())
|
if (!CarlaActor->IsPendingKill())
|
||||||
{
|
{
|
||||||
// check to set speed in walkers
|
FWalkerControl Control;
|
||||||
auto Walker = Cast<APawn>(Actor);
|
CarlaActor->GetWalkerControl(Control);
|
||||||
if (Walker)
|
AddAnimWalker(CarlaRecorderAnimWalker
|
||||||
{
|
{
|
||||||
auto Controller = Cast<AWalkerController>(Walker->GetController());
|
CarlaActor->GetActorId(),
|
||||||
if (Controller != nullptr)
|
Control.Speed
|
||||||
{
|
|
||||||
AddAnimWalker(CarlaRecorderAnimWalker
|
|
||||||
{
|
|
||||||
View.GetActorId(),
|
|
||||||
Controller->GetWalkerControl().Speed
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ACarlaRecorder::AddTrafficLightState(FCarlaActor &View)
|
|
||||||
{
|
|
||||||
AActor *Actor = View.GetActor();
|
|
||||||
check(Actor != nullptr);
|
|
||||||
|
|
||||||
// get states
|
|
||||||
auto TrafficLight = Cast<ATrafficLightBase>(Actor);
|
|
||||||
if (TrafficLight != nullptr)
|
|
||||||
{
|
|
||||||
AddState(CarlaRecorderStateTrafficLight
|
|
||||||
{
|
|
||||||
View.GetActorId(),
|
|
||||||
TrafficLight->GetTimeIsFrozen(),
|
|
||||||
TrafficLight->GetElapsedTime(),
|
|
||||||
static_cast<char>(TrafficLight->GetTrafficLightState())
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACarlaRecorder::AddVehicleLight(FCarlaActor &View)
|
void ACarlaRecorder::AddTrafficLightState(FCarlaActor *CarlaActor)
|
||||||
{
|
{
|
||||||
AActor *Actor = View.GetActor();
|
check(CarlaActor != nullptr);
|
||||||
check(Actor != nullptr);
|
|
||||||
|
|
||||||
if (Actor->IsPendingKill())
|
// get states
|
||||||
|
UTrafficLightController* Controller =
|
||||||
|
CarlaActor->GetTrafficLightController();
|
||||||
|
if (Controller != nullptr)
|
||||||
{
|
{
|
||||||
return;
|
auto* Group = Controller->GetGroup();
|
||||||
|
if (Group)
|
||||||
|
{
|
||||||
|
AddState(CarlaRecorderStateTrafficLight
|
||||||
|
{
|
||||||
|
CarlaActor->GetActorId(),
|
||||||
|
Group->IsFrozen(),
|
||||||
|
Controller->GetElapsedTime(),
|
||||||
|
static_cast<char>(Controller->GetCurrentState().State)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto Vehicle = Cast<ACarlaWheeledVehicle>(Actor);
|
void ACarlaRecorder::AddVehicleLight(FCarlaActor *CarlaActor)
|
||||||
if (Vehicle == nullptr)
|
{
|
||||||
{
|
check(CarlaActor != nullptr);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
FVehicleLightState LightState;
|
||||||
|
CarlaActor->GetVehicleLightState(LightState);
|
||||||
CarlaRecorderLightVehicle LightVehicle;
|
CarlaRecorderLightVehicle LightVehicle;
|
||||||
LightVehicle.DatabaseId = View.GetActorId();
|
LightVehicle.DatabaseId = CarlaActor->GetActorId();
|
||||||
auto LightState = Vehicle->GetVehicleLightState();
|
|
||||||
LightVehicle.State = carla::rpc::VehicleLightState(LightState).light_state;
|
LightVehicle.State = carla::rpc::VehicleLightState(LightState).light_state;
|
||||||
AddLightVehicle(LightVehicle);
|
AddLightVehicle(LightVehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACarlaRecorder::AddActorKinematics(FCarlaActor &View)
|
void ACarlaRecorder::AddActorKinematics(FCarlaActor *CarlaActor)
|
||||||
{
|
{
|
||||||
AActor *Actor = View.GetActor();
|
check(CarlaActor != nullptr);
|
||||||
check(Actor != nullptr);
|
|
||||||
|
|
||||||
if (Actor->IsPendingKill())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FVector Velocity, AngularVelocity;
|
FVector Velocity, AngularVelocity;
|
||||||
constexpr float TO_METERS = 1e-2;
|
constexpr float TO_METERS = 1e-2;
|
||||||
Velocity = TO_METERS * Actor->GetVelocity();
|
Velocity = TO_METERS* CarlaActor->GetActorVelocity();
|
||||||
UPrimitiveComponent* Primitive = Cast<UPrimitiveComponent>(Actor->GetRootComponent());
|
AngularVelocity = CarlaActor->GetActorAngularVelocity();
|
||||||
if (Primitive)
|
|
||||||
{
|
|
||||||
AngularVelocity = Primitive->GetPhysicsAngularVelocityInDegrees();
|
|
||||||
}
|
|
||||||
CarlaRecorderKinematics Kinematic =
|
CarlaRecorderKinematics Kinematic =
|
||||||
{
|
{
|
||||||
View.GetActorId(),
|
CarlaActor->GetActorId(),
|
||||||
Velocity,
|
Velocity,
|
||||||
AngularVelocity
|
AngularVelocity
|
||||||
};
|
};
|
||||||
AddKinematics(Kinematic);
|
AddKinematics(Kinematic);
|
||||||
}
|
}
|
||||||
void ACarlaRecorder::AddActorBoundingBox(FCarlaActor &View)
|
void ACarlaRecorder::AddActorBoundingBox(FCarlaActor *CarlaActor)
|
||||||
{
|
{
|
||||||
AActor *Actor = View.GetActor();
|
check(CarlaActor != nullptr);
|
||||||
check(Actor != nullptr);
|
|
||||||
|
|
||||||
if (Actor->IsPendingKill())
|
const auto &Box = CarlaActor->GetActorInfo()->BoundingBox;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &Box = View.GetActorInfo()->BoundingBox;
|
|
||||||
CarlaRecorderActorBoundingBox BoundingBox =
|
CarlaRecorderActorBoundingBox BoundingBox =
|
||||||
{
|
{
|
||||||
View.GetActorId(),
|
CarlaActor->GetActorId(),
|
||||||
{Box.Origin, Box.Extent}
|
{Box.Origin, Box.Extent}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -599,16 +562,16 @@ void ACarlaRecorder::AddExistingActors(void)
|
||||||
FActorRegistry Registry = Episode->GetActorRegistry();
|
FActorRegistry Registry = Episode->GetActorRegistry();
|
||||||
for (auto& It : Registry)
|
for (auto& It : Registry)
|
||||||
{
|
{
|
||||||
const FCarlaActor& View = *It.Value.Get();
|
const FCarlaActor* View = It.Value.Get();
|
||||||
const AActor *Actor = View.GetActor();
|
const AActor *Actor = View->GetActor();
|
||||||
if (Actor != nullptr)
|
if (Actor != nullptr)
|
||||||
{
|
{
|
||||||
// create event
|
// create event
|
||||||
CreateRecorderEventAdd(
|
CreateRecorderEventAdd(
|
||||||
View.GetActorId(),
|
View->GetActorId(),
|
||||||
static_cast<uint8_t>(View.GetActorType()),
|
static_cast<uint8_t>(View->GetActorType()),
|
||||||
Actor->GetActorTransform(),
|
Actor->GetActorTransform(),
|
||||||
View.GetActorInfo()->Description);
|
View->GetActorInfo()->Description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,6 +649,6 @@ void ACarlaRecorder::CreateRecorderEventAdd(
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Bounding box in local coordinates
|
// Bounding box in local coordinates
|
||||||
AddActorBoundingBox(*CarlaActor);
|
AddActorBoundingBox(CarlaActor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,11 +197,11 @@ private:
|
||||||
CarlaRecorderQuery Query;
|
CarlaRecorderQuery Query;
|
||||||
|
|
||||||
void AddExistingActors(void);
|
void AddExistingActors(void);
|
||||||
void AddActorPosition(FCarlaActor &View);
|
void AddActorPosition(FCarlaActor *CarlaActor);
|
||||||
void AddWalkerAnimation(FCarlaActor &View);
|
void AddWalkerAnimation(FCarlaActor *CarlaActor);
|
||||||
void AddVehicleAnimation(FCarlaActor &View);
|
void AddVehicleAnimation(FCarlaActor *CarlaActor);
|
||||||
void AddTrafficLightState(FCarlaActor &View);
|
void AddTrafficLightState(FCarlaActor *CarlaActor);
|
||||||
void AddVehicleLight(FCarlaActor &View);
|
void AddVehicleLight(FCarlaActor *CarlaActor);
|
||||||
void AddActorKinematics(FCarlaActor &View);
|
void AddActorKinematics(FCarlaActor *CarlaActor);
|
||||||
void AddActorBoundingBox(FCarlaActor &View);
|
void AddActorBoundingBox(FCarlaActor *CarlaActor);
|
||||||
};
|
};
|
||||||
|
|
|
@ -617,14 +617,9 @@ void FCarlaServer::FPimpl::BindActions()
|
||||||
ECarlaServerResponse::ActorNotFound,
|
ECarlaServerResponse::ActorNotFound,
|
||||||
" Actor Id: " + FString::FromInt(ActorId));
|
" Actor Id: " + FString::FromInt(ActorId));
|
||||||
}
|
}
|
||||||
FVector UELocation = Location;
|
|
||||||
ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(Episode->GetWorld());
|
|
||||||
ALargeMapManager* LargeMap = GameMode->GetLMManager();
|
|
||||||
if (LargeMap)
|
|
||||||
{
|
|
||||||
UELocation = LargeMap->GlobalToLocalLocation(UELocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
CarlaActor->SetActorGlobalLocation(
|
||||||
|
Location, ETeleportType::TeleportPhysics);
|
||||||
return R<void>::Success();
|
return R<void>::Success();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -642,15 +637,8 @@ void FCarlaServer::FPimpl::BindActions()
|
||||||
" Actor Id: " + FString::FromInt(ActorId));
|
" Actor Id: " + FString::FromInt(ActorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
FTransform UETransform = Transform;
|
CarlaActor->SetActorGlobalTransform(
|
||||||
ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(Episode->GetWorld());
|
Transform, ETeleportType::TeleportPhysics);
|
||||||
ALargeMapManager* LargeMap = GameMode->GetLMManager();
|
|
||||||
if (LargeMap)
|
|
||||||
{
|
|
||||||
UETransform = LargeMap->GlobalToLocalTransform(UETransform);
|
|
||||||
}
|
|
||||||
|
|
||||||
CarlaActor->SetActorTransform(UETransform, ETeleportType::TeleportPhysics);
|
|
||||||
return R<void>::Success();
|
return R<void>::Success();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -670,31 +658,11 @@ void FCarlaServer::FPimpl::BindActions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply walker transform
|
// apply walker transform
|
||||||
FTransform NewTransform = Transform;
|
|
||||||
ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(Episode->GetWorld());
|
|
||||||
ALargeMapManager* LargeMap = GameMode->GetLMManager();
|
|
||||||
if (LargeMap)
|
|
||||||
{
|
|
||||||
NewTransform = LargeMap->GlobalToLocalTransform(NewTransform);
|
|
||||||
}
|
|
||||||
FVector NewLocation = NewTransform.GetLocation();
|
|
||||||
|
|
||||||
FTransform CurrentTransform = CarlaActor->GetActor()->GetTransform();
|
|
||||||
FVector CurrentLocation = CurrentTransform.GetLocation();
|
|
||||||
NewLocation.Z += 90.0f; // move point up because in Unreal walker is centered in the middle height
|
|
||||||
|
|
||||||
// if difference between Z position is small, then we keep current, otherwise we set the new one
|
|
||||||
// (to avoid Z fighting position and falling pedestrians)
|
|
||||||
if (NewLocation.Z - CurrentLocation.Z < 100.0f)
|
|
||||||
NewLocation.Z = CurrentLocation.Z;
|
|
||||||
|
|
||||||
NewTransform.SetLocation(NewLocation);
|
|
||||||
|
|
||||||
ECarlaServerResponse Response =
|
ECarlaServerResponse Response =
|
||||||
CarlaActor->SetWalkerState(
|
CarlaActor->SetWalkerState(
|
||||||
NewTransform,
|
Transform,
|
||||||
cr::WalkerControl(Transform.GetForwardVector(), Speed, false),
|
cr::WalkerControl(
|
||||||
Speed);
|
Transform.GetForwardVector(), Speed, false));
|
||||||
if (Response != ECarlaServerResponse::Success)
|
if (Response != ECarlaServerResponse::Success)
|
||||||
{
|
{
|
||||||
return RespondError(
|
return RespondError(
|
||||||
|
|
|
@ -429,6 +429,7 @@ void ATrafficLightManager::SpawnTrafficLights()
|
||||||
const auto& SignalId = SignalPair.first;
|
const auto& SignalId = SignalPair.first;
|
||||||
const auto& Signal = SignalPair.second;
|
const auto& Signal = SignalPair.second;
|
||||||
if(!Signal->GetControllers().size() &&
|
if(!Signal->GetControllers().size() &&
|
||||||
|
!GetMap()->IsJunction(Signal->GetRoadId()) &&
|
||||||
carla::road::SignalType::IsTrafficLight(Signal->GetType()) &&
|
carla::road::SignalType::IsTrafficLight(Signal->GetType()) &&
|
||||||
!SignalsToSpawn.count(SignalId))
|
!SignalsToSpawn.count(SignalId))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue