Apollo  6.0
Open source self driving car software
a_star_strategy.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 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 #pragma once
18 
19 #include <unordered_map>
20 #include <unordered_set>
21 #include <vector>
22 
24 
25 namespace apollo {
26 namespace routing {
27 
28 class AStarStrategy : public Strategy {
29  public:
30  explicit AStarStrategy(bool enable_change);
31  ~AStarStrategy() = default;
32 
33  virtual bool Search(const TopoGraph* graph, const SubTopoGraph* sub_graph,
34  const TopoNode* src_node, const TopoNode* dest_node,
35  std::vector<NodeWithRange>* const result_nodes);
36 
37  private:
38  void Clear();
39  double HeuristicCost(const TopoNode* src_node, const TopoNode* dest_node);
40  double GetResidualS(const TopoNode* node);
41  double GetResidualS(const TopoEdge* edge, const TopoNode* to_node);
42 
43  private:
44  bool change_lane_enabled_;
45  std::unordered_set<const TopoNode*> open_set_;
46  std::unordered_set<const TopoNode*> closed_set_;
47  std::unordered_map<const TopoNode*, const TopoNode*> came_from_;
48  std::unordered_map<const TopoNode*, double> g_score_;
49  std::unordered_map<const TopoNode*, double> enter_s_;
50 };
51 
52 } // namespace routing
53 } // namespace apollo
Definition: topo_node.h:32
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: strategy.h:24
Definition: sub_topo_graph.h:29
Definition: a_star_strategy.h:28
Definition: topo_graph.h:31
virtual bool Search(const TopoGraph *graph, const SubTopoGraph *sub_graph, const TopoNode *src_node, const TopoNode *dest_node, std::vector< NodeWithRange > *const result_nodes)
Definition: topo_node.h:121
AStarStrategy(bool enable_change)