Apollo 11.0
自动驾驶开放平台
navi_obstacle_decider.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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
22#pragma once
23
24#include <map>
25#include <string>
26#include <tuple>
27#include <vector>
28
29#include "modules/common_msgs/basic_msgs/pnc_point.pb.h"
30#include "modules/planning/planners/navi/proto/navi_task_config.pb.h"
31
37
42namespace apollo {
43namespace planning {
44
54 public:
56
57 virtual ~NaviObstacleDecider() = default;
62 bool Init(const PlannerNaviConfig &config) override;
63
69 double GetNudgeDistance(
70 const std::vector<const Obstacle *> &obstacles,
71 const ReferenceLine &reference_line, const PathDecision &path_decision,
72 const std::vector<common::PathPoint> &path_data_points,
73 const common::VehicleState &vehicle_state, int *lane_obstacles_num);
74
80 const std::vector<common::PathPoint> &path_data_points,
81 const std::vector<const Obstacle *> &obstacles);
82
87 const std::vector<std::tuple<std::string, double, double>> &UnsafeObstacles();
88
89 private:
94 const apollo::common::VehicleParam &VehicleParam();
95
100 void SetLastNudgeDistance(double dist);
101
106 void ProcessObstacle(const std::vector<const Obstacle *> &obstacles,
107 const std::vector<common::PathPoint> &path_data_points,
108 const PathDecision &path_decision,
109 const double min_lane_width,
110 const common::VehicleState &vehicle_state);
111
117 void AddObstacleOffsetDirection(
118 const common::PathPoint &projection_point,
119 const std::vector<common::PathPoint> &path_data_points,
120 const Obstacle *current_obstacle, const double proj_len, double *dist);
121
126 bool IsNeedFilterObstacle(
127 const Obstacle *current_obstacle,
128 const common::PathPoint &vehicle_projection_point,
129 const std::vector<common::PathPoint> &path_data_points,
130 const common::VehicleState &vehicle_state,
131 common::PathPoint *projection_point_ptr);
132
137 double GetMinLaneWidth(const std::vector<common::PathPoint> &path_data_points,
138 const ReferenceLine &reference_line);
139
144 void RecordLastNudgeDistance(const double nudge_dist);
145
151 double GetObstacleActualOffsetDistance(
152 std::map<double, double>::iterator iter, const double right_nedge_lane,
153 const double left_nudge_lane, int *lane_obstacles_num);
157 void SmoothNudgeDistance(const common::VehicleState &vehicle_state,
158 double *nudge_dist);
159 void KeepNudgePosition(const double nudge_dist, int *lane_obstacles_num);
160
161 private:
163 std::map<double, double> obstacle_lat_dist_;
164 std::vector<std::tuple<std::string, double, double>> unsafe_obstacle_info_;
165 double last_nudge_dist_ = 0.0;
166 unsigned int no_nudge_num_ = 0;
167 unsigned int limit_speed_num_ = 0;
168 unsigned int eliminate_clutter_num_ = 0;
169 unsigned int last_lane_obstacles_num_ = 0;
170 unsigned int statist_count_ = 0;
171 unsigned int cycles_count_ = 0;
172 bool is_obstacle_stable_ = false;
173 bool keep_nudge_flag_ = false;
174
175 FRIEND_TEST(NaviObstacleDeciderTest, ComputeNudgeDist1);
176 FRIEND_TEST(NaviObstacleDeciderTest, ComputeNudgeDist2);
177 FRIEND_TEST(NaviObstacleDeciderTest, ComputeNudgeDist3);
178 FRIEND_TEST(NaviObstacleDeciderTest, ComputeNudgeDist4);
179 FRIEND_TEST(NaviObstacleDeciderTest, GetUnsafeObstaclesID);
180 // TODO(all): Add your member functions and variables.
181};
182
183inline const apollo::common::VehicleParam &NaviObstacleDecider::VehicleParam() {
184 const auto &vehicle_param = apollo::common::VehicleConfigHelper::Instance()
185 ->GetConfig()
186 .vehicle_param();
187 return vehicle_param;
188}
189
190inline const std::vector<std::tuple<std::string, double, double>> &
192 return unsafe_obstacle_info_;
193}
194
195inline void NaviObstacleDecider::SetLastNudgeDistance(double dist) {
196 last_nudge_dist_ = dist;
197}
198} // namespace planning
199} // namespace apollo
NaviObstacleDecider is used to make appropriate decisions for obstacles around the vehicle in navigat...
const std::vector< std::tuple< std::string, double, double > > & UnsafeObstacles()
Get unsafe obstacles' ID
bool Init(const PlannerNaviConfig &config) override
Initialization parameters
void GetUnsafeObstaclesInfo(const std::vector< common::PathPoint > &path_data_points, const std::vector< const Obstacle * > &obstacles)
get the unsafe obstacles between trajectory and reference line.
double GetNudgeDistance(const std::vector< const Obstacle * > &obstacles, const ReferenceLine &reference_line, const PathDecision &path_decision, const std::vector< common::PathPoint > &path_data_points, const common::VehicleState &vehicle_state, int *lane_obstacles_num)
get the actual nudgable distance according to the position of the obstacle
This is the class that associates an Obstacle with its path properties.
Definition obstacle.h:62
PathDecision represents all obstacle decisions on one path.
Planning module main class.
class register implement
Definition arena_queue.h:37
Defines the Vec2d class.