当前位置:   article > 正文

【局部规划】Hybird A*算法原理

【局部规划】Hybird A*算法原理

HybirdAstar算法原理

HybridAstar是一种带有半径约束的路径平滑规划算法,算法思想来自A*算法,但A*是没有考虑平滑和半径约束的路径规划算法,且基于栅格地图的网格搜索算法,它们的目标代价函数是为了形成一条路径最短的无碰撞路径。而HybirdAstar是在二者的基础上加入半径约束,进行路径不同曲率方向采样,同时采用reedsheep曲线,进行目标点的衔接,来加速路径的生成效率。

1. A*算法原理

A*算法是基于网格的搜索算法。在算法中,路径的搜索主要考虑了两种代价,一个从起点到当前点路径长度代价g(n),另一个从当前点到目标点的预测代价h(n),二者之和构成栅格上目标搜索方向的判断的总代价f(n)。

因此,A*算法可以通过如下函数构建搜索方向上的栅格代价

其中,f(n)代表栅格节点n的总代价值,g(n) 代表栅格节点n距离起点的代价,h(n)是节点n距离终点的预测代价,也就是所谓的启发函数。

A*算法是通过openlist和closelist形成栅格的可行搜索解和封闭搜索解,算法实现如下:

  1. 初始化两个空的列表openlist和closelist,将起点加入openlist中,并设置代价值为0
  2. while(1)
  3. {
  4. if(openlist != null)
  5. {
  6. 从openlist中选取代价值最小的节点n.
  7. 1. 如果节点n为终点,则从终点开始逐步追踪parent节点,一直达到起点,返回找到的结果路径,
  8. 跳出循环,算法结束,break;
  9. 2. 如果节点n不是终点,
  10. 2.1 将节点n从openlist中删除,加入到closelist中.
  11. 2.2 遍历节点n的8个相邻无碰撞节点
  12. 2.2.1 如果相邻节点在closelist或者openlist中,则跳过该节点,计算下一个节点。
  13. 2.2.2 如果相邻节点不在openlist中,则设置该节点父节点为n,通过f(n)计算该节点的
  14. 代价值,并将该节点放入openlist中。
  15. }
  16. else
  17. break; //不能找到一条最优路径
  18. }

2. HybridAstar算法原理

HybridAstar算法主要分为两部分,一部分是最短路径的栅格代价值生成,有两种方式,一种是采用A*,另一种采用djkstra,但目标都一样,形成最短路径上的栅格代价值;另一部分是曲率采样,也就是所谓路径平滑,和A*的思想一样采用节点的方式产生树结构,在树结构中引入openlist和closelist两个列表,以此进行树的剪枝和回退操作。根据代价函数,将采样节点放到openlist中,同时根据最优代价从openlist中取出节点,并存放到closelist中,其操作过程和前面提到的A*算法过程一致。

代价函数g(n)同时考虑了路径长,转向、倒车等附加成本;启发函数考虑了最优的无碰撞路径,采用的是reedshepp曲线生成,满足了车辆的运动学约束;采用无碰撞的reedshepps曲线长度和运动学约束作为最终的启发函数代价项h(n)。以下是其实现的伪代码:

2.1 核心代码分析

下面以Apollo代码作为切入点来分析HybridAstar算法,主要分为四个部分:

  1. 栅格化规划区域内环境地图,采用djkstra或者A*算法生成当前位置到停车目标位置的栅格代价,也就是所谓的最优路径的栅格代价地图。
  2. 在车辆的世界坐标系下以一定的曲率采样间隔和步长,进行车辆的位姿采样,形成满足运动学约束的节点树。
  3. 计算采样的节点代价(会将前面计算的栅格代价也考虑进来),并存放到openlist中,从openlist中取出最优代价存放到closelist中,openlist和closelist的操作过程和前面讲到的A*算法原理一样。
  4. 在采样节点快要到达目标点时,反复采用reedshepps曲线将当前节点和目标点进行无碰撞连接,一旦reedshepps曲线连接成功,则标志着路径生成完成。

 2.1.1 栅格代价地图生成

