Added detection of 'Speed_' object record from roadrunner to interpret it as a speed signal.
This commit is contained in:
parent
5428354e5c
commit
cbd12ac056
|
@ -32,6 +32,7 @@ namespace parser {
|
|||
|
||||
// type Crosswalk
|
||||
std::string type = node_object.attribute("type").as_string();
|
||||
std::string name = node_object.attribute("name").as_string();
|
||||
if (type == "crosswalk") {
|
||||
|
||||
// read all points
|
||||
|
@ -62,6 +63,31 @@ namespace parser {
|
|||
node_object.attribute("length").as_double(),
|
||||
points);
|
||||
|
||||
} else if (name.substr(0, 6) == "Speed_") {
|
||||
road::RoadId road_id = node_road.attribute("id").as_uint();
|
||||
road::Road *road = map_builder.GetRoad(road_id);
|
||||
// speed signal by roadrunner
|
||||
std::string speed_str = name.substr(6);
|
||||
double speed = std::stod(speed_str);
|
||||
map_builder.AddSignal(road,
|
||||
node_object.attribute("id").as_string(),
|
||||
node_object.attribute("s").as_double(),
|
||||
node_object.attribute("t").as_double(),
|
||||
node_object.attribute("name").as_string(),
|
||||
"no",
|
||||
node_object.attribute("orientation").value(),
|
||||
node_object.attribute("zOffset").as_double(),
|
||||
"OpenDRIVE",
|
||||
"274",
|
||||
speed_str,
|
||||
speed,
|
||||
"mph",
|
||||
node_object.attribute("height").as_double(),
|
||||
node_object.attribute("width").as_double(),
|
||||
speed_str,
|
||||
node_object.attribute("hdg").as_double(),
|
||||
node_object.attribute("pitch").as_double(),
|
||||
node_object.attribute("roll").as_double());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -378,9 +378,10 @@ T * GetClosestTrafficSignActor(const carla::road::Signal &Signal, UWorld* World)
|
|||
for (AActor* Actor : Actors)
|
||||
{
|
||||
float Dist = FVector::DistSquared(Actor->GetActorLocation(), Location);
|
||||
if (Dist < MinDistance && MatchSignalAndActor(Signal, ClosestTrafficSign))
|
||||
T * TrafficSign = Cast<T>(Actor);
|
||||
if (Dist < MinDistance && MatchSignalAndActor(Signal, TrafficSign))
|
||||
{
|
||||
ClosestTrafficSign = Cast<T>(Actor);
|
||||
ClosestTrafficSign = TrafficSign;
|
||||
MinDistance = Dist;
|
||||
}
|
||||
}
|
||||
|
@ -402,8 +403,8 @@ void ATrafficLightManager::SpawnTrafficLights()
|
|||
{
|
||||
continue;
|
||||
}
|
||||
ATrafficSignBase * ClosestTrafficSign = GetClosestTrafficSignActor(*Signal.get(), GetWorld());
|
||||
ATrafficLightBase * TrafficLight = Cast<ATrafficLightBase>(ClosestTrafficSign);
|
||||
ATrafficLightBase * TrafficLight = GetClosestTrafficSignActor<ATrafficLightBase>(
|
||||
*Signal.get(), GetWorld());
|
||||
if (TrafficLight)
|
||||
{
|
||||
UTrafficLightComponent *TrafficLightComponent = TrafficLight->GetTrafficLightComponent();
|
||||
|
@ -425,8 +426,8 @@ void ATrafficLightManager::SpawnTrafficLights()
|
|||
carla::road::SignalType::IsTrafficLight(Signal->GetType()) &&
|
||||
!SignalsToSpawn.count(SignalId))
|
||||
{
|
||||
ATrafficSignBase * ClosestTrafficSign = GetClosestTrafficSignActor(*Signal.get(), GetWorld());
|
||||
ATrafficLightBase * TrafficLight = Cast<ATrafficLightBase>(ClosestTrafficSign);
|
||||
ATrafficLightBase * TrafficLight = GetClosestTrafficSignActor<ATrafficLightBase>(
|
||||
*Signal.get(), GetWorld());
|
||||
if (TrafficLight)
|
||||
{
|
||||
UTrafficLightComponent *TrafficLightComponent = TrafficLight->GetTrafficLightComponent();
|
||||
|
|
Loading…
Reference in New Issue