Buran Motion Planning Framework
grid_path_finder.h
1 #pragma once
2 
3 #include <memory>
4 #include <unordered_map>
5 #include <set>
6 #include <utility>
7 #include <unordered_set>
8 #include <scene.h>
9 #include "path_finder.h"
10 #include "log.h"
11 #include "state.h"
12 
13 #include <iostream>
14 
15 namespace bmpf {
40  class GridPathFinder : public PathFinder {
41  public:
42 
52  static const int ERROR_CAN_NOT_FIND_FREE_END_POINT = 3;
53 
62  const std::shared_ptr<bmpf::Scene> &scene, bool showTrace, int gridSize, int threadCnt = 1
63  );
64 
70  std::vector<double> coordsToState(std::vector<int> &coords) const;
71 
78  std::vector<double> coordsToState(std::vector<int> coords, unsigned long robotNum);
79 
85  bool checkCoords(std::vector<int> coords);
86 
95  std::vector<std::vector<double>>
96  findGridPath(std::vector<int> &startCoords, std::vector<int> &endCoords, int &errorCode);
97 
104  bool checkCoords(const std::vector<int> &coords, unsigned int robotNum);
105 
112  virtual std::vector<int> stateToCoords(std::vector<double> state);
113 
119  void prepare(const std::vector<double> &startState, const std::vector<double> &endState) override;
120 
126  virtual void prepare(std::vector<int> &startCoords, std::vector<int> &endCoords);
127 
139  std::vector<std::vector<double>> checkTask(
140  const std::vector<double> &startState, const std::vector<double> &endState,
141  double opacity
142  );
143 
144 
145  protected:
146 
158  virtual std::vector<int> _findFreePoint(
159  std::vector<int> coords, unsigned long pos, unsigned long maxPos,
160  const std::vector<double> &state
161  );
162 
166  std::vector<double> _gridSteps;
171  std::vector<std::vector<double>> _groupedGridSteps;
179  std::vector<int> _startCoords;
183  std::vector<int> _endCoords;
187  std::vector<double> _startStateFromCoords;
191  std::vector<double> _endStateFromCoords;
195  double _maxDist;
199  bool _coordsUsed = false;
205  std::vector<std::vector<int>> _buildedGridPath;
206 
207  public:
208 
213  const std::vector<std::vector<int>> &getBuildedGridPath() const { return _buildedGridPath; }
214 
219  const std::vector<double> &getStartStateFromCoords() const { return _startStateFromCoords; }
220 
225  const std::vector<double> &getEndStateFromCoords() const { return _endStateFromCoords; }
226 
231  const std::vector<double> &getGridSteps() const { return _gridSteps; }
232 
237  const double &getMaxDist() const { return _maxDist; }
238 
244  const std::vector<std::vector<double>> &getGroupedGridSteps() const { return _groupedGridSteps; }
245  };
246 
247 
248 }
bmpf::GridPathFinder::_coordsUsed
bool _coordsUsed
Definition: grid_path_finder.h:199
bmpf::GridPathFinder::stateToCoords
virtual std::vector< int > stateToCoords(std::vector< double > state)
Definition: grid_path_finder.cpp:325
bmpf::GridPathFinder::findGridPath
std::vector< std::vector< double > > findGridPath(std::vector< int > &startCoords, std::vector< int > &endCoords, int &errorCode)
Definition: grid_path_finder.cpp:221
bmpf::GridPathFinder::_maxDist
double _maxDist
Definition: grid_path_finder.h:195
bmpf::GridPathFinder::checkCoords
bool checkCoords(std::vector< int > coords)
Definition: grid_path_finder.cpp:284
bmpf::GridPathFinder::coordsToState
std::vector< double > coordsToState(std::vector< int > &coords) const
Definition: grid_path_finder.cpp:259
bmpf::GridPathFinder::prepare
void prepare(const std::vector< double > &startState, const std::vector< double > &endState) override
Definition: grid_path_finder.cpp:99
bmpf::GridPathFinder::getMaxDist
const double & getMaxDist() const
Definition: grid_path_finder.h:237
bmpf::GridPathFinder::_startCoords
std::vector< int > _startCoords
Definition: grid_path_finder.h:179
bmpf::GridPathFinder::getStartStateFromCoords
const std::vector< double > & getStartStateFromCoords() const
Definition: grid_path_finder.h:219
bmpf::GridPathFinder::_groupedGridSteps
std::vector< std::vector< double > > _groupedGridSteps
Definition: grid_path_finder.h:171
bmpf::GridPathFinder::getBuildedGridPath
const std::vector< std::vector< int > > & getBuildedGridPath() const
Definition: grid_path_finder.h:213
bmpf::GridPathFinder::ERROR_CAN_NOT_FIND_FREE_END_POINT
static const int ERROR_CAN_NOT_FIND_FREE_END_POINT
Definition: grid_path_finder.h:52
bmpf::GridPathFinder::_findFreePoint
virtual std::vector< int > _findFreePoint(std::vector< int > coords, unsigned long pos, unsigned long maxPos, const std::vector< double > &state)
поиск координат соседней свободной точки Это - рекуррентный метод, он пробует прибавить -1,...
Definition: grid_path_finder.cpp:391
bmpf::GridPathFinder::getGridSteps
const std::vector< double > & getGridSteps() const
Definition: grid_path_finder.h:231
bmpf::GridPathFinder::ERROR_CAN_NOT_FIND_FREE_START_POINT
static const int ERROR_CAN_NOT_FIND_FREE_START_POINT
Definition: grid_path_finder.h:47
bmpf::GridPathFinder::_buildedGridPath
std::vector< std::vector< int > > _buildedGridPath
Definition: grid_path_finder.h:205
bmpf::PathFinder
Базовый класс для всех планировщиков
Definition: path_finder.h:28
bmpf::GridPathFinder::_endStateFromCoords
std::vector< double > _endStateFromCoords
Definition: grid_path_finder.h:191
bmpf::GridPathFinder
Базовый класс для всех планировщиков на сетке Базовый класс для всех планировщиков на сетке....
Definition: grid_path_finder.h:40
bmpf::GridPathFinder::_gridSize
int _gridSize
Definition: grid_path_finder.h:175
bmpf::GridPathFinder::_gridSteps
std::vector< double > _gridSteps
Definition: grid_path_finder.h:166
bmpf::GridPathFinder::_startStateFromCoords
std::vector< double > _startStateFromCoords
Definition: grid_path_finder.h:187
bmpf::GridPathFinder::_endCoords
std::vector< int > _endCoords
Definition: grid_path_finder.h:183
bmpf::GridPathFinder::GridPathFinder
GridPathFinder(const std::shared_ptr< bmpf::Scene > &scene, bool showTrace, int gridSize, int threadCnt=1)
Definition: grid_path_finder.cpp:12
bmpf::GridPathFinder::getEndStateFromCoords
const std::vector< double > & getEndStateFromCoords() const
Definition: grid_path_finder.h:225
bmpf::GridPathFinder::getGroupedGridSteps
const std::vector< std::vector< double > > & getGroupedGridSteps() const
Definition: grid_path_finder.h:244
bmpf::GridPathFinder::checkTask
std::vector< std::vector< double > > checkTask(const std::vector< double > &startState, const std::vector< double > &endState, double opacity)
проверка задания проверка задания, возвращает пустой вектор, если маршрут можно строить штатным образ...
Definition: grid_path_finder.cpp:53