在Apollo代码中,有两种方式来生成栅格代价地图,一种是djkstra算法,另一种是A*算法,源代码在coarse_trajectorygenerator/http://grid_search.cc,对应的函数分别为GenerateDpMap和GenerateAStarPath,Apollo提供的源码使用的是GenerateDpMap产生最短路径的栅格代价。

采用djkstra产生的栅格代价地图

  1. bool GridSearch::GenerateDpMap(
  2. const double ex, const double ey, const std::vector<double>& XYbounds,
  3. const std::vector<std::vector<common::math::LineSegment2d>>&
  4. obstacles_linesegments_vec)
  5. {
  6. std::priority_queue<std::pair<std::string, double>,
  7. std::vector<std::pair<std::string, double>>, cmp>
  8. open_pq;
  9. std::unordered_map<std::string, std::shared_ptr<Node2d>> open_set;
  10. dp_map_ = decltype(dp_map_)();
  11. XYbounds_ = XYbounds;
  12. // XYbounds with xmin, xmax, ymin, ymax
  13. max_grid_y_ = std::round((XYbounds_[3] - XYbounds_[2]) / xy_grid_resolution_);
  14. max_grid_x_ = std::round((XYbounds_[1] - XYbounds_[0]) / xy_grid_resolution_);
  15. std::shared_ptr<Node2d> end_node =
  16. std::make_shared<Node2d>(ex, ey, xy_grid_resolution_, XYbounds_);
  17. // obstacles_linesegments_vec_ = obstacles_linesegments_vec;
  18. open_set.insert(std::make_pair(end_node->GetIndex(), end_node));
  19. open_pq.push(std::make_pair(end_node->GetIndex(), end_node->GetCost()));
  20. // Grid a star begins
  21. size_t explored_node_num = 0;
  22. while (!open_pq.empty())
  23. {
  24. // std::cout<<"open_pq: "<<open_pq.size()<<std::endl;
  25. const std::string current_id = open_pq.top().first;
  26. open_pq.pop();
  27. std::shared_ptr<Node2d> current_node = open_set[current_id];
  28. dp_map_.insert(std::make_pair(current_node->GetIndex(), current_node));
  29. Box2d node_box = GetNodeExpandRange(current_node->GetGridX(),current_node->GetGridY());
  30. obstacles_linesegments_vec_.clear();
  31. for(const auto& obstacle : obstacles_linesegments_vec)
  32. {
  33. for(const auto& linesegment : obstacle)
  34. if(node_box.HasOverlap(linesegment))
  35. {
  36. obstacles_linesegments_vec_.emplace_back(obstacle);
  37. break;
  38. }
  39. }
  40. std::vector<std::shared_ptr<Node2d>> next_nodes =
  41. std::move(GenerateNextNodes(current_node));
  42. for (auto& next_node : next_nodes)
  43. {
  44. if (!CheckConstraints(next_node))
  45. {
  46. continue;
  47. }
  48. if (dp_map_.find(next_node->GetIndex()) != dp_map_.end())
  49. {
  50. continue;
  51. }
  52. if (open_set.find(next_node->GetIndex()) == open_set.end())
  53. {
  54. ++explored_node_num;
  55. next_node->SetPreNode(current_node);
  56. open_set.insert(std::make_pair(next_node->GetIndex(), next_node));
  57. open_pq.push(
  58. std::make_pair(next_node->GetIndex(), next_node->GetCost()));
  59. }
  60. else
  61. {
  62. if (open_set[next_node->GetIndex()]->GetCost() > next_node->GetCost())
  63. {
  64. open_set[next_node->GetIndex()]->SetCost(next_node->GetCost());
  65. open_set[next_node->GetIndex()]->SetPreNode(current_node);
  66. }
  67. }
  68. }
  69. }
  70. ADEBUG << "explored node num is " << explored_node_num;
  71. // std::cout<<"explored node num is " <<explored_node_num<<"[grid_search.cc]"<<std::endl;
  72. return true;
  73. }

