docs/08_Planning/hybrid_a_star_en.md
The goal of htbrid_a_star is to generate the coarse trajectory in the open space. Hybrid_a_star contains node3d, grid_search, reeds_shepp_path and hybrid_a_star. hybrid_a_star is the most important component generating the coarse trajectory and call the grid_search and reeds_shepp_path.
Please refer to hybrid a star.cc
bool HybridAStar::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)
The input HybridAStar::Plan() is called by the open_space_trajectory_provider.cc, please refer to open_space_trajectory_provider.cc
Construct obstacles_linesegment_vector. The main method is to form a line segment from a single obstacle point in order; then, each obstacle line segment is stored in obstacles_linesegment_vector that will be used to generate the DP map.
std::vector<std::vector<common::math::LineSegment2d>>
obstacles_linesegments_vec;
for (const auto& obstacle_vertices : obstacles_vertices_vec) {
size_t vertices_num = obstacle_vertices.size();
std::vector<common::math::LineSegment2d> obstacle_linesegments;
for (size_t i = 0; i < vertices_num - 1; ++i) {
common::math::LineSegment2d line_segment = common::math::LineSegment2d(
obstacle_vertices[i], obstacle_vertices[i + 1]);
obstacle_linesegments.emplace_back(line_segment);
}
obstacles_linesegments_vec.emplace_back(obstacle_linesegments);
}
obstacles_linesegments_vec_ = std::move(obstacles_linesegments_vec);
Construct the planned point same as Node3d, please refer to node3d.h. The planned starting point and the ending point are constructed in the form of Node3d that will be save to open set and will be checked by the ValidityCheck() function.
start_node_.reset(
new Node3d({sx}, {sy}, {sphi}, XYbounds_, planner_open_space_config_));
end_node_.reset(
new Node3d({ex}, {ey}, {ephi}, XYbounds_, planner_open_space_config_));
Enter the main while loop to get a set of nodes.
if (AnalyticExpansion(current_node)) {
break;
}
Generate the coarse trajectory by nodes. The GetResult() function is used to generate the coarse trajectory.
bool HybridAStar::GetResult(HybridAStartResult* result)
Output: The optput is partial trajectory information, which include x,y,phi,v,a,steer,s.
bool HybridAStar::ValidityCheck(std::shared_ptr<Node3d> node)
The detection method is based on boundary range judgment and boundary overlap judgment.
Parameter: the input parameter is node which same as node3d.
Introduction: the function is used to check for collisions.
Process detail:
bool GridSearch::GenerateDpMap(
const double ex,
const double ey,
const std::vector<double>& XYbounds,
const std::vector<std::vector<common::math::LineSegment2d>>&
obstacles_linesegments_vec,
const std::vector<std::vector<common::math::LineSegment2d>>&
soft_boundary_linesegments_vec)
the function is used to generate dp map by dynamic programming, please refer grid_search.cc
Parameter: ex and ey are the postion of goal point, XYbounds_ is the boundary of x and y, obstacles_linesegments_ is the line segments which is composed of boundary point.
Introduction: the function is used to generate the dp map
Process detail:
bool HybridAStar::AnalyticExpansion(std::shared_ptr<Node3d> current_node, std::shared_ptr<Node3d>* candidate_final_node)
The function is used to check if an analystic curve could be connected from current configuration to the end configuration without collision. if so, search ends.
Parameter: current node is start point of planning.
introduction: the function based on the reeds shepp method which is a geometric algorithm composed of arc and line. Reeds shepp is used for search acceleration.
Process detail:
bool HybridAStar::AnalyticExpansion(std::shared_ptr<Node3d> current_node, std::shared_ptr<Node3d>* candidate_final_node)
The funtion is used to generate next node based on the current node.
Parameter: the current node of the search and the next node serial number
Introduction: the next node is calculated based on steering wheel uniform sampling and vehicle kinematics.
Process detail:
void HybridAStar::CalculateNodeCost(std::shared_ptr<Node3d> current_node,
std::shared_ptr<Node3d> next_node)
The function is used to calculate the cost of node.
Parameter: current node(vehicle position) and next node.
Introduction: the calculated cost include trajectory cost and heuristic cost considering obstacles based on holonomic.
Process detail: