-
Notifications
You must be signed in to change notification settings - Fork 0
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
Precomputes linestring's segments intervals #51
Conversation
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
@agalbachicar PTAL, still missing some minor docstrings. In the PR's description there is stated the speed ups in query times. |
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Locally it is building correctly while in GhAction CI it is failing cause using
In GCC 9 we need to link against tbb, in GCC 10 it isn't required. (Not sure why it is working locally) |
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement! PTAL to some minor comments.
/// A segment of a LineString. | ||
/// A segment is defined by a: | ||
/// - start index: index of the first coordinate of the segment. | ||
/// - end index: index of the last coordinate of the segment, in general it is the start index + 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why in general it is the start index + 1
? Can we add that to the docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment edit was not effective. I wanted to say that we should explicitly mention that start_index + 1 is generally used within the LineString constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/// - start index: index of the first coordinate of the segment. | ||
/// - end index: index of the last coordinate of the segment, in general it is the start index + 1. | ||
struct Segment { | ||
/// Defines an interval in the P value of the parametrized LineString. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Defines an interval in the P value of the parametrized LineString. | |
/// Defines an interval in the @f$ p @f$ value of the parametrized LineString. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/// Defines an interval in the P value of the parametrized LineString. | ||
/// The Less than operator is defined to allow the use of this struct as a key in a collection like std::map. | ||
struct Interval { | ||
// Interval() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should delete
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D
Done
/// @param min_max Is the minimum and maximum value of the interval. | ||
Interval(double min_max) : min(min_max), max(min_max) {} | ||
|
||
// Less than operator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Less than operator. | |
/// Less than operator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/geometry/utility/geometry.cc
Outdated
if (remaining_distance < kEpsilon) { | ||
return *line_string_points_length.first; | ||
return start; | ||
} | ||
return *line_string_points_length.first + | ||
remaining_distance / partial_length * (*line_string_points_length.second - *line_string_points_length.first); | ||
return start + d_segment.normalized() * remaining_distance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we merge this into the following?
return remaining_distance < kEpsilon ? start : start + d_segment.normalized() * remaining_distance;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed
Done.
src/geometry/utility/geometry.cc
Outdated
return {line_string.end() - 1, line_string.end() - 2, line_string.length()}; | ||
BoundPointsResult GetBoundPointsAtP(const LineString<CoordinateT>& line_string, double p, double tolerance) { | ||
p = maliput::common::RangeValidator::GetAbsoluteEpsilonValidator(0., line_string.length(), tolerance, kEpsilon)(p); | ||
const auto segment = line_string.segments().at(typename LineString<CoordinateT>::Segment::Interval{p}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the compiler understand the right type conversion if we did?
const auto segment = line_string.segments().at({p});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it does.
Done
src/geometry/utility/geometry.cc
Outdated
std::for_each(std::execution::par, segments.begin(), segments.end(), [&](const auto& segment) { | ||
const auto& start = line_string[segment.second.idx_start]; | ||
const auto& end = line_string[segment.second.idx_end]; | ||
const auto current_closest_point_res = GetClosestPointToSegment(Segment3d{start, end}, xyz, tolerance); | ||
if (current_closest_point_res.distance < segment_closest_point_result.distance) { | ||
segment_closest_point_result = current_closest_point_res; | ||
closest_segment = {segment.second.idx_start, segment.second.idx_end, segment.second.p_interval}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is not aligned with parallel execution as there might be race conditions, so I will remove the parallel execution here and use a regular for_each statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done at 9f81200
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
@agalbachicar , please take a look at 8d2d32b I found this case when trying to create the meshes for the arc_lane_dense map(The last point of the map is the same at the right before). Even though it reflects a possible wrong creation of the map adding that could solve the issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to create a unit test for that?
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Check f48371a |
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
🎉 New feature
Related to #50 #47
Summary
p
of the linestring is quite quick.Speed up
Test it
Checklist
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.