25#include <unordered_set>
27#include "absl/strings/str_cat.h"
28#include "absl/strings/str_join.h"
29#include "boost/math/tools/minima.hpp"
52 const std::vector<ReferencePoint>& reference_points)
53 : reference_points_(reference_points),
55 reference_points.begin(), reference_points.end()))) {
56 CHECK_EQ(
static_cast<size_t>(map_path_.
num_points()),
57 reference_points_.size());
61 : map_path_(hdmap_path) {
62 for (
const auto& point : hdmap_path.
path_points()) {
63 DCHECK(!point.lane_waypoints().empty());
64 const auto& lane_waypoint = point.lane_waypoints()[0];
65 reference_points_.emplace_back(
68 CHECK_EQ(
static_cast<size_t>(map_path_.
num_points()),
69 reference_points_.size());
74 AWARN <<
"The other reference line is empty.";
77 auto first_point = reference_points_.front();
79 if (!other.
XYToSL(first_point, &first_sl)) {
80 AWARN <<
"Failed to project the first point to the other reference line.";
83 bool first_join = first_sl.
s() > 0 && first_sl.
s() < other.
Length();
85 auto last_point = reference_points_.back();
87 if (!other.
XYToSL(last_point, &last_sl)) {
88 AWARN <<
"Failed to project the last point to the other reference line.";
91 bool last_join = last_sl.
s() > 0 && last_sl.
s() < other.
Length();
93 if (!first_join && !last_join) {
94 AERROR <<
"These reference lines are not connected.";
100 auto lower = accumulated_s.begin();
101 static constexpr double kStitchingError = 1e-1;
103 if (first_sl.
l() > kStitchingError) {
104 AERROR <<
"lateral stitching error on first join of reference line too "
105 "big, stitching fails";
108 lower = std::lower_bound(accumulated_s.begin(), accumulated_s.end(),
110 size_t start_i = std::distance(accumulated_s.begin(), lower);
111 reference_points_.insert(reference_points_.begin(), other_points.begin(),
112 other_points.begin() + start_i);
115 if (last_sl.
l() > kStitchingError) {
116 AERROR <<
"lateral stitching error on first join of reference line too "
117 "big, stitching fails";
120 auto upper = std::upper_bound(lower, accumulated_s.end(), last_sl.
s());
121 auto end_i = std::distance(accumulated_s.begin(), upper);
122 reference_points_.insert(reference_points_.end(),
123 other_points.begin() + end_i, other_points.end());
125 map_path_ =
MapPath(std::move(std::vector<hdmap::MapPathPoint>(
126 reference_points_.begin(), reference_points_.end())));
132 double min_dist = std::numeric_limits<double>::max();
133 size_t min_index = 0;
134 for (
size_t i = 0; i < reference_points_.size(); ++i) {
135 const double distance = DistanceXY(xy, reference_points_[i]);
136 if (distance < min_dist) {
141 return reference_points_[min_index];
145 const double look_backward,
146 const double look_forward) {
148 if (!
XYToSL(point, &sl)) {
152 return Segment(sl.
s(), look_backward, look_forward);
156 const double look_forward) {
161 std::distance(accumulated_s.begin(),
162 std::lower_bound(accumulated_s.begin(), accumulated_s.end(),
167 std::distance(accumulated_s.begin(),
168 std::upper_bound(accumulated_s.begin(), accumulated_s.end(),
171 if (end_index - start_index < 2) {
172 AERROR <<
"Too few reference points after shrinking.";
177 std::vector<ReferencePoint>(reference_points_.begin() + start_index,
178 reference_points_.begin() + end_index);
180 map_path_ =
MapPath(std::vector<hdmap::MapPathPoint>(
181 reference_points_.begin(), reference_points_.end()));
187 if (reference_points_.empty()) {
192 XYToSL(path_point, &sl_point);
194 frenet_frame_point.set_s(sl_point.
s());
195 frenet_frame_point.set_l(sl_point.
l());
197 const double theta = path_point.
theta();
198 const double kappa = path_point.
kappa();
199 const double l = frenet_frame_point.
l();
203 const double theta_ref = ref_point.
heading();
204 const double kappa_ref = ref_point.
kappa();
205 const double dkappa_ref = ref_point.
dkappa();
208 theta_ref, theta, l, kappa_ref);
211 theta_ref, theta, kappa_ref, kappa, dkappa_ref, l);
212 frenet_frame_point.set_dl(dl);
213 frenet_frame_point.set_ddl(ddl);
214 return frenet_frame_point;
217std::pair<std::array<double, 3>, std::array<double, 3>>
219 ACHECK(!reference_points_.empty());
223 {traj_point.path_point().x(), traj_point.path_point().y()}, &sl_point);
225 std::array<double, 3> s_condition;
226 std::array<double, 3> l_condition;
229 sl_point.
s(), ref_point.
x(), ref_point.
y(), ref_point.
heading(),
233 &s_condition, &l_condition);
234 AINFO <<
"planning_start_point x,y,the,k: " << std::fixed
239 AINFO <<
"ref point x y the ka dka" << std::fixed << ref_point.
x() <<
","
240 << ref_point.
y() <<
"," << ref_point.
heading() <<
","
242 return std::make_pair(s_condition, l_condition);
247 if (s < accumulated_s.front() - 1e-2) {
248 AWARN <<
"The requested s: " << s <<
" < 0.";
249 return reference_points_.front();
251 if (s > accumulated_s.back() + 1e-2) {
252 AWARN <<
"The requested s: " << s
253 <<
" > reference line length: " << accumulated_s.back();
254 return reference_points_.back();
257 std::lower_bound(accumulated_s.begin(), accumulated_s.end(), s);
258 if (it_lower == accumulated_s.begin()) {
259 return reference_points_.front();
261 auto index = std::distance(accumulated_s.begin(), it_lower);
262 if (std::fabs(accumulated_s[index - 1] - s) <
263 std::fabs(accumulated_s[index] - s)) {
264 return reference_points_[index - 1];
266 return reference_points_[index];
271 if (s < accumulated_s.front() - 1e-2) {
272 AWARN <<
"The requested s: " << s <<
" < 0.";
275 if (s > accumulated_s.back() + 1e-2) {
276 AWARN <<
"The requested s: " << s <<
" > reference line length "
277 << accumulated_s.back();
278 return reference_points_.size() - 1;
281 std::lower_bound(accumulated_s.begin(), accumulated_s.end(), s);
282 return std::distance(accumulated_s.begin(), it_lower);
286 double start_s,
double end_s)
const {
293 std::vector<ReferencePoint> ref_points;
296 if (start_index < end_index) {
297 ref_points.assign(reference_points_.begin() + start_index,
298 reference_points_.begin() + end_index);
305 if (s < accumulated_s.front() - 1e-2) {
306 AWARN <<
"The requested s: " << s <<
" < 0.";
307 return reference_points_.front();
309 if (s > accumulated_s.back() + 1e-2) {
310 AWARN <<
"The requested s: " << s
311 <<
" > reference line length: " << accumulated_s.back();
312 return reference_points_.back();
317 size_t index = interpolate_index.
id;
318 size_t next_index = index + 1;
319 if (next_index >= reference_points_.size()) {
320 next_index = reference_points_.size() - 1;
323 const auto& p0 = reference_points_[index];
324 const auto& p1 = reference_points_[next_index];
326 const double s0 = accumulated_s[index];
327 const double s1 = accumulated_s[next_index];
328 return InterpolateWithMatchedIndex(p0, s0, p1, s1, interpolate_index);
331double ReferenceLine::FindMinDistancePoint(
const ReferencePoint& p0,
334 const double s1,
const double x,
336 auto func_dist_square = [&p0, &p1, &s0, &s1, &x, &y](
const double s) {
337 auto p = Interpolate(p0, s0, p1, s1, s);
338 double dx = p.x() - x;
339 double dy = p.y() - y;
340 return dx * dx + dy * dy;
343 return ::boost::math::tools::brent_find_minima(func_dist_square, s0, s1, 8)
348 const double y)
const {
349 CHECK_GE(reference_points_.size(), 0U);
351 auto func_distance_square = [](
const ReferencePoint& point,
const double x,
353 double dx = point.
x() - x;
354 double dy = point.
y() - y;
355 return dx * dx + dy * dy;
358 double d_min = func_distance_square(reference_points_.front(), x, y);
359 size_t index_min = 0;
361 for (
size_t i = 1; i < reference_points_.size(); ++i) {
362 double d_temp = func_distance_square(reference_points_[i], x, y);
363 if (d_temp < d_min) {
369 size_t index_start = index_min == 0 ? index_min : index_min - 1;
371 index_min + 1 == reference_points_.size() ? index_min : index_min + 1;
373 if (index_start == index_end) {
374 return reference_points_[index_start];
380 double s = ReferenceLine::FindMinDistancePoint(
381 reference_points_[index_start], s0, reference_points_[index_end], s1, x,
384 return Interpolate(reference_points_[index_start], s0,
385 reference_points_[index_end], s1, s);
391 AERROR <<
"The reference line has too few points.";
404 double warm_start_s)
const {
405 double s = warm_start_s;
407 if (warm_start_s < 0.0) {
409 AERROR <<
"Cannot get nearest point from path.";
414 AERROR <<
"Cannot get nearest point from path with warm_start_s: "
428 double warm_start_s)
const {
429 double s = warm_start_s;
431 if (warm_start_s < 0.0) {
433 AERROR <<
"Cannot get nearest point from path.";
438 AERROR <<
"Cannot get nearest point from path with warm_start_s: "
451 double hueristic_start_s,
452 double hueristic_end_s)
const {
455 double min_distance = 0.0;
457 hueristic_end_s, &s, &l,
459 AERROR <<
"Cannot get nearest point from path with hueristic_start_s: "
460 << hueristic_start_s <<
" hueristic_end_s: " << hueristic_end_s;
474 double s = s0 + index.
offset;
475 DCHECK_LE(s0 - 1.0e-6, s) <<
"s: " << s <<
" is less than s0 : " << s0;
476 DCHECK_LE(s, s1 + 1.0e-6) <<
"s: " << s <<
" is larger than s1: " << s1;
483 return ReferencePoint(map_path_point, kappa, dkappa);
486ReferencePoint ReferenceLine::Interpolate(
const ReferencePoint& p0,
488 const ReferencePoint& p1,
489 const double s1,
const double s) {
493 DCHECK_LE(s0 - 1.0e-6, s) <<
" s: " << s <<
" is less than s0 :" << s0;
494 DCHECK_LE(s, s1 + 1.0e-6) <<
"s: " << s <<
" is larger than s1: " << s1;
498 const double heading =
502 std::vector<hdmap::LaneWaypoint> waypoints;
503 if (!p0.lane_waypoints().empty() && !p1.lane_waypoints().empty()) {
504 const auto& p0_waypoint = p0.lane_waypoints()[0];
505 if ((s - s0) + p0_waypoint.s <= p0_waypoint.lane->total_length()) {
506 const double lane_s = p0_waypoint.s + s - s0;
507 waypoints.emplace_back(p0_waypoint.lane, lane_s);
509 const auto& p1_waypoint = p1.lane_waypoints()[0];
510 if (p1_waypoint.lane->id().id() != p0_waypoint.lane->id().id() &&
511 p1_waypoint.s - (s1 - s) >= 0) {
512 const double lane_s = p1_waypoint.s - (s1 - s);
513 waypoints.emplace_back(p1_waypoint.lane, lane_s);
515 if (waypoints.empty()) {
516 const double lane_s = p0_waypoint.s;
517 waypoints.emplace_back(p0_waypoint.lane, lane_s);
520 return ReferencePoint(hdmap::MapPathPoint({x, y}, heading, waypoints), kappa,
525 return reference_points_;
531 double*
const lane_right_width)
const {
536 if (!map_path_.
GetLaneWidth(s, lane_left_width, lane_right_width)) {
548 if (ref_point.lane_waypoints().empty()) {
551 *l_offset = ref_point.lane_waypoints().front().l;
556 double*
const road_right_width)
const {
560 return map_path_.
GetRoadWidth(s, road_left_width, road_right_width);
565 CHECK_NOTNULL(hdmap);
579 std::vector<hdmap::RoadInfoConstPtr> roads;
580 hdmap->
GetRoads(point, 4.0, &roads);
581 for (
auto road : roads) {
583 road_type = road->type();
594 const auto waypoint = ref_point.lane_waypoints().front();
600 const double s, std::vector<hdmap::LaneInfoConstPtr>* lanes)
const {
601 CHECK_NOTNULL(lanes);
603 std::unordered_set<hdmap::LaneInfoConstPtr> lane_set;
604 for (
const auto& lane_waypoint : ref_point.lane_waypoints()) {
605 if (common::util::InsertIfNotPresent(&lane_set, lane_waypoint.lane)) {
606 lanes->push_back(lane_waypoint.lane);
612 double lane_left_width = 0.0;
613 double lane_right_width = 0.0;
616 double driving_width = std::max(lane_left_width - sl_boundary.
end_l(),
617 lane_right_width + sl_boundary.
start_l());
618 driving_width = std::min(lane_left_width + lane_right_width, driving_width);
619 ADEBUG <<
"Driving width [" << driving_width <<
"].";
620 return driving_width;
625 if (!
XYToSL(vec2d_point, &sl_point)) {
635 double middle_s = (sl_boundary.
start_s() + sl_boundary.
end_s()) / 2.0;
636 double lane_left_width = 0.0;
637 double lane_right_width = 0.0;
638 map_path_.
GetLaneWidth(middle_s, &lane_left_width, &lane_right_width);
639 return sl_boundary.
start_l() <= lane_left_width &&
640 sl_boundary.
end_l() >= -lane_right_width;
644 if (sl_point.
s() <= 0 || sl_point.
s() > map_path_.
length()) {
647 double left_width = 0.0;
648 double right_width = 0.0;
650 if (!
GetLaneWidth(sl_point.
s(), &left_width, &right_width)) {
654 return sl_point.
l() >= -right_width && sl_point.
l() <= left_width;
671 double middle_s = (sl_boundary.
start_s() + sl_boundary.
end_s()) / 2.0;
672 double road_left_width = 0.0;
673 double road_right_width = 0.0;
674 map_path_.
GetRoadWidth(middle_s, &road_left_width, &road_right_width);
675 return sl_boundary.
start_l() <= road_left_width &&
676 sl_boundary.
end_l() >= -road_right_width;
680 if (sl_point.
s() <= 0 || sl_point.
s() > map_path_.
length()) {
683 double road_left_width = 0.0;
684 double road_right_width = 0.0;
686 if (!
GetRoadWidth(sl_point.
s(), &road_left_width, &road_right_width)) {
690 return sl_point.
l() >= -road_right_width && sl_point.
l() <= road_left_width;
700 double distance = 0.0;
702 &s, &l, &distance)) {
703 AERROR <<
"Cannot get projection point from path.";
708 auto rotated_box = box;
711 std::vector<common::math::Vec2d> corners;
712 rotated_box.GetAllCorners(&corners);
714 double min_s(std::numeric_limits<double>::max());
715 double max_s(std::numeric_limits<double>::lowest());
716 double min_l(std::numeric_limits<double>::max());
717 double max_l(std::numeric_limits<double>::lowest());
719 for (
const auto& point : corners) {
722 min_s = std::fmin(min_s, point.x() - rotated_box.center().x() + s);
723 max_s = std::fmax(max_s, point.x() - rotated_box.center().x() + s);
724 min_l = std::fmin(min_l, point.y() - rotated_box.center().y() + l);
725 max_l = std::fmax(max_l, point.y() - rotated_box.center().y() + l);
727 sl_boundary->set_start_s(min_s);
728 sl_boundary->set_end_s(max_s);
729 sl_boundary->set_start_l(min_l);
730 sl_boundary->set_end_l(max_l);
736 double warm_start_s)
const {
737 std::vector<common::math::Vec2d> corners;
744 double warm_start_s)
const {
745 std::vector<common::math::Vec2d> corners = polygon.
points();
750 const std::vector<common::math::Vec2d>& corners,
751 SLBoundary*
const sl_boundary,
double warm_start_s)
const {
752 double start_s(std::numeric_limits<double>::max());
753 double end_s(std::numeric_limits<double>::lowest());
754 double start_l(std::numeric_limits<double>::max());
755 double end_l(std::numeric_limits<double>::lowest());
758 std::vector<SLPoint> sl_corners;
759 std::vector<common::math::Vec2d> obs_corners = corners;
763 double min_dist = std::numeric_limits<double>::max();
764 for (
int i = 0; i < obs_corners.size(); ++i) {
765 double ego_dist = ego_position_.
DistanceTo(obs_corners[i]);
766 if (ego_dist < min_dist) {
771 std::rotate(obs_corners.begin(), obs_corners.begin() + first_index,
774 ADEBUG <<
"first_point: " << std::setprecision(9) << first_point.
x() <<
", "
777 if (!
XYToSL(first_point, &first_sl_point, warm_start_s)) {
778 AERROR <<
"Failed to get projection for point: "
779 << first_point.
DebugString() <<
" on reference line.";
782 sl_corners.push_back(std::move(first_sl_point));
785 double hueristic_start_s = 0.0;
786 double hueristic_end_s = 0.0;
787 double distance = 0.0;
789 for (
size_t i = 1; i < obs_corners.size(); ++i) {
790 distance = obs_corners[i].DistanceTo(obs_corners[i - 1]);
791 hueristic_start_s = sl_corners.back().
s() - 2.0 * distance;
792 hueristic_end_s = sl_corners.back().s() + 2.0 * distance;
793 if (!
XYToSL(obs_corners[i], &sl_point, hueristic_start_s,
795 AERROR <<
"Failed to get projection for point: "
796 << obs_corners[i].DebugString() <<
" on reference line.";
799 sl_corners.push_back(std::move(sl_point));
802 for (
size_t i = 0; i < obs_corners.size(); ++i) {
804 auto index1 = (i + 1) % obs_corners.size();
805 const auto& p0 = obs_corners[index0];
806 const auto& p1 = obs_corners[index1];
808 const auto p_mid = (p0 + p1) * 0.5;
809 distance = obs_corners[index0].DistanceTo(p_mid);
810 hueristic_start_s = sl_corners[index0].s() - 2.0 * distance;
811 hueristic_end_s = sl_corners[index0].s() + 2.0 * distance;
813 if (!
XYToSL(p_mid, &sl_point_mid, hueristic_start_s, hueristic_end_s)) {
814 AERROR <<
"Failed to get projection for point: " << p_mid.DebugString()
815 <<
" on reference line.";
819 Vec2d v0(sl_corners[index1].s() - sl_corners[index0].s(),
820 sl_corners[index1].l() - sl_corners[index0].l());
822 Vec2d v1(sl_point_mid.
s() - sl_corners[index0].s(),
823 sl_point_mid.
l() - sl_corners[index0].l());
825 *sl_boundary->add_boundary_point() = sl_corners[index0];
829 *sl_boundary->add_boundary_point() = sl_point_mid;
834 start_s = std::fmin(start_s, sl_point.
s());
835 end_s = std::fmax(end_s, sl_point.
s());
836 start_l = std::fmin(start_l, sl_point.
l());
837 end_l = std::fmax(end_l, sl_point.
l());
840 sl_boundary->set_start_s(start_s);
841 sl_boundary->set_end_s(end_s);
842 sl_boundary->set_start_l(start_l);
843 sl_boundary->set_end_l(end_l);
848 const double start_s,
const double end_s)
const {
854 double start_s(std::numeric_limits<double>::max());
855 double end_s(std::numeric_limits<double>::lowest());
856 double start_l(std::numeric_limits<double>::max());
857 double end_l(std::numeric_limits<double>::lowest());
858 for (
const auto& point : polygon.
point()) {
860 if (!
XYToSL(point, &sl_point)) {
861 AERROR <<
"Failed to get projection for point: " << point.DebugString()
862 <<
" on reference line.";
865 start_s = std::fmin(start_s, sl_point.
s());
866 end_s = std::fmax(end_s, sl_point.
s());
867 start_l = std::fmin(start_l, sl_point.
l());
868 end_l = std::fmax(end_l, sl_point.
l());
870 sl_boundary->set_start_s(start_s);
871 sl_boundary->set_end_s(end_s);
872 sl_boundary->set_start_l(start_l);
873 sl_boundary->set_end_l(end_l);
890 double lane_left_width = 0.0;
891 double lane_right_width = 0.0;
892 const double mid_s = (sl_boundary.
start_s() + sl_boundary.
end_s()) / 2.0;
893 if (mid_s < 0 || mid_s >
Length()) {
894 ADEBUG <<
"ref_s is out of range: " << mid_s;
897 if (!map_path_.
GetLaneWidth(mid_s, &lane_left_width, &lane_right_width)) {
898 AERROR <<
"Failed to get width at s = " << mid_s;
901 if (sl_boundary.
start_l() > 0) {
902 return sl_boundary.
start_l() < lane_left_width;
904 return sl_boundary.
end_l() > -lane_right_width;
910 std::min(reference_points_.size(),
911 static_cast<size_t>(FLAGS_trajectory_point_num_for_debug));
913 "point num:", reference_points_.size(),
914 absl::StrJoin(reference_points_.begin(),
915 reference_points_.begin() + limit,
"",
920 for (
const auto& speed_limit : speed_limit_) {
921 if (s >= speed_limit.start_s && s <= speed_limit.end_s) {
922 return speed_limit.speed_limit;
927 double speed_limit = FLAGS_planning_upper_speed_limit;
928 bool speed_limit_found =
false;
929 for (
const auto& lane_waypoint : map_path_point.lane_waypoints()) {
930 if (lane_waypoint.lane ==
nullptr) {
931 AWARN <<
"lane_waypoint.lane is nullptr.";
934 speed_limit_found =
true;
936 std::fmin(lane_waypoint.lane->lane().speed_limit(), speed_limit);
939 if (!speed_limit_found) {
941 speed_limit = FLAGS_default_city_road_speed_limit;
944 speed_limit = FLAGS_default_highway_speed_limit;
952 double speed_limit) {
953 std::vector<SpeedLimit> new_speed_limit;
954 for (
const auto& limit : speed_limit_) {
955 if (start_s >= limit.end_s || end_s <= limit.start_s) {
956 new_speed_limit.emplace_back(limit);
959 double min_speed = std::min(limit.speed_limit, speed_limit);
960 if (start_s >= limit.start_s) {
961 new_speed_limit.emplace_back(limit.start_s, start_s, min_speed);
962 if (end_s <= limit.end_s) {
963 new_speed_limit.emplace_back(start_s, end_s, min_speed);
964 new_speed_limit.emplace_back(end_s, limit.end_s, limit.speed_limit);
966 new_speed_limit.emplace_back(start_s, limit.end_s, min_speed);
969 new_speed_limit.emplace_back(start_s, limit.start_s, speed_limit);
970 if (end_s <= limit.end_s) {
971 new_speed_limit.emplace_back(limit.start_s, end_s, min_speed);
972 new_speed_limit.emplace_back(end_s, limit.end_s, limit.speed_limit);
974 new_speed_limit.emplace_back(limit.start_s, limit.end_s, min_speed);
977 start_s = limit.end_s;
978 end_s = std::max(end_s, limit.end_s);
981 speed_limit_.clear();
982 if (end_s > start_s) {
983 new_speed_limit.emplace_back(start_s, end_s, speed_limit);
985 for (
const auto& limit : new_speed_limit) {
986 if (limit.start_s < limit.end_s) {
987 speed_limit_.emplace_back(limit);
990 std::sort(speed_limit_.begin(), speed_limit_.end(),
991 [](
const SpeedLimit& a,
const SpeedLimit& b) {
992 if (a.start_s != b.start_s) {
993 return a.start_s < b.start_s;
995 if (a.end_s != b.end_s) {
996 return a.end_s < b.end_s;
998 return a.speed_limit < b.speed_limit;
Defines the templated Angle class.
static Angle from_rad(const double value)
Constructs an Angle object from an angle in radians (factory).
Rectangular (undirected) bounding box in 2-D.
std::string DebugString() const
Gets a human-readable description of the box
void GetAllCorners(std::vector< Vec2d > *const corners) const
Getter of the corners of the box
void RotateFromCenter(const double rotate_angle)
Rotate from center.
const Vec2d & center() const
Getter of the center of the box
static void cartesian_to_frenet(const double rs, const double rx, const double ry, const double rtheta, const double rkappa, const double rdkappa, const double x, const double y, const double v, const double a, const double theta, const double kappa, std::array< double, 3 > *const ptr_s_condition, std::array< double, 3 > *const ptr_d_condition)
Convert a vehicle state in Cartesian frame to Frenet frame.
static double CalculateSecondOrderLateralDerivative(const double theta_ref, const double theta, const double kappa_ref, const double kappa, const double dkappa_ref, const double l)
static double CalculateLateralDerivative(const double theta_ref, const double theta, const double l, const double kappa_ref)
: given sl, theta, and road's theta, kappa, extract derivative l, second order derivative l:
The class of polygon in 2-D.
const std::vector< Vec2d > & points() const
Get the vertices of the polygon.
Implements a class of 2-dimensional vectors.
void set_x(const double x)
Setter for x component
std::string DebugString() const
Returns a human-readable string representing this object
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 set_y(const double y)
Setter for y component
double CrossProd(const Vec2d &other) const
Returns the "cross" product between these two Vec2d (non-standard).
static const HDMap * BaseMapPtr()
High-precision map loader interface.
int GetRoads(const apollo::common::PointENU &point, double distance, std::vector< RoadInfoConstPtr > *roads) const
get all roads in certain range
void set_heading(const double heading)
InterpolatedIndex GetIndexFromS(double s) const
bool GetProjectionWithWarmStartS(const common::math::Vec2d &point, double *accumulate_s, double *lateral) const
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
bool GetLaneWidth(const double s, double *lane_left_width, double *lane_right_width) const
std::vector< hdmap::LaneSegment > GetLaneSegments(const double start_s, const double end_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
MapPathPoint GetSmoothPoint(const InterpolatedIndex &index) const
bool OverlapWith(const common::math::Box2d &box, double width) const
const std::vector< common::math::Vec2d > & unit_directions() const
const std::vector< MapPathPoint > & path_points() const
const std::vector< double > & accumulated_s() const
bool GetApproximateSLBoundary(const common::math::Box2d &box, const double start_s, const double end_s, SLBoundary *const sl_boundary) const
bool IsOnRoad(const common::SLPoint &sl_point) const
: check if a box/point is on road (not on sideways/medians) along reference line
bool Segment(const common::math::Vec2d &point, const double distance_backward, const double distance_forward)
std::string DebugString() const
const hdmap::Path & map_path() const
bool IsOnLane(const common::SLPoint &sl_point) const
: check if a box/point is on lane along reference line
void AddSpeedLimit(double start_s, double end_s, double speed_limit)
void GetLaneBoundaryType(const double s, hdmap::LaneBoundaryType::Type *const left_boundary_type, hdmap::LaneBoundaryType::Type *const right_boundary_type) const
ReferencePoint GetReferencePoint(const double s) const
std::vector< hdmap::LaneSegment > GetLaneSegments(const double start_s, const double end_s) const
std::pair< std::array< double, 3 >, std::array< double, 3 > > ToFrenetFrame(const common::TrajectoryPoint &traj_point) const
double GetDrivingWidth(const SLBoundary &sl_boundary) const
size_t GetNearestReferenceIndex(const double s) const
bool GetSLBoundary(const common::math::Box2d &box, SLBoundary *const sl_boundary, double warm_start_s=-1.0) const
Get the SL Boundary of the box.
bool Stitch(const ReferenceLine &other)
Stitch current reference line with the other reference line The stitching strategy is to use current ...
bool GetRoadWidth(const double s, double *const road_left_width, double *const road_right_width) const
void GetLaneFromS(const double s, std::vector< hdmap::LaneInfoConstPtr > *lanes) const
bool SLToXY(const common::SLPoint &sl_point, common::math::Vec2d *const xy_point) const
bool XYToSL(const common::math::Vec2d &xy_point, common::SLPoint *const sl_point, double warm_start_s=-1.0) const
Transvert Cartesian coordinates to Frenet.
std::vector< ReferencePoint > GetReferencePoints(double start_s, double end_s) const
hdmap::Road::Type GetRoadType(const double s) const
ReferencePoint GetNearestReferencePoint(const common::math::Vec2d &xy) const
bool HasOverlap(const common::math::Box2d &box) const
check if any part of the box has overlap with the road.
common::FrenetFramePoint GetFrenetPoint(const common::PathPoint &path_point) const
double GetSpeedLimitFromS(const double s) const
bool IsBlockRoad(const common::math::Box2d &box2d, double gap) const
Check if a box is blocking the road surface.
bool GetLaneWidth(const double s, double *const lane_left_width, double *const lane_right_width) const
const std::vector< ReferencePoint > & reference_points() const
bool GetOffsetToMap(const double s, double *l_offset) const
Planning module main class.
Linear interpolation functions.
T lerp(const T &x0, const double t0, const T &x1, const double t1, const double t)
Linear interpolation between two points of type T.
constexpr double kMathEpsilon
double slerp(const double a0, const double t0, const double a1, const double t1, const double t)
Spherical linear interpolation between two angles.
double DistanceXY(const U &u, const V &v)
calculate the distance beteween Point u and Point v, which are all have member function x() and y() i...
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.
Some string util functions.
optional PathPoint path_point
repeated apollo::common::PointENU point
repeated apollo::common::SLPoint boundary_point