采用A*算法产生的栅格代价地图:

  1. bool GridSearch::GenerateAStarPath(
  2. const double sx, const double sy, const double ex, const double ey,
  3. const std::vector<double>& XYbounds,
  4. const std::vector<std::vector<common::math::LineSegment2d>>&
  5. obstacles_linesegments_vec,
  6. GridAStartResult* result) {
  7. std::priority_queue<std::pair<std::string, double>,
  8. std::vector<std::pair<std::string, double>>, cmp>
  9. open_pq;
  10. std::unordered_map<std::string, std::shared_ptr<Node2d>> open_set;
  11. std::unordered_map<std::string, std::shared_ptr<Node2d>> close_set;
  12. XYbounds_ = XYbounds;
  13. std::shared_ptr<Node2d> start_node =
  14. std::make_shared<Node2d>(sx, sy, xy_grid_resolution_, XYbounds_);
  15. std::shared_ptr<Node2d> end_node =
  16. std::make_shared<Node2d>(ex, ey, xy_grid_resolution_, XYbounds_);
  17. std::shared_ptr<Node2d> final_node_ = nullptr;
  18. obstacles_linesegments_vec_ = obstacles_linesegments_vec;
  19. open_set.insert(std::make_pair(start_node->GetIndex(), start_node));
  20. open_pq.push(std::make_pair(start_node->GetIndex(), start_node->GetCost()));
  21. // Grid a star begins
  22. size_t explored_node_num = 0;
  23. while (!open_pq.empty()) {
  24. std::string current_id = open_pq.top().first;
  25. open_pq.pop();
  26. std::shared_ptr<Node2d> current_node = open_set[current_id];
  27. // Check destination
  28. if (*(current_node) == *(end_node)) {
  29. final_node_ = current_node;
  30. break;
  31. }
  32. close_set.emplace(current_node->GetIndex(), current_node);
  33. std::vector<std::shared_ptr<Node2d>> next_nodes =
  34. std::move(GenerateNextNodes(current_node));
  35. for (auto& next_node : next_nodes) {
  36. if (!CheckConstraints(next_node)) {
  37. continue;
  38. }
  39. if (close_set.find(next_node->GetIndex()) != close_set.end()) {
  40. continue;
  41. }
  42. if (open_set.find(next_node->GetIndex()) == open_set.end()) {
  43. ++explored_node_num;
  44. next_node->SetHeuristic(
  45. EuclidDistance(next_node->GetGridX(), next_node->GetGridY(),
  46. end_node->GetGridX(), end_node->GetGridY()));
  47. next_node->SetPreNode(current_node);
  48. open_set.insert(std::make_pair(next_node->GetIndex(), next_node));
  49. open_pq.push(
  50. std::make_pair(next_node->GetIndex(), next_node->GetCost()));
  51. }
  52. }
  53. }
  54. if (final_node_ == nullptr) {
  55. AERROR << "Grid A searching return null ptr(open_set ran out)";
  56. return false;
  57. }
  58. LoadGridAStarResult(result);
  59. ADEBUG << "explored node num is " << explored_node_num;
  60. return true;
  61. }

最终在HybirdAstar通过调用CheckDpMap(const double sx, const double sy)获取栅格代价。

2.1.2 HybirdAstar路径搜索

