Skip to content

Commit

Permalink
Use findUsages in missing_referrers_for_traffic_lights
Browse files Browse the repository at this point in the history
Signed-off-by: TaikiYamada4 <[email protected]>
  • Loading branch information
TaikiYamada4 committed Dec 5, 2024
1 parent 1232fca commit 1a077ae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@ class MissingReferrersForTrafficLightsValidator : public lanelet::validation::Ma
*/
lanelet::validation::Issues check_missing_referrers_for_traffic_lights(
const lanelet::LaneletMap & map);

/**
* @brief Returns lanelets that refers the regulatory element specified by the input id
* from the input lanelet map.
*
* @param map
* @param reg_elem_id
* @return lanelet::ConstLanelets
*/
lanelet::ConstLanelets collect_referring_lanelets(
const lanelet::LaneletMap & map, const lanelet::Id reg_elem_id);
};
} // namespace lanelet::autoware::validation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ MissingReferrersForTrafficLightsValidator::check_missing_referrers_for_traffic_l
}

// At least one lanelet should refer a traffic_light regulatory element
const lanelet::ConstLanelets referring_lanelets =
collect_referring_lanelets(map, reg_elem->id());
const lanelet::ConstLanelets referring_lanelets = map.laneletLayer.findUsages(reg_elem);

if (referring_lanelets.size() == 0) {
issues.emplace_back(
lanelet::validation::Severity::Error, lanelet::validation::Primitive::RegulatoryElement,
Expand All @@ -66,19 +66,4 @@ MissingReferrersForTrafficLightsValidator::check_missing_referrers_for_traffic_l

return issues;
}

lanelet::ConstLanelets MissingReferrersForTrafficLightsValidator::collect_referring_lanelets(
const lanelet::LaneletMap & map, const lanelet::Id target_reg_elem_id)
{
lanelet::ConstLanelets lanelet_group;
for (const lanelet::ConstLanelet & lanelet : map.laneletLayer) {
for (lanelet::RegulatoryElementConstPtr reg_elem : lanelet.regulatoryElements()) {
if (reg_elem->id() == target_reg_elem_id) {
lanelet_group.push_back(lanelet);
}
}
}
return lanelet_group;
}

} // namespace lanelet::autoware::validation

0 comments on commit 1a077ae

Please sign in to comment.