CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Traffic
GeoTrafficSign.cpp
Go to the documentation of this file.
1
// Copyright (c) 2026 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 "
GeoTrafficSign.h
"
8
#include "
Carla.h
"
9
10
AGeoTrafficSign::AGeoTrafficSign
(
const
FObjectInitializer &ObjectInitializer)
11
: Super(ObjectInitializer)
12
{
13
Pole
= ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(
this
, TEXT(
"Pole"
));
14
Pole
->SetupAttachment(RootComponent);
15
Pole
->SetMobility(EComponentMobility::Static);
16
Pole
->SetCollisionProfileName(TEXT(
"BlockAll"
));
17
18
Plate
= ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(
this
, TEXT(
"Plate"
));
19
Plate
->SetupAttachment(RootComponent);
20
Plate
->SetMobility(EComponentMobility::Static);
21
Plate
->SetCollisionProfileName(TEXT(
"NoCollision"
));
22
}
23
24
void
AGeoTrafficSign::Setup
(UStaticMesh* PoleMesh, UStaticMesh* PlateMesh, UMaterialInterface* PlateMaterial,
25
FVector PlateOffset,
float
PlateYaw,
float
PlateScale)
26
{
27
Pole
->SetStaticMesh(PoleMesh);
28
Plate
->SetStaticMesh(PlateMesh);
29
if
(PlateMaterial !=
nullptr
)
30
{
31
Plate
->SetMaterial(0, PlateMaterial);
32
}
33
Plate
->SetRelativeLocation(PlateOffset);
34
Plate
->SetRelativeRotation(FRotator(0.0f, PlateYaw, 0.0f));
35
Plate
->SetRelativeScale3D(FVector(PlateScale));
36
}
37
38
ETrafficSignState
AGeoTrafficSign::StateForSignal
(
const
FString& Type,
const
FString& Subtype)
39
{
40
if
(Type == TEXT(
"206"
))
41
{
42
return
ETrafficSignState::StopSign;
43
}
44
if
(Type == TEXT(
"205"
))
45
{
46
return
ETrafficSignState::YieldSign;
47
}
48
if
(Type == TEXT(
"274"
))
49
{
50
return
SpeedLimitStateForKmh
(FCString::Atoi(*Subtype));
51
}
52
return
ETrafficSignState::UNKNOWN
;
53
}
54
55
void
AGeoTrafficSign::PostInitializeComponents
()
56
{
57
Super::PostInitializeComponents();
58
if
(
GetTrafficSignState
() ==
ETrafficSignState::UNKNOWN
&& !
XodrType
.IsEmpty())
59
{
60
ConfigureForSignal
(
XodrType
,
XodrSubtype
);
61
}
62
}
63
64
void
AGeoTrafficSign::ConfigureForSignal
(
const
FString& Type,
const
FString& Subtype)
65
{
66
XodrType
= Type;
67
XodrSubtype
= Subtype;
68
if
(Type == TEXT(
"274"
))
69
{
70
SetSpeedLimitKmh
(FCString::Atoi(*Subtype));
71
}
72
else
73
{
74
SetTrafficSignState
(
StateForSignal
(Type, Subtype));
75
}
76
}
Carla.h
GeoTrafficSign.h
SpeedLimitStateForKmh
ETrafficSignState SpeedLimitStateForKmh(int32 Kmh)
The dedicated state for a km/h value, ETrafficSignState::SpeedLimit when there is none (then store th...
Definition
TrafficSignBase.h:76
ETrafficSignState
ETrafficSignState
Definition
TrafficSignBase.h:16
ETrafficSignState::UNKNOWN
@ UNKNOWN
Definition
TrafficSignBase.h:18
AGeoTrafficSign::StateForSignal
static ETrafficSignState StateForSignal(const FString &Type, const FString &Subtype)
The ETrafficSignState the traffic-light manager matches against for an OpenDRIVE signal type/subtype:...
Definition
GeoTrafficSign.cpp:38
AGeoTrafficSign::Plate
UStaticMeshComponent * Plate
Definition
GeoTrafficSign.h:35
AGeoTrafficSign::XodrType
FString XodrType
Definition
GeoTrafficSign.h:50
AGeoTrafficSign::ConfigureForSignal
void ConfigureForSignal(const FString &Type, const FString &Subtype)
Set XodrType / XodrSubtype and the matching runtime state (speed limit in km/h from the subtype) so A...
Definition
GeoTrafficSign.cpp:64
AGeoTrafficSign::Setup
void Setup(UStaticMesh *PoleMesh, UStaticMesh *PlateMesh, UMaterialInterface *PlateMaterial, FVector PlateOffset, float PlateYaw, float PlateScale)
Assign meshes / material and place the plate.
Definition
GeoTrafficSign.cpp:24
AGeoTrafficSign::AGeoTrafficSign
AGeoTrafficSign(const FObjectInitializer &ObjectInitializer)
Definition
GeoTrafficSign.cpp:10
AGeoTrafficSign::PostInitializeComponents
virtual void PostInitializeComponents() override
Levels baked before every km/h value had a state carry UNKNOWN for e.g.
Definition
GeoTrafficSign.cpp:55
AGeoTrafficSign::XodrSubtype
FString XodrSubtype
Definition
GeoTrafficSign.h:53
AGeoTrafficSign::Pole
UStaticMeshComponent * Pole
Definition
GeoTrafficSign.h:32
ATrafficSignBase::GetTrafficSignState
ETrafficSignState GetTrafficSignState() const
Definition
TrafficSignBase.h:114
ATrafficSignBase::SetTrafficSignState
void SetTrafficSignState(ETrafficSignState State)
Definition
TrafficSignBase.h:120
ATrafficSignBase::SetSpeedLimitKmh
void SetSpeedLimitKmh(int32 Kmh)
Make this a speed-limit sign for Kmh: picks the dedicated state when one exists, the custom state (va...
Definition
TrafficSignBase.h:140
Generated by
1.18.0