Apollo 11.0
自动驾驶开放平台
nudge_info.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 <limits>
24#include <list>
25#include <set>
26#include <string>
27#include <tuple>
28#include <unordered_map>
29#include <utility>
30#include <vector>
31
32#include "modules/common_msgs/basic_msgs/pnc_point.pb.h"
33
34#include "cyber/common/log.h"
35#include "cyber/time/clock.h"
39
40namespace apollo {
41namespace planning {
42
43using common::SLPoint;
44using common::math::Polygon2d;
45
47 double left_lane_remain = std::numeric_limits<double>::min();
48 double left_road_remain = std::numeric_limits<double>::min();
49 double right_lane_remain = std::numeric_limits<double>::min();
50 double right_road_remain = std::numeric_limits<double>::min();
53};
54
55enum class NudgeType {
56 NONE = 0,
57 LEFT = 1, // left cross line
58 RIGHT = 2, // right cross line
59 WAITING = 3,
60};
61
67 bool is_passable = false;
68 bool is_all_on_lane = false;
69 double nudge_probability = 0.0;
70 double tracking_time = 0.0;
71 double start_track_time = std::numeric_limits<double>::max();
72 double last_track_time = 0;
74
78
79 void Clear() {
81 tracking_time = 0.0;
83 }
84
85 void PrintPolygonInfo(std::string obs_id) {
86 if (origin_polygon.points().size() > 0) {
87 PrintCurves print_curve;
88 for (const auto& p : origin_polygon.points()) {
89 print_curve.AddPoint(obs_id + "_BlockObsPolygon", p.x(), p.y());
90 }
91 print_curve.AddPoint(
92 obs_id + "_BlockObsPolygon", origin_polygon.points()[0].x(), origin_polygon.points()[0].y());
93 print_curve.PrintToLog();
94 }
95 }
96};
97
98class NudgeInfo {
99public:
100 NudgeInfo() = default;
101
102 void set_enable(bool is_enable);
103 bool is_enable() const;
104
105 void set_is_merge_block_obs(bool is_merge);
106 bool is_merge_block_obs() const;
107
108 const std::unordered_map<std::string, NudgeObstacleInfo>& tracking_nudge_obs_info() const;
109 std::unordered_map<std::string, NudgeObstacleInfo>* mutable_tracking_nudge_obs_info();
110
111 const std::vector<SLPolygon>& block_sl_polygons() const;
112 std::vector<SLPolygon>* mutable_block_sl_polygons();
113
114 const std::set<std::string>& update_ids() const;
115 std::set<std::string>* mutable_update_ids();
116
117 const std::vector<std::vector<SLPoint>>& extra_nudge_key_points() const;
118 std::vector<std::vector<SLPoint>>* mutable_extra_nudge_key_points();
119
120 bool IsObsIgnoreNudgeDecision(std::string obs_id, double obs_start_s, double check_dis) const;
121 bool NeedCheckObsCollision(std::string obs_id) const;
122
123 void GetFirstBlockSLPolygon(std::string obs_id, SLPolygon* obs_sl_polygon) const;
124
125 void SortBlockSLPolygons();
126
127 void PrintDebugInfo();
128 bool GetInterpolatedNudgeL(bool is_left_nudge, double s, double* nudge_l) const;
129
130private:
131 bool is_enable_ = false;
132 NudgeType nudge_type_ = NudgeType::NONE;
133 bool is_merge_block_obs_ = false;
134 std::unordered_map<std::string, NudgeObstacleInfo> tracking_nudge_obs_info_;
135 std::set<std::string> update_ids_;
136
137 std::vector<SLPolygon> block_sl_polygons_;
138
139 std::vector<std::vector<SLPoint>> extra_nudge_key_points_;
140};
141
142} // namespace planning
143} // namespace apollo
The class of polygon in 2-D.
Definition polygon2d.h:42
const std::vector< Vec2d > & points() const
Get the vertices of the polygon.
Definition polygon2d.h:65
std::vector< std::vector< SLPoint > > * mutable_extra_nudge_key_points()
Definition nudge_info.cc:68
const std::vector< SLPolygon > & block_sl_polygons() const
Definition nudge_info.cc:51
const std::unordered_map< std::string, NudgeObstacleInfo > & tracking_nudge_obs_info() const
Definition nudge_info.cc:43
bool GetInterpolatedNudgeL(bool is_left_nudge, double s, double *nudge_l) const
const std::set< std::string > & update_ids() const
Definition nudge_info.cc:58
std::unordered_map< std::string, NudgeObstacleInfo > * mutable_tracking_nudge_obs_info()
Definition nudge_info.cc:47
bool is_merge_block_obs() const
Definition nudge_info.cc:39
bool IsObsIgnoreNudgeDecision(std::string obs_id, double obs_start_s, double check_dis) const
Definition nudge_info.cc:84
void set_enable(bool is_enable)
Definition nudge_info.cc:28
std::set< std::string > * mutable_update_ids()
Definition nudge_info.cc:61
std::vector< SLPolygon > * mutable_block_sl_polygons()
Definition nudge_info.cc:54
const std::vector< std::vector< SLPoint > > & extra_nudge_key_points() const
Definition nudge_info.cc:65
void GetFirstBlockSLPolygon(std::string obs_id, SLPolygon *obs_sl_polygon) const
void set_is_merge_block_obs(bool is_merge)
Definition nudge_info.cc:36
bool NeedCheckObsCollision(std::string obs_id) const
Definition nudge_info.cc:72
void AddPoint(std::string key, double x, double y)
add point to curve key
Planning module main class.
class register implement
Definition arena_queue.h:37
Define the Polygon2d class.
void PrintPolygonInfo(std::string obs_id)
Definition nudge_info.h:85
hdmap::LaneBoundaryType::Type left_lane_boundary_type
Definition nudge_info.h:51
hdmap::LaneBoundaryType::Type right_lane_boundary_type
Definition nudge_info.h:52