25 #include <fast_methods/ndgridmap/ndgridmap.hpp>
28 using namespace cimg_library;
49 template<
class T,
size_t ndims>
50 static void loadMapFromImg
52 std::vector<unsigned int> obs;
53 CImg<double> img(filename);
54 std::array<unsigned int, ndims> dimsize;
55 dimsize[0] = img.width();
56 dimsize[1] = img.height();
61 double occupancy = img(x,y)/255;
62 unsigned int idx = img.width()*(img.height()-y-1)+x;
63 grid[idx].setOccupancy(occupancy);
64 if (grid[idx].isOccupied())
94 template<
class T,
size_t ndims>
95 static int loadMapFromText
98 std::vector<unsigned int> obs;
104 std::getline(file, val);
112 if (ndims_aux != ndims) {
113 console::error(
"Number of dimensions specified does not match the loaded grid.");
117 std::array<unsigned int, ndims> dimsize;
118 for (
unsigned int &i : dimsize) {
123 grid.setLeafSize(leafsize);
126 for (
unsigned int i = 0; i < grid.
size(); ++i)
129 grid[i].setOccupancy(occupancy);
131 if (grid[i].isOccupied())
void resize(const std::array< unsigned int, ndims > &dimsize)
Resizes each dimension of the grid according dimsize.
static void error(const std::string &val)
Auxiliar static class which helps to load maps into nDGridMap.
void setOccupiedCells(const std::vector< unsigned int > &obs)
Sets the cells which are occupied. Usually called by grid loaders.
Templated class which represents a n-dimensional grid map. Its cells are assumed to be cubic...
unsigned int size() const
Returns number of cells in the grid.