46 GridMap::GridMap(
double xmin,
double xmax,
double ymin,
double ymax,
double resolution,
50 , resolution_(resolution)
55 , grid_data_(grid_data)
59 throw std::invalid_argument(
"Grid data size does not match the grid size");
64 : xsize_(grid_msg->info.width)
65 , ysize_(grid_msg->info.height)
66 , resolution_(grid_msg->info.resolution)
67 , xmin_(grid_msg->info.origin.position.x)
68 , ymin_(grid_msg->info.origin.position.y)
69 , xmax_(
axis_upper(xmin_, resolution_, xsize_))
70 , ymax_(
axis_upper(ymin_, resolution_, ysize_))
71 , grid_data_(grid_msg->data)
75 throw std::invalid_argument(
"Grid data size does not match the grid size");
80 : xsize_(0), ysize_(0), resolution_(0), xmin_(0.0), ymin_(0.0), xmax_(0.0), ymax_(0.0)
86 xsize_ = grid_msg->info.width;
87 ysize_ = grid_msg->info.height;
89 xmin_ = grid_msg->info.origin.position.x;
90 ymin_ = grid_msg->info.origin.position.y;
99 return ((i <=
ysize_ - 1) and (j <=
xsize_ - 1)) ? true :
false;
113 std::cout <<
"WARNING (grid2RowMajor) i and j NOT within bounds" << std::endl;
121 const auto i =
static_cast<unsigned int>(idx /
xsize_);
122 const auto j = idx - i *
xsize_;
145 unsigned int j =
static_cast<unsigned int>(std::floor((x -
xmin_) /
resolution_));
146 unsigned int i =
static_cast<unsigned int>(std::floor((y -
ymin_) /
resolution_));
181 throw std::invalid_argument(
"Grid index out of range");
183 return static_cast<double>(
grid_data_.at(idx)) / 100.0;
188 std::cout <<
"Grid \n"
189 <<
"x-axis: [" <<
xmin_ <<
", " <<
xmax_ <<
"] \n"
190 <<
"y-axis: [" <<
ymin_ <<
", " <<
ymax_ <<
"] \n"
191 <<
"xsize: " <<
xsize_ <<
"\n"
192 <<
"ysize: " <<
ysize_ <<
"\n"
193 <<
"size: " <<
grid_data_.size() << std::endl;