该部分代码在coarse_trajectorygenerator/http://hybrid_a_star.cc中。节点采样采用了半径约束,是在世界坐标系下进行的,节点搜索借鉴的是A*的思想。

  1. bool HybridAStar::Plan(
  2. double sx, double sy, double sphi,double sv, double ex, double ey, double ephi,double ev,
  3. const std::vector<double>& XYbounds,
  4. const std::vector<std::vector<common::math::Vec2d>>& obstacles_vertices_vec,
  5. HybridAStartResult* result) //HybridAstar路径规划主函数
  6. {
  7. // clear containers
  8. open_set_.clear(); //前面A*中提到的openlist
  9. close_set_.clear(); //前面A*中提到的closelist
  10. open_pq_ = decltype(open_pq_)();
  11. final_node_ = nullptr;
  12. obstacles_linesegments_vec_.clear();
  13. for (const auto& obstacle_vertices : obstacles_vertices_vec) //感知活动的障碍物边界信息,以直线段的形式存储
  14. {
  15. size_t vertices_num = obstacle_vertices.size();
  16. std::vector<common::math::LineSegment2d> obstacle_linesegments;
  17. for (size_t i = 0; i < vertices_num - 1; ++i)
  18. {
  19. common::math::LineSegment2d line_segment = common::math::LineSegment2d(
  20. obstacle_vertices[i], obstacle_vertices[i + 1]);
  21. obstacle_linesegments.emplace_back(line_segment);
  22. // printf("linesegment:%f,%f-%f,%f\n",line_segment.start().x(),line_segment.start().y(),line_segment.end().x(),line_segment.end().y());
  23. }
  24. obstacles_linesegments_vec_.emplace_back(obstacle_linesegments);
  25. }
  26. // obstacles_linesegments_vec_ = std::move(obstacles_linesegments_vec);
  27. obstacles_linesegments_vec_local_ = obstacles_linesegments_vec_;
  28. // load XYbounds
  29. XYbounds_ = XYbounds;
  30. // load nodes and obstacles
  31. start_node_.reset(
  32. new Node3d({sx}, {sy}, {sphi}, XYbounds_, planner_open_space_config_));
  33. end_node_.reset(
  34. new Node3d({ex}, {ey}, {ephi}, XYbounds_, planner_open_space_config_));
  35. if (!ValidityCheck(start_node_)) //检查起点是否发生碰撞,是否有效
  36. {
  37. AINFO << "start_node in collision with obstacles";
  38. return false;
  39. }
  40. if (!ValidityCheck(end_node_)) //检查终点是否发生碰撞,是否有效
  41. {
  42. AINFO << "end_node in collision with obstacles";
  43. return false;
  44. }
  45. double map_start = Clock::NowInSeconds();
  46. grid_a_star_heuristic_generator_->GenerateDpMap(ex, ey, XYbounds_,
  47. obstacles_linesegments_vec_); //栅格路径搜索,主要用于产生栅格路径势场,也就是栅格最短路径的代价值
  48. double map_time = Clock::NowInSeconds() - map_start;
  49. ADEBUG << "map time " << map_time;
  50. // load open set, pq
  51. open_set_.insert(std::make_pair(start_node_->GetIndex(), start_node_));
  52. open_pq_.push(
  53. std::make_pair(start_node_->GetIndex(), start_node_->GetCost()));
  54. // Hybrid A* begins
  55. size_t explored_node_num = 0;
  56. double astar_start_time = Clock::NowInSeconds();
  57. double heuristic_time = 0.0;
  58. double rs_time = 0.0;
  59. double start_time = 0.0;
  60. double end_time = 0.0;
  61. unsigned int node_cnt = 0;
  62. while (!open_pq_.empty())
  63. {
  64. //timeout check
  65. if(Clock::NowInSeconds() - astar_start_time > 3.0)
  66. {
  67. std::cout <<"timeout in 3 s,return" << std::endl;
  68. return false;
  69. }
  70. // take out the lowest cost neighboring node
  71. const std::string current_id = open_pq_.top().first;
  72. open_pq_.pop();
  73. std::shared_ptr<Node3d> current_node = open_set_[current_id];
  74. // check if an analystic curve could be connected from current
  75. // configuration to the end configuration without collision. if so, search
  76. // ends.:Plan(
  77. node_cnt++;
  78. double current_heuristic = grid_a_star_heuristic_generator_->CheckDpMap(current_node->GetX(),
  79. current_node->GetY()); //grid_search中djkstra栅格搜索的栅格代价值(可以理解最优路径花费)
  80. unsigned int N= static_cast<unsigned int>(0.1*current_heuristic); //用于加速hybridastar搜索速度,
  81. if(node_cnt >= N+1)
  82. {
  83. node_cnt =0;
  84. start_time = Clock::NowInSeconds();
  85. if (AnalyticExpansion(current_node)) //是否可以生成到目标点的无碰撞的reedshepp曲线,加速搜索,直接连接规划终点。
  86. {
  87. break;
  88. }
  89. end_time = Clock::NowInSeconds();
  90. rs_time += end_time - start_time;
  91. }
  92. close_set_.insert(std::make_pair(current_node->GetIndex(), current_node)); //将最优代价值节点放入到closelist中。
  93. Box2d node_box = GetNodeExpandRange(current_node->GetX(),current_node->GetY(),current_node->GetPhi()); //节点footprint
  94. obstacles_linesegments_vec_local_.clear();
  95. for(const auto& obstacle : obstacles_linesegments_vec_) //感知获得的障碍物边界信息以直线段的形式存储
  96. {
  97. for(const auto& linesegment : obstacle)
  98. if(node_box.HasOverlap(linesegment))
  99. {
  100. obstacles_linesegments_vec_local_.emplace_back(obstacle);
  101. break;
  102. }
  103. }
  104. for (size_t i = 0; i < next_node_num_; ++i)
  105. {
  106. std::shared_ptr<Node3d> next_node = Next_node_generator(current_node, i); //以不同曲率产生下一个相邻节点
  107. // boundary check failure handle
  108. if (next_node == nullptr)
  109. {
  110. continue;
  111. }
  112. // check if the node is already in the close set
  113. if (close_set_.find(next_node->GetIndex()) != close_set_.end()) //检查下一个采样节点是否在closelist中
  114. {
  115. continue;
  116. }
  117. // collision check
  118. if (!ValidityCheck(next_node)) //检查下一个采样节点是否发生碰撞
  119. {
  120. continue;
  121. }
  122. if (open_set_.find(next_node->GetIndex()) == open_set_.end()) //下一个节点也不在openlist中
  123. {
  124. explored_node_num++;
  125. start_time = Clock::NowInSeconds();
  126. CalculateNodeCost(current_node, next_node); //计算当前采样节点的代价值
  127. end_time = Clock::NowInSeconds();
  128. heuristic_time += end_time - start_time;
  129. open_set_.emplace(next_node->GetIndex(), next_node);
  130. open_pq_.emplace(next_node->GetIndex(), next_node->GetCost()); //将当前节点放入到closelist中,, //将当前节点放入到closelist中, cost = traj_cost_ + heuristic_cost_
  131. }
  132. }
  133. }
  134. if (final_node_ == nullptr)
  135. {
  136. ADEBUG << "Hybrid A searching return null ptr(open_set ran out)";
  137. return false;
  138. }
  139. if (!GetResult(result,sv,ev)) //将前面获得的搜寻节点信息按顺序提取为特定格式的路径数据
  140. {
  141. ADEBUG << "GetResult failed";
  142. return false;
  143. }
  144. double astar_end_time = Clock::NowInSeconds() - astar_start_time;
  145. double total_plan = Clock::NowInSeconds()-map_start;
  146. ADEBUG << "explored node num is " << explored_node_num;
  147. ADEBUG << "heuristic time is " << heuristic_time;
  148. ADEBUG << "reed shepp time is " << rs_time;
  149. ADEBUG << "hybrid astar total time is "
  150. << astar_end_time;
  151. std::cout <<"map time is " << map_time << std::endl;
  152. std::cout <<"explored node num is " << explored_node_num << std::endl;
  153. std::cout <<"heuristic time is " << heuristic_time << std::endl;
  154. std::cout <<"reed shepp time is " << rs_time << std::endl;
  155. std::cout <<"hybrid astar run time is " << astar_end_time << std::endl;
  156. std::cout <<"total plan time is " << total_plan << std::endl;
  157. return true;
  158. }

