35 #include <fast_methods/fm/fsm.hpp>
36 #include <fast_methods/ndgridmap/fmcell.h>
37 #include <fast_methods/utils/utils.h>
40 template <
class gr
id_t >
class LSM :
public FSM<grid_t> {
43 LSM(
unsigned maxSweeps = std::numeric_limits<unsigned>::max()) :
FSM<grid_t>(
"LSM", maxSweeps) {}
45 LSM(
const char * name,
unsigned maxSweeps = std::numeric_limits<unsigned>::max()) :
FSM<grid_t>(name, maxSweeps) {}
57 for(
size_t i = 0; i <
grid_->size(); ++i)
58 grid_->getCell(i).setState(FMState::FROZEN);
62 grid_->getCell(i).setArrivalTime(0);
64 for (
unsigned int j = 0; j < n_neighs; ++j)
83 for(
size_t i = 0; i <
grid_->size(); ++i)
84 grid_->getCell(i).setState(FMState::FROZEN);
87 virtual void printRunInfo
90 std::cout <<
'\t' <<
name_ <<
'\n'
91 <<
'\t' <<
"Maximum sweeps: " <<
maxSweeps_ <<
'\n'
92 <<
'\t' <<
"Sweeps performed: " <<
sweeps_ <<
'\n'
93 <<
'\t' <<
"Elapsed time: " <<
time_ <<
" ms\n";
100 if (
grid_->getCell(idx).getState() == FMState::OPEN) {
101 const double prevTime =
grid_->getCell(idx).getArrivalTime();
106 grid_->getCell(idx).setArrivalTime(newTime);
109 for (
unsigned int i = 0; i < n_neighs; ++i)
114 else if(!isnan(newTime) && !isinf(newTime) && (idx ==
goal_idx_))
117 grid_->getCell(idx).setState(FMState::FROZEN);
Implements Fast Sweeping Method.
double time_
Time elapsed by the compute method.
virtual double solveEikonal(const int &idx)
Solves nD Eikonal equation for cell idx. If heuristics are activated, it will add the estimated trave...
virtual void setup()
Executes EikonalSolver setup and other checks.
virtual void reset()
Clears temporal data, so it is ready to run again.
grid_t * grid_
Grid container.
bool stopPropagation_
Flag to stop sweeping (used when goal point has converged).
static void info(const std::string &val)
std::vector< unsigned int > init_points_
Initial index.
void recursiveIteration(size_t depth, int it=0)
Equivalent to nesting as many for loops as dimensions. For every most inner loop iteration, solveForIdx() is called for the corresponding idx.
std::string name_
Solver name.
unsigned int sweeps_
Number of sweeps performed.
bool keepSweeping_
Flag to indicate that at least one more sweep is required.
static bool isTimeBetterThan(double t1, double t2)
Returns true if t1 is at least epsilon-lower than t2, provides robust comparions for doubles...
virtual void setSweep()
Set the sweep variables: initial and final indices for iterations, and the increment of each iteratio...
virtual void computeInternal()
Actual method that implements LSM.
Implements Lock Sweeping Method.
unsigned int goal_idx_
Goal index.
unsigned maxSweeps_
Number of maximum sweeps to perform.
virtual void reset()
Clears temporal data, so it is ready to run again.
std::array< unsigned int, 2 *grid_t::getNDims()> neighbors_
Auxiliar array which stores the neighbor of each iteration of the computeFM() function.
virtual void solveForIdx(unsigned idx)
Actually executes one solving iteration of the LSM.