#include <yarp/dev/MapGrid2D.h>
Public Types | |
enum | map_flags { MAP_CELL_FREE = 0, MAP_CELL_KEEP_OUT = 1, MAP_CELL_TEMPORARY_OBSTACLE = 2, MAP_CELL_ENLARGED_OBSTACLE = 3, MAP_CELL_WALL = 4, MAP_CELL_UNKNOWN = 5 } |
typedef yarp::sig::PixelMono | CellData |
Public Member Functions | |
MapGrid2D () | |
virtual | ~MapGrid2D () |
bool | isWall (XYCell cell) const |
Checks if a specific cell of the map contains a wall. More... | |
bool | isFree (XYCell cell) const |
Checks if a specific cell of the map is free, i.e. More... | |
bool | isNotFree (XYCell cell) const |
Checks if a specific cell of the map contains is not free. More... | |
bool | isKeepOut (XYCell cell) const |
Checks if a specific cell of the map is marked as keep-out. More... | |
bool | getMapFlag (XYCell cell, map_flags &flag) const |
Get the flag of a specific cell of the map. More... | |
bool | setMapFlag (XYCell cell, map_flags flag) |
Set the flag of a specific cell of the map. More... | |
bool | setOccupancyData (XYCell cell, double occupancy) |
Set the occupancy data of a specific cell of the map. More... | |
bool | getOccupancyData (XYCell cell, double &occupancy) const |
Retrieves the occupancy data of a specific cell of the map. More... | |
bool | setMapImage (yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) |
bool | getMapImage (yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) const |
bool | setOccupancyGrid (yarp::sig::ImageOf< yarp::sig::PixelMono > &image) |
bool | getOccupancyGrid (yarp::sig::ImageOf< yarp::sig::PixelMono > &image) const |
bool | setOrigin (double x, double y, double theta) |
Sets the origin of the map reference frame (according to ROS convention) More... | |
void | getOrigin (double &x, double &y, double &theta) const |
Retrieves the origin of the map reference frame (according to ROS convention) More... | |
bool | setResolution (double resolution) |
Sets the resolution of the map, i.e. More... | |
void | getResolution (double &resolution) const |
Retrieves the resolution of the map, i.e. More... | |
bool | setSize_in_meters (double x, double y) |
Sets the size of the map in meters, according to the current map resolution. More... | |
bool | setSize_in_cells (size_t x, size_t y) |
Sets the size of the map in cells. More... | |
void | getSize_in_meters (double &x, double &y) const |
Returns the size of the map in meters, according to the current map resolution. More... | |
void | getSize_in_cells (size_t &x, size_t &y) const |
Returns the size of the map in cells. More... | |
size_t | width () const |
Retrieves the map width, expressed in cells. More... | |
size_t | height () const |
Retrieves the map height, expressed in cells. More... | |
bool | setMapName (std::string map_name) |
Sets the map name. More... | |
std::string | getMapName () const |
Retrieves the map name. More... | |
bool | crop (int left, int top, int right, int bottom) |
Modifies the map, cropping pixels at the boundaries. More... | |
bool | isIdenticalTo (const MapGrid2D &otherMap) const |
Checks is two maps are identical. More... | |
bool | enlargeObstacles (double size) |
Performs the obstacle enlargement operation. More... | |
bool | loadFromFile (std::string map_filename) |
Loads a yarp map file from disk. More... | |
bool | saveToFile (std::string map_filename) const |
Store a yarp map file to disk. More... | |
bool | read (yarp::os::ConnectionReader &connection) override |
Read this object from a network connection. More... | |
bool | write (yarp::os::ConnectionWriter &connection) const override |
Write vector to a connection. More... | |
Public Member Functions inherited from yarp::os::Portable | |
virtual Type | getType () const |
Public Member Functions inherited from yarp::os::PortReader | |
virtual | ~PortReader () |
Destructor. More... | |
virtual Type | getReadType () const |
Public Member Functions inherited from yarp::os::PortWriter | |
virtual | ~PortWriter () |
Destructor. More... | |
virtual void | onCompletion () const |
This is called when the port has finished all writing operations. More... | |
virtual void | onCommencement () const |
This is called when the port is about to begin writing operations. More... | |
virtual yarp::os::Type | getWriteType () const |
Public Member Functions inherited from yarp::dev::Nav2D::MapGrid2DInfo | |
MapGrid2DInfo () | |
XYWorld | cell2World (XYCell cell) const |
yarp::dev::Nav2D::Map2DLocation | toLocation (XYCell cell) const |
XYCell | toXYCell (yarp::dev::Nav2D::Map2DLocation loc) const |
XYCell | world2Cell (XYWorld world) const |
XYCell | world2Cell_unsafeFast (XYWorld world) const |
yarp::dev::Nav2D::Map2DLocation | toLocation (XYWorld cell) const |
XYWorld | toXYWorld (yarp::dev::Nav2D::Map2DLocation loc) const |
bool | isInsideMap (XYCell cell) const |
Checks if a cell is inside the map. More... | |
bool | isInsideMap (XYWorld world) const |
Checks if a world coordinate is inside the map. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from yarp::os::Portable | |
static bool | copyPortable (const PortWriter &writer, PortReader &reader) |
Copy one portable to another, via writing and reading. More... | |
Public Attributes inherited from yarp::dev::Nav2D::MapGrid2DInfo | |
std::string | m_map_name |
double | m_resolution |
meters/pixel More... | |
MapGrid2DOrigin | m_origin |
pose of the map frame w.r.t. the bottom left corner of the map image More... | |
size_t | m_width |
cells More... | |
size_t | m_height |
cells More... | |
Definition at line 30 of file MapGrid2D.h.
Definition at line 34 of file MapGrid2D.h.
Enumerator | |
---|---|
MAP_CELL_FREE | |
MAP_CELL_KEEP_OUT | |
MAP_CELL_TEMPORARY_OBSTACLE | |
MAP_CELL_ENLARGED_OBSTACLE | |
MAP_CELL_WALL | |
MAP_CELL_UNKNOWN |
Definition at line 38 of file MapGrid2D.h.
MapGrid2D::MapGrid2D | ( | ) |
Definition at line 69 of file MapGrid2D.cpp.
|
virtualdefault |
bool MapGrid2D::crop | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom | ||
) |
Modifies the map, cropping pixels at the boundaries.
left,top,right,bottom | the corners of the map area to keep (expressed in pixel coordinates). If the value is negative, all unknown pixels are removed until a significative pixel is found. |
Definition at line 614 of file MapGrid2D.cpp.
bool MapGrid2D::enlargeObstacles | ( | double | size | ) |
Performs the obstacle enlargement operation.
It's useful to set size to a value equal or larger to the radius of the robot bounding box. In this way a navigation algorithm can easily check obstacle collision by comparing the location of the center of the robot with cell value (free/occupied etc)
size | the size of the enlargement, in meters. If size>0 the requested enlargement is performed. If the function is called multiple times, the enlargement sums up. If size <= 0 the enlargement stored in the map is cleaned up. |
Definition at line 180 of file MapGrid2D.cpp.
Get the flag of a specific cell of the map.
cell | is the cell location, referred to the top-left corner of the map. |
Definition at line 973 of file MapGrid2D.cpp.
bool MapGrid2D::getMapImage | ( | yarp::sig::ImageOf< yarp::sig::PixelRgb > & | image | ) | const |
Definition at line 147 of file MapGrid2D.cpp.
std::string MapGrid2D::getMapName | ( | ) | const |
bool MapGrid2D::getOccupancyData | ( | XYCell | cell, |
double & | occupancy | ||
) | const |
Retrieves the occupancy data of a specific cell of the map.
occupancy | represents the probability (0-100) of the cell of being occupied by a wall/obstacle etc. |
Definition at line 995 of file MapGrid2D.cpp.
bool MapGrid2D::getOccupancyGrid | ( | yarp::sig::ImageOf< yarp::sig::PixelMono > & | image | ) | const |
Definition at line 1025 of file MapGrid2D.cpp.
void MapGrid2D::getOrigin | ( | double & | x, |
double & | y, | ||
double & | theta | ||
) | const |
Retrieves the origin of the map reference frame (according to ROS convention)
x,y,theta | is the pose of the origin, expressed in [m], [deg] and referred to the bottom-left corner of the map, pointing outwards. |
Definition at line 877 of file MapGrid2D.cpp.
void MapGrid2D::getResolution | ( | double & | resolution | ) | const |
Retrieves the resolution of the map, i.e.
the conversion factor which represents the metric size of a map cell.
resolution | the map resolution, expressed in [m/cell]. e.g. resolution=0.05 means that each cell of the map represent 5cm of the real world. |
Definition at line 895 of file MapGrid2D.cpp.
void MapGrid2D::getSize_in_cells | ( | size_t & | x, |
size_t & | y | ||
) | const |
Returns the size of the map in cells.
x,y | is the map size in cells. |
Definition at line 956 of file MapGrid2D.cpp.
void MapGrid2D::getSize_in_meters | ( | double & | x, |
double & | y | ||
) | const |
Returns the size of the map in meters, according to the current map resolution.
x,y | is the map size in meters. |
Definition at line 950 of file MapGrid2D.cpp.
size_t MapGrid2D::height | ( | ) | const |
Retrieves the map height, expressed in cells.
Definition at line 137 of file MapGrid2D.cpp.
bool MapGrid2D::isFree | ( | XYCell | cell | ) | const |
Checks if a specific cell of the map is free, i.e.
the robot can freely pass through the cell
cell | is the cell location, referred to the top-left corner of the map. |
Definition at line 104 of file MapGrid2D.cpp.
bool MapGrid2D::isIdenticalTo | ( | const MapGrid2D & | otherMap | ) | const |
Checks is two maps are identical.
Definition at line 55 of file MapGrid2D.cpp.
bool MapGrid2D::isKeepOut | ( | XYCell | cell | ) | const |
Checks if a specific cell of the map is marked as keep-out.
User can set a cell as keep-out to prevent a robot to pass through it, even if no obstacles are present in the path.
cell | is the cell location, referred to the top-left corner of the map. |
Definition at line 115 of file MapGrid2D.cpp.
bool MapGrid2D::isNotFree | ( | XYCell | cell | ) | const |
Checks if a specific cell of the map contains is not free.
It may be occupied by a wall, an obstacle, a keep-out area etc.
cell | is the cell location, referred to the top-left corner of the map. |
Definition at line 92 of file MapGrid2D.cpp.
bool MapGrid2D::isWall | ( | XYCell | cell | ) | const |
Checks if a specific cell of the map contains a wall.
A robot cannot pass through a cell occupied by a wall.
cell | is the cell location, referred to the top-left corner of the map. |
Definition at line 125 of file MapGrid2D.cpp.
bool MapGrid2D::loadFromFile | ( | std::string | map_filename | ) |
Loads a yarp map file from disk.
File must have .map extension. param map_filename is the full path to the map file.
Definition at line 512 of file MapGrid2D.cpp.
|
overridevirtual |
Read this object from a network connection.
Override this for your particular class.
reader | an interface to the network connection for reading |
Implements yarp::os::Portable.
Definition at line 768 of file MapGrid2D.cpp.
bool MapGrid2D::saveToFile | ( | std::string | map_filename | ) | const |
Store a yarp map file to disk.
File must have .map extension. param map_filename is the full path to the map file.
Definition at line 709 of file MapGrid2D.cpp.
Set the flag of a specific cell of the map.
cell | is the cell location, referred to the top-left corner of the map. |
Definition at line 962 of file MapGrid2D.cpp.
bool MapGrid2D::setMapImage | ( | yarp::sig::ImageOf< yarp::sig::PixelRgb > & | image | ) |
Definition at line 162 of file MapGrid2D.cpp.
bool MapGrid2D::setMapName | ( | std::string | map_name | ) |
Sets the map name.
map_name | the map name. |
Definition at line 900 of file MapGrid2D.cpp.
bool MapGrid2D::setOccupancyData | ( | XYCell | cell, |
double | occupancy | ||
) |
Set the occupancy data of a specific cell of the map.
occupancy | represents the probability (0-100) of the cell of being occupied by a wall/obstacle etc. |
Definition at line 984 of file MapGrid2D.cpp.
bool MapGrid2D::setOccupancyGrid | ( | yarp::sig::ImageOf< yarp::sig::PixelMono > & | image | ) |
Definition at line 1013 of file MapGrid2D.cpp.
bool MapGrid2D::setOrigin | ( | double | x, |
double | y, | ||
double | theta | ||
) |
Sets the origin of the map reference frame (according to ROS convention)
x,y,theta | is the pose of the origin, expressed in [m], [deg] and referred to the bottom-left corner of the map, pointing outwards. |
Definition at line 850 of file MapGrid2D.cpp.
bool MapGrid2D::setResolution | ( | double | resolution | ) |
Sets the resolution of the map, i.e.
the conversion factor which represents the metric size of a map cell.
resolution | the map resolution, expressed in [m/cell]. e.g. resolution=0.05 means that each cell of the map represent 5cm of the real world. |
Definition at line 884 of file MapGrid2D.cpp.
bool MapGrid2D::setSize_in_cells | ( | size_t | x, |
size_t | y | ||
) |
Sets the size of the map in cells.
x,y | is the map size in cells. |
Definition at line 934 of file MapGrid2D.cpp.
bool MapGrid2D::setSize_in_meters | ( | double | x, |
double | y | ||
) |
Sets the size of the map in meters, according to the current map resolution.
x,y | is the map size in meters. |
Definition at line 916 of file MapGrid2D.cpp.
size_t MapGrid2D::width | ( | ) | const |
Retrieves the map width, expressed in cells.
Definition at line 142 of file MapGrid2D.cpp.
|
overridevirtual |
Write vector to a connection.
return true iff a vector was written correctly
Implements yarp::os::Portable.
Definition at line 814 of file MapGrid2D.cpp.