Buran Motion Planning Framework
node_grid_path_finder.h
1 #pragma once
2 
3 #include <set>
4 #include "path_node.h"
5 #include "scene.h"
6 #include "grid_path_finder.h"
7 
8 
9 namespace bmpf {
41  public:
45  static const int ERROR_REACHED_MAX_NODE_CNT = 4;
46 
58  NodeGridPathFinder(const std::shared_ptr<bmpf::Scene> &scene,
59  bool showTrace,
60  int gridSize,
61  unsigned int maxNodeCnt,
62  unsigned int kG = 1,
63  unsigned int kD = 0,
64  int threadCnt = 1
65  ) : GridPathFinder(scene, showTrace, gridSize, threadCnt),
66  _maxNodeCnt(maxNodeCnt), _kG(kG), _kD(kD) {}
67 
73  std::vector<std::vector<double>> getAllProcessedStates();
74 
80  bool findTick(std::vector<double> &state) override;
81 
91  virtual std::shared_ptr<PathNode> _forEachNeighbor(
92  std::shared_ptr<PathNode> currentNode, std::vector<int> &endCoords
93  ) = 0;
94 
103  std::shared_ptr<PathNode>
104  tryToGetNeighborPtr(std::vector<int> newCoords, const std::shared_ptr<PathNode> &parentNode, double sum);
105 
109  void buildPath() override;
110 
116  void prepare(const std::vector<double> &startState, const std::vector<double> &endState) override;
117 
123  void prepare(std::vector<int> &startState, std::vector<int> &endState) override;
124 
129  std::vector<double> getCurrentState();
130 
134  void nextNode() { _openSet.erase(_openSet.begin()); }
135 
142  double _findLinkDistance(std::vector<int> &a, std::vector<int> &b);
143 
144  protected:
145 
150  void _moveNodeFromOpenedToClosed(const std::shared_ptr<PathNode> &node);
151 
157  bool _findCoordsInClosedList(std::vector<int> &coords);
158 
164  bool _findCoordsInOpenedList(std::vector<int> &coords);
165 
172  double _getPathNodeWeight(std::vector<int> curCoords, std::vector<int> &endCoords);
173 
177  unsigned int _kG;
181  unsigned int _kD;
185  std::shared_ptr<PathNode> _endNode;
189  std::vector<std::shared_ptr<PathNode>> _closedNodes;
193  std::unordered_set<long> _closedStateConvCodeSet;
197  std::set<PathNodePtr> _openSet;
201  unsigned int _maxNodeCnt;
202 
203  };
204 
205 
206 }
bmpf::NodeGridPathFinder::tryToGetNeighborPtr
std::shared_ptr< PathNode > tryToGetNeighborPtr(std::vector< int > newCoords, const std::shared_ptr< PathNode > &parentNode, double sum)
Definition: node_grid_path_finder.cpp:93
bmpf::NodeGridPathFinder::_openSet
std::set< PathNodePtr > _openSet
Definition: node_grid_path_finder.h:197
bmpf::NodeGridPathFinder
Базовый класс для всех планировщиков на сетке с нодами Базовый класс для всех планировщиков на сетке ...
Definition: node_grid_path_finder.h:40
bmpf::NodeGridPathFinder::_maxNodeCnt
unsigned int _maxNodeCnt
Definition: node_grid_path_finder.h:201
bmpf::NodeGridPathFinder::findTick
bool findTick(std::vector< double > &state) override
Definition: node_grid_path_finder.cpp:126
bmpf::NodeGridPathFinder::_getPathNodeWeight
double _getPathNodeWeight(std::vector< int > curCoords, std::vector< int > &endCoords)
Definition: node_grid_path_finder.cpp:244
bmpf::NodeGridPathFinder::_kD
unsigned int _kD
Definition: node_grid_path_finder.h:181
bmpf::NodeGridPathFinder::getCurrentState
std::vector< double > getCurrentState()
Definition: node_grid_path_finder.cpp:111
bmpf::NodeGridPathFinder::_forEachNeighbor
virtual std::shared_ptr< PathNode > _forEachNeighbor(std::shared_ptr< PathNode > currentNode, std::vector< int > &endCoords)=0
bmpf::NodeGridPathFinder::nextNode
void nextNode()
Definition: node_grid_path_finder.h:134
bmpf::NodeGridPathFinder::NodeGridPathFinder
NodeGridPathFinder(const std::shared_ptr< bmpf::Scene > &scene, bool showTrace, int gridSize, unsigned int maxNodeCnt, unsigned int kG=1, unsigned int kD=0, int threadCnt=1)
Definition: node_grid_path_finder.h:58
bmpf::NodeGridPathFinder::_endNode
std::shared_ptr< PathNode > _endNode
Definition: node_grid_path_finder.h:185
bmpf::NodeGridPathFinder::_kG
unsigned int _kG
Definition: node_grid_path_finder.h:177
bmpf::NodeGridPathFinder::_findCoordsInOpenedList
bool _findCoordsInOpenedList(std::vector< int > &coords)
Definition: node_grid_path_finder.cpp:39
bmpf::NodeGridPathFinder::_findLinkDistance
double _findLinkDistance(std::vector< int > &a, std::vector< int > &b)
Definition: node_grid_path_finder.cpp:268
bmpf::NodeGridPathFinder::_findCoordsInClosedList
bool _findCoordsInClosedList(std::vector< int > &coords)
Definition: node_grid_path_finder.cpp:29
bmpf::NodeGridPathFinder::buildPath
void buildPath() override
Definition: node_grid_path_finder.cpp:49
bmpf::GridPathFinder
Базовый класс для всех планировщиков на сетке Базовый класс для всех планировщиков на сетке....
Definition: grid_path_finder.h:40
bmpf::NodeGridPathFinder::_closedStateConvCodeSet
std::unordered_set< long > _closedStateConvCodeSet
Definition: node_grid_path_finder.h:193
bmpf::NodeGridPathFinder::ERROR_REACHED_MAX_NODE_CNT
static const int ERROR_REACHED_MAX_NODE_CNT
Definition: node_grid_path_finder.h:45
bmpf::NodeGridPathFinder::_moveNodeFromOpenedToClosed
void _moveNodeFromOpenedToClosed(const std::shared_ptr< PathNode > &node)
Definition: node_grid_path_finder.cpp:9
bmpf::NodeGridPathFinder::prepare
void prepare(const std::vector< double > &startState, const std::vector< double > &endState) override
Definition: node_grid_path_finder.cpp:188
bmpf::NodeGridPathFinder::_closedNodes
std::vector< std::shared_ptr< PathNode > > _closedNodes
Definition: node_grid_path_finder.h:189
bmpf::NodeGridPathFinder::getAllProcessedStates
std::vector< std::vector< double > > getAllProcessedStates()
Definition: node_grid_path_finder.cpp:175