Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(map_height_fitter): more efficient query to find closest lanelet #7020

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions map/map_height_fitter/src/map_height_fitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,12 @@ double MapHeightFitter::Impl::get_ground_height(const Point & point) const
}
}
} else if (fit_target_ == "vector_map") {
lanelet::ConstLanelets all_lanelets = lanelet::utils::query::laneletLayer(vector_map_);

geometry_msgs::msg::Pose pose;
pose.position.x = x;
pose.position.y = y;
pose.position.z = 0.0;
lanelet::ConstLanelet closest_lanelet;
const bool result =
lanelet::utils::query::getClosestLanelet(all_lanelets, pose, &closest_lanelet);
if (!result) {
const auto closest_points = vector_map_->pointLayer.nearest(lanelet::BasicPoint2d{x, y}, 1);
if (closest_points.empty()) {
RCLCPP_WARN_STREAM(logger, "failed to get closest lanelet");
return point.z;
}
height = closest_lanelet.centerline().back().z();
height = closest_points.front().z();
}

return std::isfinite(height) ? height : point.z;
Expand Down
Loading