Apollo 11.0
自动驾驶开放平台
sl_polygon.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
21#pragma once
22
23#include <algorithm>
24#include <limits>
25#include <string>
26#include <vector>
27
28#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
29#include "modules/common_msgs/planning_msgs/sl_boundary.pb.h"
30
31#include "cyber/common/log.h"
34
35namespace apollo {
36namespace planning {
37
40
41class SLPolygon {
42 public:
50 SLPolygon() = default;
51 explicit SLPolygon(
52 SLBoundary sl_boundary, std::string id = "",
54 bool print_log = false);
55 virtual ~SLPolygon() = default;
56 static double GetInterpolatedLFromBoundary(
57 const std::vector<SLPoint>& boundary, const double s);
58 const std::vector<SLPoint>& LeftBoundary() const { return left_boundary_; }
59 const std::vector<SLPoint>& RightBoundary() const { return right_boundary_; }
60 const double GetLeftBoundaryByS(const double s) const {
61 if (nudge_type_ == NudgeType::RIGHT_NUDGE) {
62 return std::numeric_limits<double>::max();
63 }
64 return GetInterpolatedSFromBoundary(left_boundary_, s);
65 }
66 const double GetRightBoundaryByS(const double s) const {
67 if (nudge_type_ == NudgeType::LEFT_NUDGE) {
68 return std::numeric_limits<double>::lowest();
69 }
70 return GetInterpolatedSFromBoundary(right_boundary_, s);
71 }
72 static double GetInterpolatedSFromBoundary(
73 const std::vector<SLPoint>& boundary, double s);
74 double MinS() const { return min_s_point_.s(); }
75 double MaxS() const { return max_s_point_.s(); }
76 double MinL() const { return min_l_point_.l(); }
77 double MaxL() const { return max_l_point_.l(); }
78 SLPoint MinSPoint() const { return min_s_point_; }
79 SLPoint MaxSPoint() const { return max_s_point_; }
80 SLPoint MinLPoint() const { return min_l_point_; }
81 SLPoint MaxLPoint() const { return max_l_point_; }
82 NudgeType NudgeInfo() const { return nudge_type_; }
83 void SetNudgeInfo(NudgeType nudge_type) { nudge_type_ = nudge_type; }
84 void PrintToLog(std::string prefix = "") const;
85 void PrintToLogBlock() const;
86 std::string id() const { return id_; }
87
88 void SetOverlapeWithReferCenter(bool overlap) {
89 overlape_with_refer_center_ = overlap;
90 }
91 bool OverlapeWithReferCenter() const { return overlape_with_refer_center_; }
92 void SetOverlapeSizeWithReference(double abs_l) {
93 overlape_size_with_reference_ =
94 std::max(abs_l, overlape_size_with_reference_);
95 }
97 return overlape_size_with_reference_;
98 }
99
100 std::array<bool, 2>& is_passable() { return is_passable_; }
101 void UpdatePassableInfo(double left_bound, double right_bound,
102 double left_buffer, double right_buffer,
103 double check_s);
104 double MinRadiusStopDistance(double adc_min_l, double adc_max_l,
105 double ego_half_width);
106 PerceptionObstacle::Type ObstacleType() const { return obstacle_type_; }
107
108 private:
109 std::vector<SLPoint> left_boundary_;
110 std::vector<SLPoint> right_boundary_;
111 SLBoundary sl_boundary_;
112 SLPoint min_s_point_;
113 SLPoint max_s_point_;
114 SLPoint min_l_point_;
115 SLPoint max_l_point_;
116 std::string id_;
117 bool overlape_with_refer_center_ = false;
118 double overlape_size_with_reference_ = 0.0;
119 NudgeType nudge_type_ = NudgeType::UNDEFINED;
120 std::array<bool, 2> is_passable_ = {true, true};
121 double min_radius_stop_distance_ = -1.0;
123};
124
125} // namespace planning
126} // namespace apollo
double MinRadiusStopDistance(double adc_min_l, double adc_max_l, double ego_half_width)
virtual ~SLPolygon()=default
const double GetLeftBoundaryByS(const double s) const
Definition sl_polygon.h:60
std::array< bool, 2 > & is_passable()
Definition sl_polygon.h:100
SLPoint MinLPoint() const
Definition sl_polygon.h:80
PerceptionObstacle::Type ObstacleType() const
Definition sl_polygon.h:106
const std::vector< SLPoint > & LeftBoundary() const
Definition sl_polygon.h:58
bool OverlapeWithReferCenter() const
Definition sl_polygon.h:91
void UpdatePassableInfo(double left_bound, double right_bound, double left_buffer, double right_buffer, double check_s)
void PrintToLog(std::string prefix="") const
Definition sl_polygon.cc:60
void SetOverlapeWithReferCenter(bool overlap)
Definition sl_polygon.h:88
static double GetInterpolatedLFromBoundary(const std::vector< SLPoint > &boundary, const double s)
Definition sl_polygon.cc:41
const std::vector< SLPoint > & RightBoundary() const
Definition sl_polygon.h:59
NudgeType NudgeInfo() const
Definition sl_polygon.h:82
static double GetInterpolatedSFromBoundary(const std::vector< SLPoint > &boundary, double s)
const double GetRightBoundaryByS(const double s) const
Definition sl_polygon.h:66
std::string id() const
Definition sl_polygon.h:86
double OverlapeSizeWithReference() const
Definition sl_polygon.h:96
SLPoint MaxSPoint() const
Definition sl_polygon.h:79
void SetNudgeInfo(NudgeType nudge_type)
Definition sl_polygon.h:83
void SetOverlapeSizeWithReference(double abs_l)
Definition sl_polygon.h:92
SLPoint MinSPoint() const
Definition sl_polygon.h:78
SLPoint MaxLPoint() const
Definition sl_polygon.h:81
Planning module main class.
class register implement
Definition arena_queue.h:37
Defines the Vec2d class.