Apollo 11.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
60public:
61 explicit HybridAStar(const PlannerOpenSpaceConfig& open_space_conf);
62 virtual ~HybridAStar() = default;
63 bool TrajectoryPartition(const HybridAStartResult& result, std::vector<HybridAStartResult>* partitioned_result);
64
65private:
66 bool AnalyticExpansion(std::shared_ptr<Node3d> current_node, std::shared_ptr<Node3d>* candidate_final_node);
67 // check collision and validity
68 bool ValidityCheck(std::shared_ptr<Node3d> node);
69 // check Reeds Shepp path collision and validity
70 bool RSPCheck(const std::shared_ptr<ReedSheppPath> reeds_shepp_to_end);
71 // load the whole RSP as nodes and add to the close set
72 std::shared_ptr<Node3d> LoadRSPinCS(
73 const std::shared_ptr<ReedSheppPath> reeds_shepp_to_end,
74 std::shared_ptr<Node3d> current_node);
75 std::shared_ptr<Node3d> Next_node_generator(std::shared_ptr<Node3d> current_node, size_t next_node_index);
76 void CalculateNodeCost(std::shared_ptr<Node3d> current_node, std::shared_ptr<Node3d> next_node);
77 double TrajCost(std::shared_ptr<Node3d> current_node, std::shared_ptr<Node3d> next_node);
78 double HoloObstacleHeuristic(std::shared_ptr<Node3d> next_node);
79 bool GetResult(HybridAStartResult* result);
80 bool GetTemporalProfile(HybridAStartResult* result);
81 bool GenerateSpeedAcceleration(HybridAStartResult* result);
82 bool GenerateSCurveSpeedAcceleration(HybridAStartResult* result);
83
84private:
85 PlannerOpenSpaceConfig planner_open_space_config_;
87 size_t next_node_num_ = 0;
88 double max_steer_angle_ = 0.0;
89 double max_kappa_ = 0.0;
90 double step_size_ = 0.0;
91 double xy_grid_resolution_ = 0.0;
92 double delta_t_ = 0.0;
93 double traj_forward_penalty_ = 0.0;
94 double traj_back_penalty_ = 0.0;
95 double traj_gear_switch_penalty_ = 0.0;
96 double traj_steer_penalty_ = 0.0;
97 double traj_steer_change_penalty_ = 0.0;
98 double soft_boundary_penalty_ = 0.0;
99 double heu_rs_forward_penalty_ = 0.0;
100 double heu_rs_back_penalty_ = 0.0;
101 double heu_rs_gear_switch_penalty_ = 0.0;
102 double heu_rs_steer_penalty_ = 0.0;
103 double heu_rs_steer_change_penalty_ = 0.0;
104 double acc_weight_ = 0.0;
105 double jerk_weight_ = 0.0;
106 double kappa_penalty_weight_ = 0.0;
107 double ref_s_weight_ = 0.0;
108 double ref_v_weight_ = 0.0;
109 double max_forward_v_ = 0.0;
110 double max_reverse_v_ = 0.0;
111 double max_forward_acc_ = 0.0;
112 double max_reverse_acc_ = 0.0;
113 double max_acc_jerk_ = 0.0;
114 double arc_length_ = 0.0;
115 std::vector<double> XYbounds_;
116 std::shared_ptr<Node3d> start_node_;
117 std::shared_ptr<Node3d> end_node_;
118 std::shared_ptr<Node3d> final_node_;
119 std::vector<std::vector<common::math::LineSegment2d>> obstacles_linesegments_vec_;
120
121 struct cmp {
122 bool operator()(
123 const std::pair<std::shared_ptr<Node3d>, double>& left,
124 const std::pair<std::shared_ptr<Node3d>, double>& right) const {
125 return left.second >= right.second;
126 }
127 };
128 std::priority_queue<
129 std::pair<std::shared_ptr<Node3d>, double>,
130 std::vector<std::pair<std::shared_ptr<Node3d>, double>>,
131 cmp>
132 open_pq_;
133 std::unordered_set<std::string> open_set_;
134 std::unordered_set<std::string> close_set_;
135 std::unique_ptr<ReedShepp> reed_shepp_generator_;
136 std::unique_ptr<GridSearch> grid_a_star_heuristic_generator_;
137
138 // park generic
139public:
140 explicit HybridAStar(const WarmStartConfig& open_space_conf);
141
142 bool Plan(
143 double sx,
144 double sy,
145 double sphi,
146 double ex,
147 double ey,
148 double ephi,
149 const std::vector<double>& XYbounds,
150 const std::vector<std::vector<common::math::Vec2d>>& obstacles_vertices_vec,
151 HybridAStartResult* result,
152 const std::vector<std::vector<common::math::Vec2d>>& soft_boundary_vertices_vec = {},
153 bool reeds_sheep_last_straight = false);
154
155private:
156 double GetSoftBoundaryCost(const std::shared_ptr<ReedSheppPath>& reeds_shepp_to_end);
157 bool RSPLengthCheck(const std::shared_ptr<ReedSheppPath> reeds_shepp_path);
158
159 WarmStartConfig planner_warm_start_config_;
160 std::vector<std::vector<common::math::LineSegment2d>> soft_boundary_linesegments_vec_;
161 double traj_expected_shortest_length_ = 0.0;
162 double traj_short_length_penalty_ = 0.0;
163};
164
165} // namespace planning
166} // 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)
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