21#include <unordered_map>
23#include "absl/strings/str_cat.h"
24#include "absl/strings/str_join.h"
41using std::placeholders::_1;
45const double kSampleDistance = 0.25;
47bool FindLaneSegment(
const MapPathPoint& p1,
const MapPathPoint& p2,
48 LaneSegment*
const lane_segment) {
49 for (
const auto& wp1 : p1.lane_waypoints()) {
50 if (
nullptr == wp1.lane) {
53 for (
const auto& wp2 : p2.lane_waypoints()) {
54 if (
nullptr == wp2.lane) {
57 if (wp1.lane->id().id() == wp2.lane->id().id() && wp1.s < wp2.s) {
58 *lane_segment = LaneSegment(wp1.lane, wp1.s, wp2.s);
69 if (
lane ==
nullptr) {
70 return "(lane is null)";
72 return absl::StrCat(
"id = ",
lane->id().id(),
" s = ",
s);
79 for (
const auto& type :
80 waypoint.
lane->lane().left_boundary().boundary_type()) {
81 if (type.s() <= waypoint.
s) {
82 if (type.types_size() > 0) {
96 for (
const auto& type :
97 waypoint.
lane->lane().right_boundary().boundary_type()) {
98 if (type.s() <= waypoint.
s) {
99 if (type.types_size() > 0) {
100 return type.types(0);
111 if (!waypoint.
lane) {
114 auto point = waypoint.
lane->GetSmoothPoint(waypoint.
s);
116 CHECK_NOTNULL(map_ptr);
117 for (
const auto& lane_id :
118 waypoint.
lane->lane().left_neighbor_forward_lane_id()) {
119 auto lane = map_ptr->GetLaneById(lane_id);
125 if (!lane->GetProjection({point.x(), point.y()}, &s, &l)) {
129 if (s < -kSampleDistance || s > lane->total_length() + kSampleDistance) {
139 static constexpr double kSegmentDelta = 0.5;
142 while (i < segments->size()) {
144 while (j + 1 < segments->size() &&
145 segments->at(i).lane == segments->at(j + 1).lane) {
148 auto& segment_k = segments->at(k);
149 segment_k.
lane = segments->at(i).lane;
150 segment_k.start_s = segments->at(i).start_s;
151 segment_k.end_s = segments->at(j).end_s;
152 if (segment_k.start_s < kSegmentDelta) {
153 segment_k.start_s = 0.0;
155 if (segment_k.end_s + kSegmentDelta >= segment_k.lane->total_length()) {
156 segment_k.end_s = segment_k.lane->total_length();
162 segments->shrink_to_fit();
167 if (!waypoint.
lane) {
170 auto point = waypoint.
lane->GetSmoothPoint(waypoint.
s);
172 CHECK_NOTNULL(map_ptr);
173 for (
const auto& lane_id :
174 waypoint.
lane->lane().right_neighbor_forward_lane_id()) {
175 auto lane = map_ptr->GetLaneById(lane_id);
181 if (!lane->GetProjection({point.x(), point.y()}, &s, &l)) {
184 if (s < -kSampleDistance || s > lane->total_length() + kSampleDistance) {
194 if (
lane ==
nullptr) {
195 return "(lane is null)";
197 return absl::StrCat(
"id = ",
lane->id().id(),
" start_s = ",
start_s,
207 const double start_s,
208 const double end_s) {
209 std::vector<MapPathPoint> points;
210 if (start_s >= end_s) {
213 double accumulate_s = 0.0;
214 for (
size_t i = 0; i < lane->points().size(); ++i) {
215 if (accumulate_s >= start_s && accumulate_s <= end_s) {
216 points.emplace_back(lane->points()[i], lane->headings()[i],
219 if (i < lane->segments().size()) {
220 const auto& segment = lane->segments()[i];
221 const double next_accumulate_s = accumulate_s + segment.length();
222 if (start_s > accumulate_s && start_s < next_accumulate_s) {
223 points.emplace_back(segment.start() + segment.unit_direction() *
224 (start_s - accumulate_s),
227 if (end_s > accumulate_s && end_s < next_accumulate_s) {
229 segment.start() + segment.unit_direction() * (end_s - accumulate_s),
232 accumulate_s = next_accumulate_s;
234 if (accumulate_s > end_s) {
242 static constexpr double kDuplicatedPointsEpsilon = 1e-7;
243 static constexpr double limit =
244 kDuplicatedPointsEpsilon * kDuplicatedPointsEpsilon;
245 CHECK_NOTNULL(points);
247 for (
size_t i = 0; i < points->size(); ++i) {
250 (*points)[count++] = (*points)[i];
252 (*points)[count - 1].add_lane_waypoints((*points)[i].
lane_waypoints());
255 points->resize(count);
273 "numlane_segments_ = ",
285 : path_points_(path_points) {
290 : path_points_(
std::move(path_points)) {
295 const std::vector<LaneSegment>& lane_segments)
296 : path_points_(path_points), lane_segments_(lane_segments) {
301 std::vector<LaneSegment>&& lane_segments)
302 : path_points_(
std::move(path_points)),
303 lane_segments_(
std::move(lane_segments)) {
308 const std::vector<LaneSegment>& lane_segments,
309 const double max_approximation_error)
310 : path_points_(path_points), lane_segments_(lane_segments) {
312 if (max_approximation_error > 0.0) {
319 : lane_segments_(segments) {
322 segment.lane, segment.start_s, segment.end_s);
331 : lane_segments_(
std::move(segments)) {
334 segment.lane, segment.start_s, segment.end_s);
343 std::vector<LaneSegment>&& lane_segments,
344 const double max_approximation_error)
345 : path_points_(
std::move(path_points)),
346 lane_segments_(
std::move(lane_segments)) {
348 if (max_approximation_error > 0.0) {
382 float heading_length = heading.
Length();
387 if (heading_length > 0.0) {
388 heading /= heading_length;
449 double segment_end_s = -1.0;
450 double segment_start_s = -1.0;
451 double waypoint_s = 0.0;
452 double left_width = 0.0;
453 double right_width = 0.0;
455 bool is_reach_to_end =
false;
456 int path_point_index = 0;
459 while (segment_end_s < sample_s && !is_reach_to_end) {
461 cur_waypoint = &(cur_point.lane_waypoints()[0]);
462 CHECK_NOTNULL(cur_waypoint->
lane);
464 segment_end_s = segment_start_s +
segments_[path_point_index].length();
466 is_reach_to_end =
true;
470 waypoint_s = cur_waypoint->
s + sample_s - segment_start_s;
471 cur_waypoint->
lane->GetWidth(waypoint_s, &left_width, &right_width);
474 cur_waypoint->
lane->GetRoadWidth(waypoint_s, &left_width, &right_width);
477 sample_s += kSampleDistance;
499 s += kSampleDistance;
505 std::vector<PathOverlap>*
const overlaps)
const {
506 if (overlaps ==
nullptr) {
510 std::unordered_map<std::string, std::vector<std::pair<double, double>>>
514 if (lane_segment.lane ==
nullptr) {
517 for (
const auto& overlap : GetOverlaps_from_lane(*(lane_segment.lane))) {
518 const auto& overlap_info =
519 overlap->GetObjectOverlapInfo(lane_segment.lane->id());
520 if (overlap_info ==
nullptr) {
524 const auto& lane_overlap_info = overlap_info->lane_overlap_info();
525 if (lane_overlap_info.start_s() <= lane_segment.end_s &&
526 lane_overlap_info.end_s() >= lane_segment.start_s) {
527 const double ref_s = s - lane_segment.start_s;
528 const double adjusted_start_s =
529 std::max(lane_overlap_info.start_s(), lane_segment.start_s) + ref_s;
530 const double adjusted_end_s =
531 std::min(lane_overlap_info.end_s(), lane_segment.end_s) + ref_s;
532 for (
const auto&
object : overlap->overlap().object()) {
533 if (
object.
id().id() != lane_segment.lane->id().id()) {
534 overlaps_by_id[
object.id().id()].emplace_back(adjusted_start_s,
540 s += lane_segment.end_s - lane_segment.start_s;
542 for (
auto& overlaps_one_object : overlaps_by_id) {
543 const std::string& object_id = overlaps_one_object.first;
544 auto&
segments = overlaps_one_object.second;
547 const double kMinOverlapDistanceGap = 1.5;
548 for (
const auto& segment :
segments) {
549 if (!overlaps->empty() && overlaps->back().object_id == object_id &&
550 segment.first - overlaps->back().end_s <= kMinOverlapDistanceGap) {
551 overlaps->back().end_s =
552 std::max(overlaps->back().end_s, segment.second);
554 overlaps->emplace_back(object_id, segment.first, segment.second);
558 std::sort(overlaps->begin(), overlaps->end(),
560 return overlap1.start_s < overlap2.start_s;
565 auto next = std::upper_bound(
567 [](
double s,
const PathOverlap& o) { return s < o.start_s; });
592 CHECK_GE(index.
id, 0);
596 if (std::abs(index.
offset) > kMathEpsilon) {
603 if (lane_segment.
lane !=
nullptr) {
605 if (lane_waypoint.lane->id().id() == lane_segment.
lane->id().id()) {
606 ref_lane_waypoint = lane_waypoint;
612 ref_lane_waypoint.l));
646 const int sample_id =
static_cast<int>(s / kSampleDistance);
650 const int next_sample_id = sample_id + 1;
655 while (low + 1 < high) {
656 const int mid = (low + high) >> 1;
691 const double start_s,
const double end_s)
const {
692 std::vector<hdmap::LaneSegment> lanes;
693 if (start_s + kMathEpsilon > end_s) {
697 if (start_index.offset + kMathEpsilon >=
700 start_index.offset = 0;
703 if (start_index.id >= num_lanes) {
706 lanes.emplace_back(
lane_segments_[start_index.id].lane, start_index.offset,
709 for (
int i = start_index.id; i < end_index.id && i < num_lanes; ++i) {
712 if (end_index.offset >= kMathEpsilon) {
713 lanes.emplace_back(
lane_segments_[end_index.id].lane, 0, end_index.offset);
719 double* lateral)
const {
720 double distance = 0.0;
725 double* lateral,
double* min_distance)
const {
726 if (!
GetProjection(point, accumulate_s, lateral, min_distance)) {
729 if (*accumulate_s < 0.0) {
732 }
else if (*accumulate_s >
length_) {
740 double* lateral)
const {
741 double distance = 0.0;
742 return GetProjection(point, accumulate_s, lateral, &distance);
746 double* accumulate_s,
double* lateral)
const {
747 double distance = 0.0;
748 return GetProjection(point, heading, accumulate_s, lateral, &distance);
752 double* accumulate_s,
753 double* lateral)
const {
757 if (accumulate_s ==
nullptr || lateral ==
nullptr) {
760 if (*accumulate_s < 0.0) {
762 }
else if (*accumulate_s >
length()) {
766 double warm_start_s = *accumulate_s;
772 while (right_index > left_index + 1) {
773 FindIndex(left_index, right_index, warm_start_s, &mid_index);
774 const auto& segment =
segments_[mid_index];
775 const auto& start_point = segment.start();
776 double delta_x = point.
x() - start_point.x();
777 double delta_y = point.
y() - start_point.y();
778 const auto& unit_direction = segment.unit_direction();
779 double proj = delta_x * unit_direction.x() + delta_y * unit_direction.y();
781 *lateral = unit_direction.x() * delta_y - unit_direction.y() * delta_x;
783 if (proj < segment.length()) {
786 if (mid_index == right_index) {
790 left_index = mid_index + 1;
792 if (mid_index == left_index) {
799 right_index = mid_index - 1;
801 warm_start_s = segment.length() + proj;
807 const double hueristic_start_s,
808 const double hueristic_end_s,
809 double* accumulate_s,
811 double* min_distance)
const {
815 if (accumulate_s ==
nullptr || lateral ==
nullptr ||
816 min_distance ==
nullptr) {
820 *min_distance = std::numeric_limits<double>::infinity();
823 int end_interpolation_index =
static_cast<int>(
825 int min_index = start_interpolation_index;
826 for (
int i = start_interpolation_index; i <= end_interpolation_index; ++i) {
827 const double distance =
segments_[i].DistanceSquareTo(point);
828 if (distance < *min_distance) {
830 *min_distance = distance;
833 *min_distance = std::sqrt(*min_distance);
834 const auto& nearest_seg =
segments_[min_index];
835 const auto prod = nearest_seg.ProductOntoUnit(point);
836 const auto proj = nearest_seg.ProjectOntoUnit(point);
837 if (min_index == 0) {
838 *accumulate_s = std::min(proj, nearest_seg.length());
842 *lateral = (prod > 0.0 ? 1 : -1) * *min_distance;
849 *lateral = (prod > 0.0 ? 1 : -1) * *min_distance;
853 std::max(0.0, std::min(proj, nearest_seg.length()));
854 *lateral = (prod > 0.0 ? 1 : -1) * *min_distance;
860 double* lateral,
double* min_distance)
const {
864 if (accumulate_s ==
nullptr || lateral ==
nullptr ||
865 min_distance ==
nullptr) {
873 *min_distance = std::numeric_limits<double>::infinity();
876 const double distance =
segments_[i].DistanceSquareTo(point);
877 if (distance < *min_distance) {
879 *min_distance = distance;
882 *min_distance = std::sqrt(*min_distance);
883 const auto& nearest_seg =
segments_[min_index];
884 const auto prod = nearest_seg.ProductOntoUnit(point);
885 const auto proj = nearest_seg.ProjectOntoUnit(point);
886 if (min_index == 0) {
887 *accumulate_s = std::min(proj, nearest_seg.length());
891 *lateral = (prod > 0.0 ? 1 : -1) * *min_distance;
898 *lateral = (prod > 0.0 ? 1 : -1) * *min_distance;
902 std::max(0.0, std::min(proj, nearest_seg.length()));
903 *lateral = (prod > 0.0 ? 1 : -1) * *min_distance;
909 double* accumulate_s,
double* lateral,
910 double* min_distance)
const {
914 if (accumulate_s ==
nullptr || lateral ==
nullptr ||
915 min_distance ==
nullptr) {
923 *min_distance = std::numeric_limits<double>::infinity();
928 const double distance =
segments_[i].DistanceSquareTo(point);
929 if (distance < *min_distance) {
931 *min_distance = distance;
934 *min_distance = std::sqrt(*min_distance);
935 const auto& nearest_seg =
segments_[min_index];
936 const auto prod = nearest_seg.ProductOntoUnit(point);
937 const auto proj = nearest_seg.ProjectOntoUnit(point);
938 if (min_index == 0) {
939 *accumulate_s = std::min(proj, nearest_seg.length());
943 *lateral = (prod > 0.0 ? 1 : -1) * *min_distance;
950 *lateral = (prod > 0.0 ? 1 : -1) * *min_distance;
954 std::max(0.0, std::min(proj, nearest_seg.length()));
955 *lateral = (prod > 0.0 ? 1 : -1) * *min_distance;
961 if (heading ==
nullptr) {
982 double* lane_right_width)
const {
983 CHECK_NOTNULL(lane_left_width);
984 CHECK_NOTNULL(lane_right_width);
1003 double* road_right_width)
const {
1004 CHECK_NOTNULL(road_left_width);
1005 CHECK_NOTNULL(road_right_width);
1017 const double s)
const {
1018 if (samples.empty()) {
1024 const int idx =
static_cast<int>(s / kSampleDistance);
1026 return samples.back();
1028 const double ratio = (s - idx * kSampleDistance) / kSampleDistance;
1029 return samples[idx] * (1.0 - ratio) + samples[idx + 1] * ratio;
1033 double accumulate_s = 0.0;
1034 double lateral = 0.0;
1038 double lane_left_width = 0.0;
1039 double lane_right_width = 0.0;
1040 if (!
GetLaneWidth(accumulate_s, &lane_left_width, &lane_right_width)) {
1043 if (lateral < lane_left_width && lateral > -lane_right_width) {
1054 const double radius_sqr = Sqr(box.
diagonal() / 2.0 + width) + kMathEpsilon;
1056 if (segment.DistanceSquareTo(center) > radius_sqr) {
1059 if (box.
DistanceTo(segment) <= width + kMathEpsilon) {
1073 double max_distance_sqr = 0.0;
1074 for (
int i = s + 1; i < t; ++i) {
1078 return sqrt(max_distance_sqr);
1088 for (
int i = s + 1; i < t; ++i) {
1102 const int num_original_points = path.
num_points();
1105 while (last_idx < num_original_points - 1) {
1107 int next_idx = last_idx + 1;
1109 for (; last_idx + delta < num_original_points; delta *= 2) {
1113 next_idx = last_idx + delta;
1115 for (; delta > 0; delta /= 2) {
1116 if (next_idx + delta < num_original_points &&
1121 last_idx = next_idx;
1152 s += segment.length();
1156 const int num_original_points =
static_cast<int>(original_points.size());
1164 const double proj = segment.ProjectOntoUnit(original_points[idx]);
1166 projections_[i] + std::max(0.0, std::min(proj, segment.length())));
1173 double last_projection = -std::numeric_limits<double>::infinity();
1174 for (
int i = 0; i < num_original_points; ++i) {
1178 for (
int i = 0; i + 1 < num_original_points; ++i) {
1185 last_projection = std::numeric_limits<double>::infinity();
1186 for (
int i = num_original_points - 1; i >= 0; --i) {
1190 for (
int i = 0; i + 1 < num_original_points; ++i) {
1204 while (last_index + 1 < num_original_points &&
1209 proj += kSampleDistance;
1217 double* accumulate_s,
double* lateral,
1218 double* min_distance)
const {
1222 if (accumulate_s ==
nullptr || lateral ==
nullptr ||
1223 min_distance ==
nullptr) {
1226 double min_distance_sqr = std::numeric_limits<double>::infinity();
1227 int estimate_nearest_segment_idx = -1;
1228 std::vector<double> distance_sqr_to_segments;
1229 distance_sqr_to_segments.reserve(
segments_.size());
1230 for (
size_t i = 0; i <
segments_.size(); ++i) {
1231 const double distance_sqr =
segments_[i].DistanceSquareTo(point);
1232 distance_sqr_to_segments.push_back(distance_sqr);
1233 if (distance_sqr < min_distance_sqr) {
1234 min_distance_sqr = distance_sqr;
1235 estimate_nearest_segment_idx =
static_cast<int>(i);
1238 if (estimate_nearest_segment_idx < 0) {
1241 const auto& original_segments = path.
segments();
1242 const int num_original_segments =
static_cast<int>(original_segments.size());
1244 double min_distance_sqr_with_error =
1245 Sqr(sqrt(min_distance_sqr) +
1247 *min_distance = std::numeric_limits<double>::infinity();
1248 int nearest_segment_idx = -1;
1249 for (
size_t i = 0; i <
segments_.size(); ++i) {
1250 if (distance_sqr_to_segments[i] >= min_distance_sqr_with_error) {
1255 double max_original_projection = std::numeric_limits<double>::infinity();
1256 if (first_segment_idx < last_segment_idx) {
1258 const double projection = segment.ProjectOntoUnit(point);
1259 const double prod_sqr = Sqr(segment.ProductOntoUnit(point));
1260 if (prod_sqr >= min_distance_sqr_with_error) {
1263 const double scan_distance = sqrt(min_distance_sqr_with_error - prod_sqr);
1264 const double min_projection = projection - scan_distance;
1265 max_original_projection =
projections_[i] + projection + scan_distance;
1266 if (min_projection > 0.0) {
1268 const int sample_index =
1269 std::max(0,
static_cast<int>(limit / kSampleDistance));
1271 first_segment_idx = last_segment_idx;
1274 std::max(first_segment_idx,
1276 if (first_segment_idx >= last_segment_idx) {
1277 first_segment_idx = last_segment_idx;
1279 while (first_segment_idx < last_segment_idx &&
1282 ++first_segment_idx;
1288 bool min_distance_updated =
false;
1289 bool is_within_end_point =
false;
1290 for (
int idx = first_segment_idx; idx <= last_segment_idx; ++idx) {
1294 const auto& original_segment = original_segments[idx];
1295 const double x0 = point.
x() - original_segment.start().x();
1296 const double y0 = point.
y() - original_segment.start().y();
1297 const double ux = original_segment.unit_direction().x();
1298 const double uy = original_segment.unit_direction().y();
1299 double proj = x0 * ux + y0 * uy;
1300 double distance = 0.0;
1302 if (is_within_end_point) {
1305 is_within_end_point =
true;
1306 distance = hypot(x0, y0);
1307 }
else if (proj <= original_segment.length()) {
1308 is_within_end_point =
true;
1309 distance = std::abs(x0 * uy - y0 * ux);
1311 is_within_end_point =
false;
1312 if (idx != last_segment_idx) {
1315 distance = original_segment.end().DistanceTo(point);
1317 if (distance < *min_distance) {
1318 min_distance_updated =
true;
1319 *min_distance = distance;
1320 nearest_segment_idx = idx;
1323 if (min_distance_updated) {
1324 min_distance_sqr_with_error = Sqr(*min_distance +
max_error_);
1327 if (nearest_segment_idx >= 0) {
1328 const auto& segment = original_segments[nearest_segment_idx];
1329 double proj = segment.ProjectOntoUnit(point);
1330 const double prod = segment.ProductOntoUnit(point);
1331 if (nearest_segment_idx > 0) {
1332 proj = std::max(0.0, proj);
1334 if (nearest_segment_idx + 1 < num_original_segments) {
1335 proj = std::min(segment.length(), proj);
1337 *accumulate_s = original_accumulated_s[nearest_segment_idx] + proj;
1338 if ((nearest_segment_idx == 0 && proj < 0.0) ||
1339 (nearest_segment_idx + 1 == num_original_segments &&
1340 proj > segment.length())) {
1343 *lateral = (prod > 0 ? (*min_distance) : -(*min_distance));
1351 double width)
const {
1356 const double radius = box.
diagonal() / 2.0 + width;
1357 const double radius_sqr = Sqr(radius);
1358 const auto& original_segments = path.
segments();
1359 for (
size_t i = 0; i <
segments_.size(); ++i) {
1362 const double radius_sqr_with_error = Sqr(radius +
max_error);
1368 double max_original_projection = std::numeric_limits<double>::infinity();
1369 if (first_segment_idx < last_segment_idx) {
1373 if (prod_sqr >= radius_sqr_with_error) {
1376 const double scan_distance = sqrt(radius_sqr_with_error - prod_sqr);
1377 const double min_projection = projection - scan_distance;
1378 max_original_projection =
projections_[i] + projection + scan_distance;
1379 if (min_projection > 0.0) {
1381 const int sample_index =
1382 std::max(0,
static_cast<int>(limit / kSampleDistance));
1384 first_segment_idx = last_segment_idx;
1387 std::max(first_segment_idx,
1389 if (first_segment_idx >= last_segment_idx) {
1390 first_segment_idx = last_segment_idx;
1392 while (first_segment_idx < last_segment_idx &&
1395 ++first_segment_idx;
1401 for (
int idx = first_segment_idx; idx <= last_segment_idx; ++idx) {
1405 const auto& original_segment = original_segments[idx];
1406 if (original_segment.DistanceSquareTo(center) > radius_sqr) {
1409 if (box.
DistanceTo(original_segment) <= width) {
1417void Path::FindIndex(
int left_index,
int right_index,
double target_s,
1418 int* mid_index)
const {
1420 while (right_index > left_index + 1) {
1421 *mid_index = ((left_index + right_index) >> 1);
1423 left_index = *mid_index;
1427 right_index = *mid_index - 1;
Rectangular (undirected) bounding box in 2-D.
double diagonal() const
Getter of the size of the diagonal of the box
const Vec2d & center() const
Getter of the center of the box
double DistanceTo(const Vec2d &point) const
Determines the distance between the box and a given point
double DistanceSquareTo(const Vec2d &point) const
Compute the square of the shortest distance from a point on the line segment to a point in 2-D.
double ProjectOntoUnit(const Vec2d &point) const
Compute the projection of a vector onto the line segment.
double ProductOntoUnit(const Vec2d &point) const
Compute the cross product of a vector onto the line segment.
Implements a class of 2-dimensional vectors.
double DistanceSquareTo(const Vec2d &other) const
Returns the squared distance to the given vector
double Length() const
Gets the length of the vector
double y() const
Getter for y component
double DistanceTo(const Vec2d &other) const
Returns the distance to the given vector
double x() const
Getter for x component
void Normalize()
Returns the unit vector that is co-linear with this vector
static const HDMap * BaseMapPtr()
const std::vector< OverlapInfoConstPtr > & junctions() const
const std::vector< OverlapInfoConstPtr > & speed_bumps() const
const std::vector< OverlapInfoConstPtr > & stop_signs() const
const std::vector< OverlapInfoConstPtr > & clear_areas() const
const std::vector< OverlapInfoConstPtr > & signals() const
const std::vector< OverlapInfoConstPtr > & parking_spaces() const
const std::vector< OverlapInfoConstPtr > & crosswalks() const
const std::vector< OverlapInfoConstPtr > & pnc_junctions() const
const std::vector< OverlapInfoConstPtr > & yield_signs() const
const std::vector< OverlapInfoConstPtr > & areas() const
const std::vector< OverlapInfoConstPtr > & cross_lanes() const
std::vector< LaneWaypoint > lane_waypoints_
static void RemoveDuplicates(std::vector< MapPathPoint > *points)
void add_lane_waypoint(LaneWaypoint lane_waypoint)
const std::vector< LaneWaypoint > & lane_waypoints() const
static std::vector< MapPathPoint > GetPointsFromSegment(const LaneSegment &segment)
static std::vector< MapPathPoint > GetPointsFromLane(LaneInfoConstPtr lane, const double start_s, const double end_s)
std::string DebugString() const
int num_projection_samples_
bool is_within_max_error(const Path &path, const int s, const int t)
std::vector< common::math::LineSegment2d > segments_
void InitProjections(const Path &path)
std::vector< double > min_original_projections_to_right_
std::vector< int > sampled_max_original_projections_to_left_
void Init(const Path &path)
std::vector< double > max_error_per_segment_
void InitDilute(const Path &path)
double compute_max_error(const Path &path, const int s, const int t)
std::vector< double > projections_
std::vector< int > original_ids_
bool GetProjection(const Path &path, const common::math::Vec2d &point, double *accumulate_s, double *lateral, double *distance) const
std::vector< double > original_projections_
std::vector< double > max_original_projections_to_left_
bool OverlapWith(const Path &path, const common::math::Box2d &box, double width) const
const std::vector< common::math::LineSegment2d > & segments() const
std::vector< MapPathPoint > path_points_
InterpolatedIndex GetIndexFromS(double s) const
bool GetProjectionWithWarmStartS(const common::math::Vec2d &point, double *accumulate_s, double *lateral) const
double GetSample(const std::vector< double > &samples, const double s) const
std::vector< PathOverlap > speed_bump_overlaps_
bool GetProjectionWithHueristicParams(const common::math::Vec2d &point, const double hueristic_start_s, const double hueristic_end_s, double *accumulate_s, double *lateral, double *min_distance) const
std::vector< double > lane_accumulated_s_
double GetLaneRightWidth(const double s) const
bool IsOnPath(const common::math::Vec2d &point) const
std::vector< double > accumulated_s_
std::vector< PathOverlap > stop_sign_overlaps_
bool GetLaneWidth(const double s, double *lane_left_width, double *lane_right_width) const
std::vector< PathOverlap > pnc_junction_overlaps_
std::vector< PathOverlap > parking_space_overlaps_
std::function< const std::vector< OverlapInfoConstPtr > &(const LaneInfo &)> GetOverlapFromLaneFunc
double GetRoadLeftWidth(const double s) const
std::vector< hdmap::LaneSegment > GetLaneSegments(const double start_s, const double end_s) const
std::vector< PathOverlap > crosswalk_overlaps_
std::vector< int > last_point_index_
std::vector< double > lane_left_width_
std::vector< PathOverlap > lane_overlaps_
std::vector< PathOverlap > signal_overlaps_
double GetRoadRightWidth(const double s) const
bool GetHeadingAlongPath(const common::math::Vec2d &point, double *heading) const
const PathOverlap * NextLaneOverlap(double s) const
bool GetRoadWidth(const double s, double *road_left_width, double *road_ight_width) const
bool GetProjection(const common::math::Vec2d &point, double *accumulate_s, double *lateral) const
InterpolatedIndex GetLaneIndexFromS(double s) const
double GetSFromIndex(const InterpolatedIndex &index) const
std::vector< common::math::Vec2d > unit_directions_
std::vector< PathOverlap > yield_sign_overlaps_
std::string DebugString() const
MapPathPoint GetSmoothPoint(const InterpolatedIndex &index) const
std::vector< PathOverlap > clear_area_overlaps_
bool GetNearestPoint(const common::math::Vec2d &point, double *accumulate_s, double *lateral) const
bool OverlapWith(const common::math::Box2d &box, double width) const
std::vector< PathOverlap > area_overlaps_
std::vector< double > road_left_width_
std::vector< double > lane_right_width_
std::vector< common::math::LineSegment2d > segments_
bool use_path_approximation_
std::vector< PathOverlap > junction_overlaps_
std::vector< LaneSegment > lane_segments_to_next_point_
const std::vector< MapPathPoint > & path_points() const
void GetAllOverlaps(GetOverlapFromLaneFunc GetOverlaps_from_lane, std::vector< PathOverlap > *const overlaps) const
std::vector< LaneSegment > lane_segments_
double GetLaneLeftWidth(const double s) const
PathApproximation approximation_
const std::vector< double > & accumulated_s() const
std::vector< double > road_right_width_
Define the LineSegment2d class.
Math-related util functions.
double Sqr(const double x)
constexpr double kMathEpsilon
double AngleDiff(const double from, const double to)
Calculate the difference between angle from and to
std::shared_ptr< const LaneInfo > LaneInfoConstPtr
LaneBoundaryType::Type LeftBoundaryType(const LaneWaypoint &waypoint)
get left boundary type at a waypoint.
LaneBoundaryType::Type RightBoundaryType(const LaneWaypoint &waypoint)
get left boundary type at a waypoint.
LaneWaypoint RightNeighborWaypoint(const LaneWaypoint &waypoint)
get left neighbor lane waypoint.
LaneWaypoint LeftNeighborWaypoint(const LaneWaypoint &waypoint)
get left neighbor lane waypoint.
Define the Polygon2d class.
Some string util functions.
static void Join(std::vector< LaneSegment > *segments)
Join neighboring lane segments if they have the same lane id
std::string DebugString() const
std::string DebugString() const
std::string DebugString() const