Go to the documentation of this file.
46 #include <geometry_msgs/Pose.h>
47 #include <nav_msgs/OccupancyGrid.h>
61 inline unsigned int axis_length(
double lower,
double upper,
double resolution)
63 return static_cast<unsigned int>(std::round((upper - lower) / resolution));
73 inline double axis_upper(
double lower,
double resolution,
unsigned int size)
75 return static_cast<double>(resolution * size) + lower;
101 GridMap(
const nav_msgs::OccupancyGrid::ConstPtr& grid_msg);
112 void update(
const nav_msgs::OccupancyGrid::ConstPtr& grid_msg);
120 bool gridBounds(
unsigned int i,
unsigned int j)
const;
135 unsigned int grid2RowMajor(
unsigned int i,
unsigned int j)
const;
142 std::vector<unsigned int>
rowMajor2Grid(
unsigned int idx)
const;
150 std::vector<double>
grid2World(
unsigned int i,
unsigned int j)
const;
157 std::vector<double>
grid2World(
unsigned int idx)
const;
165 std::vector<unsigned int>
world2Grid(
double x,
double y)
const;
181 double getCell(
double x,
double y)
const;
189 double getCell(
unsigned int i,
unsigned int j)
const;
196 double getCell(
unsigned int idx)
const;
bool gridBounds(unsigned int i, unsigned int j) const
Test if coordinates are within the grid.
unsigned int grid2RowMajor(unsigned int i, unsigned int j) const
Converts grid indices to row major order index.
double resolution() const
Return grid resolution.
const GridData & gridData() const
Return the grid data
unsigned int world2RowMajor(double x, double y) const
Convert world coordinates to row major index.
std::vector< unsigned int > rowMajor2Grid(unsigned int idx) const
Convert row major index to row and column indices.
void update(const nav_msgs::OccupancyGrid::ConstPtr &grid_msg)
Update the grid.
double ymax() const
Return grid ymax.
unsigned int ysize() const
Return y-axis size.
double xmin() const
Return grid xmin.
std::vector< unsigned int > world2Grid(double x, double y) const
Convert world coordinates to row and column index in grid.
std::vector< double > grid2World(unsigned int i, unsigned int j) const
Convert grid coordinates to world position.
double ymin() const
Return grid ymin.
double axis_upper(double lower, double resolution, unsigned int size)
Upper axis limit.
unsigned int xsize() const
Return grid x-axis size.
double xmax() const
Return grid xmax.
void print() const
Print grid properties.
std::vector< int8_t > GridData
Occupancy grid data.
unsigned int axis_length(double lower, double upper, double resolution)
Length of a grid axis.
unsigned int size() const
Return grid size.
GridMap()
Constructor a empty grid.
double getCell(double x, double y) const
Get the value of the cell at a specified position.