2.1.3 HybirdAstar的代价值计算

该部分代码在coarse_trajectorygenerator/http://hybrid_a_star.cc中。代码实现如下:

  1. //路径搜索的总花费计算
  2. void HybridAStar::CalculateNodeCost(std::shared_ptr<Node3d> current_node,
  3. std::shared_ptr<Node3d> next_node)
  4. {
  5. next_node->SetTrajCost(current_node->GetTrajCost() +
  6. TrajCost(current_node, next_node)); //节点搜索的代价值
  7. // evaluate heuristic cost
  8. double optimal_path_cost = 0.0;
  9. optimal_path_cost += HoloObstacleHeuristic(next_node); //栅格搜索的路径代价值,最短栅格路径
  10. next_node->SetHeuCost(optimal_path_cost); //将栅格搜索的最短路径花费合并到节点搜索的花费中
  11. }
  12. //HybirdAstar路径搜索花费
  13. double HybridAStar::TrajCost(std::shared_ptr<Node3d> current_node,
  14. std::shared_ptr<Node3d> next_node)
  15. {
  16. // evaluate cost on the trajectory and add current cost
  17. double piecewise_cost = 0.0;
  18. if (next_node->GetDirec())
  19. {
  20. piecewise_cost += static_cast<double>(next_node->GetStepSize() - 1) *
  21. step_size_ * traj_forward_penalty_; //路径长度正向花费
  22. }
  23. else
  24. {
  25. piecewise_cost += static_cast<double>(next_node->GetStepSize() - 1) *
  26. step_size_ * traj_back_penalty_; //路径反向长度花费 倒车路径
  27. }
  28. if (current_node->GetDirec() != next_node->GetDirec())
  29. {
  30. piecewise_cost += traj_gear_switch_penalty_; //反向花费
  31. }
  32. piecewise_cost += traj_steer_penalty_ * std::abs(next_node->GetSteer()); //节点转向角花费
  33. piecewise_cost += traj_steer_change_penalty_ *
  34. std::abs(next_node->GetSteer() - current_node->GetSteer()); //节点转向角变化率花费
  35. return piecewise_cost;
  36. }
  37. //栅格搜索的最短路径花费
  38. double HybridAStar::HoloObstacleHeuristic(std::shared_ptr<Node3d> next_node)
  39. {
  40. return grid_a_star_heuristic_generator_->CheckDpMap(next_node->GetX(),
  41. next_node->GetY()); //栅格搜索的最短路径花费
  42. }
