More robust sensor and agent id
This commit is contained in:
parent
ac358c4826
commit
bb3b8697eb
|
@ -12,12 +12,6 @@
|
|||
#include "Game/CarlaGameModeBase.h"
|
||||
#include "Game/DataRouter.h"
|
||||
|
||||
static uint32 GetNextAgentId()
|
||||
{
|
||||
static uint32 COUNT = 0u;
|
||||
return ++COUNT;
|
||||
}
|
||||
|
||||
static FDataRouter &GetDataRouter(UWorld *World)
|
||||
{
|
||||
check(World != nullptr);
|
||||
|
@ -26,10 +20,6 @@ static FDataRouter &GetDataRouter(UWorld *World)
|
|||
return GameMode->GetDataRouter();
|
||||
}
|
||||
|
||||
UAgentComponent::UAgentComponent(const FObjectInitializer &ObjectInitializer)
|
||||
: Super(ObjectInitializer),
|
||||
Id(GetNextAgentId()) {}
|
||||
|
||||
void UAgentComponent::AcceptVisitor(IAgentComponentVisitor &Visitor) const
|
||||
{
|
||||
unimplemented();
|
||||
|
|
|
@ -22,11 +22,9 @@ class CARLA_API UAgentComponent : public USceneComponent
|
|||
|
||||
public:
|
||||
|
||||
UAgentComponent(const FObjectInitializer &ObjectInitializer);
|
||||
|
||||
uint32 GetId() const
|
||||
{
|
||||
return Id;
|
||||
return GetTypeHash(this);
|
||||
}
|
||||
|
||||
virtual void AcceptVisitor(IAgentComponentVisitor &Visitor) const;
|
||||
|
@ -36,9 +34,4 @@ protected:
|
|||
virtual void BeginPlay() override;
|
||||
|
||||
virtual void EndPlay(EEndPlayReason::Type EndPlayReason) override;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
uint32 Id;
|
||||
};
|
||||
|
|
|
@ -196,12 +196,14 @@ void FCarlaEncoder::Visit(const UTrafficSignAgentComponent &Agent)
|
|||
void FCarlaEncoder::Visit(const UVehicleAgentComponent &Agent)
|
||||
{
|
||||
auto &Vehicle = Agent.GetVehicle();
|
||||
Data.type = CARLA_SERVER_AGENT_VEHICLE;
|
||||
Data.forward_speed = Vehicle.GetVehicleForwardSpeed();
|
||||
::Encode(Vehicle.GetVehicleBoundsExtent(), Data.box_extent);
|
||||
}
|
||||
|
||||
void FCarlaEncoder::Visit(const UWalkerAgentComponent &Agent)
|
||||
{
|
||||
Data.type = CARLA_SERVER_AGENT_PEDESTRIAN;
|
||||
Data.forward_speed = Agent.GetForwardSpeed();
|
||||
::Encode(Agent.GetBoundingBoxExtent(), Data.box_extent);
|
||||
}
|
||||
|
|
|
@ -9,16 +9,6 @@
|
|||
|
||||
#include "Util/IniFile.h"
|
||||
|
||||
static uint32 GetNextSensorDescriptionId()
|
||||
{
|
||||
static uint32 COUNT = 0u;
|
||||
return ++COUNT;
|
||||
}
|
||||
|
||||
USensorDescription::USensorDescription(const FObjectInitializer &ObjectInitializer)
|
||||
: Super(ObjectInitializer),
|
||||
Id(GetNextSensorDescriptionId()) {}
|
||||
|
||||
void USensorDescription::AcceptVisitor(ISensorDescriptionVisitor &Visitor) const
|
||||
{
|
||||
unimplemented();
|
||||
|
@ -37,7 +27,7 @@ void USensorDescription::Load(const FIniFile &Config, const FString &Section)
|
|||
void USensorDescription::Log() const
|
||||
{
|
||||
UE_LOG(LogCarla, Log, TEXT("[%s/%s]"), TEXT("CARLA/Sensor"), *Name);
|
||||
UE_LOG(LogCarla, Log, TEXT("Id = %d"), Id);
|
||||
UE_LOG(LogCarla, Log, TEXT("Id = %d"), GetId());
|
||||
UE_LOG(LogCarla, Log, TEXT("Type = %s"), *Type);
|
||||
UE_LOG(LogCarla, Log, TEXT("Position = (%s)"), *Position.ToString());
|
||||
UE_LOG(LogCarla, Log, TEXT("Rotation = (%s)"), *Rotation.ToString());
|
||||
|
|
|
@ -19,11 +19,9 @@ class CARLA_API USensorDescription : public UObject
|
|||
|
||||
public:
|
||||
|
||||
USensorDescription(const FObjectInitializer &ObjectInitializer);
|
||||
|
||||
uint32 GetId() const
|
||||
{
|
||||
return Id;
|
||||
return GetTypeHash(this);
|
||||
}
|
||||
|
||||
virtual void AcceptVisitor(ISensorDescriptionVisitor &Visitor) const;
|
||||
|
@ -39,11 +37,6 @@ public:
|
|||
|
||||
virtual void Log() const;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(Category = "Sensor Description", VisibleAnywhere)
|
||||
uint32 Id;
|
||||
|
||||
public:
|
||||
|
||||
/** Display name of the sensor. */
|
||||
|
|
|
@ -118,6 +118,8 @@ namespace server {
|
|||
return SetTrafficLight(lhs->mutable_traffic_light(), rhs, cs::TrafficLight::YELLOW);
|
||||
case CARLA_SERVER_AGENT_TRAFFICLIGHT_RED:
|
||||
return SetTrafficLight(lhs->mutable_traffic_light(), rhs, cs::TrafficLight::RED);
|
||||
default:
|
||||
log_error("invalid agent type");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue