Apollo 10.0
自动驾驶开放平台
hybrid_a_star.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
17/*
18* @file
19*/
20
21#pragma once
22
23#include <algorithm>
24#include <memory>
25#include <queue>
26#include <string>
27#include <unordered_map>
28#include <unordered_set>
29#include <utility>
30#include <vector>
31
32#include "modules/common_msgs/config_msgs/vehicle_config.pb.h"
33#include "modules/planning/planning_open_space/proto/planner_open_space_config.pb.h"
34
35#include "cyber/common/log.h"
36#include "cyber/common/macros.h"
37#include "cyber/time/clock.h"
45
46namespace apollo {
47namespace planning {
48
50 std::vector<double> x;
51 std::vector<double> y;
52 std::vector<double> phi;
53 std::vector<double> v;
54 std::vector<double> a;
55 std::vector<double> steer;
56 std::vector<double> accumulated_s;
57};
58
60 public:
61 explicit HybridAStar(const PlannerOpenSpaceConfig& open_space_conf);
62 virtual ~HybridAStar() = default;
64 const HybridAStartResult& result,
65 std::vector<HybridAStartResult>* partitioned_result);
66
67 private:
68 bool AnalyticExpansion(
69 std::shared_ptr<Node3d> current_node,
70 std::shared_ptr<Node3d>* candidate_final_node);
71 // check collision and validity
72 bool ValidityCheck(std::shared_ptr<Node3d> node);
73 // check Reeds Shepp path collision and validity
74 bool RSPCheck(const std::shared_ptr<ReedSheppPath> reeds_shepp_to_end);
75 // load the whole RSP as nodes and add to the close set
76 std::shared_ptr<Node3d> LoadRSPinCS(
77 const std::shared_ptr<ReedSheppPath> reeds_shepp_to_end,
78 std::shared_ptr<Node3d> current_node);
79 std::shared_ptr<Node3d> Next_node_generator(
80 std::shared_ptr<Node3d> current_node,
81 size_t next_node_index);
82 void CalculateNodeCost(
83 std::shared_ptr<Node3d> current_node,
84 std::shared_ptr<Node3d> next_node);
85 double TrajCost(
86 std::shared_ptr<Node3d> current_node,
87 std::shared_ptr<Node3d> next_node);
88 double HoloObstacleHeuristic(std::shared_ptr<Node3d> next_node);
89 bool GetResult(HybridAStartResult* result);
90 bool GetTemporalProfile(HybridAStartResult* result);
91 bool GenerateSpeedAcceleration(HybridAStartResult* result);
92 bool GenerateSCurveSpeedAcceleration(HybridAStartResult* result);
93
94 private:
95 PlannerOpenSpaceConfig planner_open_space_config_;
96 common::VehicleParam vehicle_param_ =
98 size_t next_node_num_ = 0;
99 double max_steer_angle_ = 0.0;
100 double max_kappa_ = 0.0;
101 double step_size_ = 0.0;
102 double xy_grid_resolution_ = 0.0;
103 double delta_t_ = 0.0;
104 double traj_forward_penalty_ = 0.0;
105 double traj_back_penalty_ = 0.0;
106 double traj_gear_switch_penalty_ = 0.0;
107 double traj_steer_penalty_ = 0.0;
108 double traj_steer_change_penalty_ = 0.0;
109 double soft_boundary_penalty_ = 0.0;
110 double heu_rs_forward_penalty_ = 0.0;
111 double heu_rs_back_penalty_ = 0.0;
112 double heu_rs_gear_switch_penalty_ = 0.0;
113 double heu_rs_steer_penalty_ = 0.0;
114 double heu_rs_steer_change_penalty_ = 0.0;
115 double acc_weight_ = 0.0;
116 double jerk_weight_ = 0.0;
117 double kappa_penalty_weight_ = 0.0;
118 double ref_s_weight_ = 0.0;
119 double ref_v_weight_ = 0.0;
120 double max_forward_v_ = 0.0;
121 double max_reverse_v_ = 0.0;
122 double max_forward_acc_ = 0.0;
123 double max_reverse_acc_ = 0.0;
124 double max_acc_jerk_ = 0.0;
125 double arc_length_ = 0.0;
126 std::vector<double> XYbounds_;
127 std::shared_ptr<Node3d> start_node_;
128 std::shared_ptr<Node3d> end_node_;
129 std::shared_ptr<Node3d> final_node_;
130 std::vector<std::vector<common::math::LineSegment2d>>
131 obstacles_linesegments_vec_;
132
133 struct cmp {
134 bool operator()(
135 const std::pair<std::shared_ptr<Node3d>, double>& left,
136 const std::pair<std::shared_ptr<Node3d>, double>& right) const {
137 return left.second >= right.second;
138 }
139 };
140 std::priority_queue<
141 std::pair<std::shared_ptr<Node3d>, double>,
142 std::vector<std::pair<std::shared_ptr<Node3d>, double>>,
143 cmp>
144 open_pq_;
145 std::unordered_set<std::string> open_set_;
146 std::unordered_set<std::string> close_set_;
147 std::unique_ptr<ReedShepp> reed_shepp_generator_;
148 std::unique_ptr<GridSearch> grid_a_star_heuristic_generator_;
149
150 // park generic
151 public:
152 explicit HybridAStar(const WarmStartConfig& open_space_conf);
153
154 bool Plan(
155 double sx,
156 double sy,
157 double sphi,
158 double ex,
159 double ey,
160 double ephi,
161 const std::vector<double>& XYbounds,
162 const std::vector<std::vector<common::math::Vec2d>>&
163 obstacles_vertices_vec,
164 HybridAStartResult* result,
165 const std::vector<std::vector<common::math::Vec2d>>&
166 soft_boundary_vertices_vec = {},
167 bool reeds_sheep_last_straight = false);
168
169 private:
170 double GetSoftBoundaryCost(
171 const std::shared_ptr<ReedSheppPath>& reeds_shepp_to_end);
172 bool RSPLengthCheck(const std::shared_ptr<ReedSheppPath> reeds_shepp_path);
173
174 WarmStartConfig planner_warm_start_config_;
175 std::vector<std::vector<common::math::LineSegment2d>>
176 soft_boundary_linesegments_vec_;
177 double traj_expected_shortest_length_ = 0.0;
178 double traj_short_length_penalty_ = 0.0;
179};
180
181} // namespace planning
182} // namespace apollo
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
virtual ~HybridAStar()=default
bool TrajectoryPartition(const HybridAStartResult &result, std::vector< HybridAStartResult > *partitioned_result)
bool Plan(double sx, double sy, double sphi, double ex, double ey, double ephi, const std::vector< double > &XYbounds, const std::vector< std::vector< common::math::Vec2d > > &obstacles_vertices_vec, HybridAStartResult *result, const std::vector< std::vector< common::math::Vec2d > > &soft_boundary_vertices_vec={}, bool reeds_sheep_last_straight=false)
HybridAStar(const WarmStartConfig &open_space_conf)
Planning module main class.
Math-related util functions.
class register implement
Definition arena_queue.h:37
optional VehicleParam vehicle_param
std::vector< double > accumulated_s