代价函数的计算项:
  1. cost = traj_cost_ + heuristic_cost_;
  2. traj_cost_ = kfp* step_cnt * step_size + kbp*dir + ksvp*steer + ksap*dsteer ;
  3. cost = kfp* step_cnt * step_size + kbp*dir + ksvp*steer + ksap*dsteer + heuristic_cost_;
其中, kfp代表hybridstar路径搜索的路径长度代价项权重。
kbp代表hybridstar路径搜索倒车时的代价项权重。
ksvp代表hybridastar路径搜索转向角的代价权重。
ksap代表hybridastar路径搜索的转向角变化率的权重。
heuristic_cost_代表grid_search中的最短栅格路径代价值。

2.1.4 ReedSheep曲线

ReedShepp曲线由Reeds和Shepp二人在1990年的论文《

Optimal paths for a car that goes both forwards and backwards​sector3.imm.uran.ru/shepp/Reeds_Shepp_trunk.pdf

》中提出,ReedShepp曲线由几段半径固定的圆弧和一段直线段拼接组成,而且圆弧的半径就是汽车的最小转弯半径。前原理类似于Dubin曲线,不过在Dubin曲线的基础上考虑了倒车的情景,因此在无人驾驶领域的引用非常普遍。

ReedShepps曲线从起点到终点路径是通过车辆最小转弯半径的圆弧和直线拼接组成,曲线类型有48种,所有类型的组合如下表所示:

表中的form代表按圆弧和直线的组合分类,可以分为9大类,"C"代表了圆弧,"S" 代表了直线,"|"表示车辆运动朝向由正向转为反向或者由反向转为正向。

