Skip to content

Commit

Permalink
move getStopLinePolygon method
Browse files Browse the repository at this point in the history
  • Loading branch information
abco20 committed Feb 27, 2025
1 parent 8e01a81 commit 4e6dfb5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ class HdMapUtils
traffic_simulator::RoutingConfiguration().routing_graph_type) const
-> double;

auto getStopLinePolygon(const lanelet::Id) const -> std::vector<geometry_msgs::msg::Point>;

auto getTangentVector(const lanelet::Id, const double s) const
-> std::optional<geometry_msgs::msg::Vector3>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ auto leftBound(const lanelet::Id lanelet_id) -> std::vector<Point>;
auto rightBound(const lanelet::Id lanelet_id) -> std::vector<Point>;

// Polygons
auto stopLinePolygon(const lanelet::Id lanelet_id) -> std::vector<Point>;

auto toPolygon(const lanelet::ConstLineString3d & line_string) -> std::vector<Point>;

// Objects on path
Expand Down
15 changes: 0 additions & 15 deletions simulation/traffic_simulator/src/hdmap_utils/hdmap_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,21 +1285,6 @@ auto HdMapUtils::getTrafficLightStopLinesPoints(const lanelet::Id traffic_light_
return ret;
}

auto HdMapUtils::getStopLinePolygon(const lanelet::Id lanelet_id) const
-> std::vector<geometry_msgs::msg::Point>
{
std::vector<geometry_msgs::msg::Point> points;
const auto stop_line = lanelet_map_ptr_->lineStringLayer.get(lanelet_id);
for (const auto & point : stop_line) {
geometry_msgs::msg::Point p;
p.x = point.x();
p.y = point.y();
p.z = point.z();
points.emplace_back(p);
}
return points;
}

auto HdMapUtils::getTrafficLightIdsOnPath(const lanelet::Ids & route_lanelets) const -> lanelet::Ids
{
lanelet::Ids ids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ auto rightBound(const lanelet::Id lanelet_id) -> std::vector<Point>
}

// Polygons
auto stopLinePolygon(const lanelet::Id lanelet_id) -> std::vector<Point>
{
/// @todo here you should probably add a verify if the passed lanelet_id is indeed a stop_line
return toPolygon(LaneletWrapper::map()->lineStringLayer.get(lanelet_id));
}

auto toPolygon(const lanelet::ConstLineString3d & line_string) -> std::vector<Point>
{
std::vector<Point> points;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,8 @@ TEST_F(
*/
TEST_F(HdMapUtilsTest_CrossroadsWithStoplinesMap, getStopLinePolygon_stopLine)
{
const auto result_stoplines_points = hdmap_utils.getStopLinePolygon(lanelet::Id{120663});
const auto result_stoplines_points =
traffic_simulator::lanelet_wrapper::lanelet_map::stopLinePolygon(lanelet::Id{120663});
const auto actual_stoplines_points = std::vector<geometry_msgs::msg::Point>{
makePoint(3768.5, 73737.5, -0.5), makePoint(3765.5, 73735.5, -0.5)};

Expand All @@ -2433,7 +2434,8 @@ TEST_F(HdMapUtilsTest_CrossroadsWithStoplinesMap, getStopLinePolygon_stopLine)
*/
TEST_F(HdMapUtilsTest_CrossroadsWithStoplinesMap, getStopLinePolygon_invalidLaneletId)
{
EXPECT_THROW(hdmap_utils.getStopLinePolygon(1000039), std::runtime_error);
EXPECT_THROW(
traffic_simulator::lanelet_wrapper::lanelet_map::stopLinePolygon(1000039), std::runtime_error);
}

/**
Expand Down

0 comments on commit 4e6dfb5

Please sign in to comment.