34 #include <fast_methods/fm/eikonalsolver.hpp>
35 #include <fast_methods/ndgridmap/fmcell.h>
37 #include <fast_methods//utils/utils.h>
59 console::warning(
"Setting a goal point in DDQM is experimental. It may lead to wrong results.");
72 for(
size_t i = 0; i <
grid_->size(); ++i)
73 grid_->getCell(i).setState(FMState::FROZEN);
76 unsigned int n_neighs = 0;
78 grid_->getCell(i).setArrivalTime(0);
80 for (
unsigned int j = 0; j < n_neighs; ++j) {
88 bool stopPropagation =
false;
93 std::array<size_t, 2> counts = {0,0};
95 while ((!
queues_[0].empty() || !
queues_[1].empty()) && !stopPropagation) {
96 while (!
queues_[lq].empty() && !stopPropagation) {
97 unsigned int idx =
queues_[lq].front();
99 if (
grid_->getCell(idx).isOccupied())
103 grid_->getCell(idx).setArrivalTime(newT);
105 for (
unsigned int j = 0; j < n_neighs; ++j) {
107 if (
grid_->getCell(n).getState() == FMState::FROZEN)
109 grid_->getCell(n).setState(FMState::OPEN);
120 grid_->getCell(idx).setState(FMState::FROZEN);
123 stopPropagation =
true;
134 (std::array<size_t, 2> & counts) {
135 double minPercent = 0.65;
136 double maxPercent = 0.75;
137 double currentPercent;
139 currentPercent = counts[0]/double(counts[1]);
141 currentPercent = 1.0;
142 if (currentPercent <= minPercent)
144 else if (currentPercent >= maxPercent)
158 double avgSpeed = 1.0/(
grid_->getAvgSpeed()*
grid_->getLeafSize());
163 virtual void printRunInfo
166 std::cout <<
'\t' <<
name_ <<
'\n'
167 <<
'\t' <<
"Elapsed time: " <<
time_ <<
" ms\n";
182 std::array<std::queue<unsigned int>, 2>
queues_;
Abstract class that serves as interface for the actual EikonalSolvers implemented. It requires (at least) the computeInternal method to be implemented,.
virtual void setup()
Executes EikonalSolver setup and other checks.
double time_
Time elapsed by the compute method.
double thStep_
Threshold step for each full iteration.
virtual void setEnvironment(grid_t *g)
Sets and cleans the grid in which operations will be performed.
virtual void setup()
Checks that the solver is ready to run. Sets the grid unclean.
std::array< unsigned int, 2 *grid_t::getNDims()> neighbors_
Auxiliar array which stores the neighbor of each iteration of the computeFM() function.
std::array< std::queue< unsigned int >, 2 > queues_
Queues which contain the lower and higher cells to be expanded in further iterations.
virtual double solveEikonal(const int &idx)
Solves nD Eikonal equation for cell idx. If heuristics are activated, it will add the estimated trave...
void increaseThreshold(std::array< size_t, 2 > &counts)
Dynamically increases the threshold according to the reference paper.
grid_t * grid_
Grid container.
static void info(const std::string &val)
std::vector< unsigned int > init_points_
Initial index.
std::string name_
Solver name.
virtual void reset()
Clears temporal data, so it is ready to run again.
static bool isTimeBetterThan(double t1, double t2)
Returns true if t1 is at least epsilon-lower than t2, provides robust comparions for doubles...
Implements Double Dynamic Queue Method.
virtual void computeInternal()
Actual method that implements DDQM.
double threshold_
Current queue cutoff to divide lower and higher queues.
unsigned int goal_idx_
Goal index.
static void warning(const std::string &val)
virtual void setEnvironment(grid_t *g)
Calls EikonalSolver::setEnvironment() and sets the initial threshold.
virtual void reset()
Clears temporal data, so it is ready to run again.