在Baseword下又可以分为很多的基元类型,由l^{+}l^-r^+r^-s^+s^-这六种元素组成,其中l^{+}表示车辆左转前进;l^-表示车辆左转后退;r^+表示车辆右转前进;r^-表示车辆右转后退;s^+表示车辆直行前进;s^-表示车辆直行后退。更加详细内容,请参考论文《Optimal paths for a car that goes both forwards and backwards》,上图图表亦来自论文。

ReedShepp曲线部分的代码在coarse_trajectorygenerator/http://reeds_shepp_path.cc中。

  1. bool ReedShepp::ShortestRSP(const std::shared_ptr<Node3d> start_node,
  2. const std::shared_ptr<Node3d> end_node,
  3. std::shared_ptr<ReedSheppPath> optimal_path) {
  4. std::vector<ReedSheppPath> all_possible_paths;
  5. if (!GenerateRSPs(start_node, end_node, &all_possible_paths)) //产生所有类型的reedshepp曲线
  6. {
  7. ADEBUG << "Fail to generate different combination of Reed Shepp "
  8. "paths";
  9. return false;
  10. }
  11. double optimal_path_length = std::numeric_limits<double>::infinity();
  12. size_t optimal_path_index = 0;
  13. size_t paths_size = all_possible_paths.size();
  14. for (size_t i = 0; i < paths_size; ++i)
  15. {
  16. if (all_possible_paths.at(i).total_length > 0 &&
  17. all_possible_paths.at(i).total_length < optimal_path_length) {
  18. optimal_path_index = i;
  19. optimal_path_length = all_possible_paths.at(i).total_length; //寻找最短的reedshepp曲线参数
  20. }
  21. }
  22. if (!GenerateLocalConfigurations(start_node, end_node,
  23. &(all_possible_paths[optimal_path_index]))) //根据曲线参数插值reedshepp曲线
  24. {
  25. ADEBUG << "Fail to generate local configurations(x, y, phi) in SetRSP";
  26. return false;
  27. }
  28. //检验是否精确插值到目标点
  29. if (std::abs(all_possible_paths[optimal_path_index].x.back() -
  30. end_node->GetX()) > 1e-3 ||
  31. std::abs(all_possible_paths[optimal_path_index].y.back() -
  32. end_node->GetY()) > 1e-3 ||
  33. std::abs(all_possible_paths[optimal_path_index].phi.back() -
  34. end_node->GetPhi()) > 1e-3)
  35. {
  36. ADEBUG << "RSP end position not right";
  37. for (size_t i = 0;
  38. i < all_possible_paths[optimal_path_index].segs_types.size(); ++i)
  39. {
  40. ADEBUG << "types are "
  41. << all_possible_paths[optimal_path_index].segs_types[i];
  42. }
  43. ADEBUG << "x, y, phi are: "
  44. << all_possible_paths[optimal_path_index].x.back() << ", "
  45. << all_possible_paths[optimal_path_index].y.back() << ", "
  46. << all_possible_paths[optimal_path_index].phi.back();
  47. ADEBUG << "end x, y, phi are: " << end_node->GetX() << ", "
  48. << end_node->GetY() << ", " << end_node->GetPhi();
  49. return false;
  50. }
  51. (*optimal_path).x = all_possible_paths[optimal_path_index].x;
  52. (*optimal_path).y = all_possible_paths[optimal_path_index].y;
  53. (*optimal_path).phi = all_possible_paths[optimal_path_index].phi;
  54. (*optimal_path).gear = all_possible_paths[optimal_path_index].gear;
  55. (*optimal_path).total_length =
  56. all_possible_paths[optimal_path_index].total_length;
  57. (*optimal_path).segs_types =
  58. all_possible_paths[optimal_path_index].segs_types;
  59. (*optimal_path).segs_lengths =
  60. all_possible_paths[optimal_path_index].segs_lengths;
  61. return true;
  62. }

reedshepp曲线起点start_node终点end_node最短路径ShortestRSP一定是上表类型中的一个,且其曲线路径是所有reedshepp曲线中最短的。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/613598
推荐阅读
相关标签
  

闽ICP备14008679号