Bench-MR
A Motion Planning Benchmark for Wheeled Mobile Robots
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
GridMaze Class Reference

#include <GridMaze.h>

Inheritance diagram for GridMaze:
Inheritance graph
[legend]
Collaboration diagram for GridMaze:
Collaboration graph
[legend]

Public Member Functions

 GridMaze ()=default
 
 GridMaze (const GridMaze &environment)
 
 GridMaze (unsigned int seed, unsigned int width, unsigned int height, double voxelSize=1.)
 
 ~GridMaze ()
 
unsigned int seed () const
 
bool empty () const
 
double voxelSize () const
 
bool occupied (unsigned int index) const
 
bool occupied (double x, double y)
 
bool occupiedCell (unsigned int xi, unsigned int yi) const
 
double distance (double x, double y) override
 Computes distances field if necessary, and returns the distance to the nearest obstacle. More...
 
double distance (unsigned int index)
 Computes distances field if necessary, and returns the distance to the nearest obstacle. More...
 
double distance (unsigned int xi, unsigned int yi)
 Computes distances field if necessary, and returns the distance to the nearest obstacle. More...
 
bool saveSbplConfigFile (const std::string &filename) const
 Writes cfg file for planners based on sbpl. More...
 
void mapData (unsigned char *data, double resolution=1.)
 
std::string mapString () const
 
std::vector< double > mapDistances ()
 
std::vector< Rectangleobstacles () const
 
std::vector< Rectangleobstacles (double x1, double y1, double x2, double y2) const
 
bool collides (double x, double y) override
 
bool collides (const Polygon &polygon) override
 
double obstacleRatio () const
 
std::string generatorType () const
 
unsigned int cells () const
 
unsigned int voxels_x () const
 
unsigned int voxels_y () const
 
std::string name () const override
 
std::string & name ()
 
void computeDistances ()
 Brute-force, quadratic in the number of cells, algorithm to compute the distance field, i.e. More...
 
void to_json (nlohmann::json &j) override
 
- Public Member Functions inherited from Environment
 Environment ()
 
virtual ~Environment ()=default
 
void setStart (const Point &point)
 
const Pointstart () const
 
void setGoal (const Point &point)
 
const Pointgoal () const
 
virtual bool collides (double x, double y)
 
virtual bool collides (const Polygon &polygon)
 
bool collides (const Point &p)
 
bool collides (const ompl::geometric::PathGeometric &trajectory)
 
bool collides (const ob::State *state)
 
bool checkValidity (const ob::State *state)
 Used by planners to determine if the state is valid or not. More...
 
const ob::RealVectorBounds & bounds () const
 
double width () const
 
double height () const
 
virtual double distance (double x, double y)
 Compute distance from xy-coordinate to the closest obstacle if possible. More...
 
double distance (const ob::State *state)
 Compute distance of a state to the closest obstacle if possible. More...
 
double bilinearDistance (double x, double y, double cellSize=1)
 Bilinear filtering of distance. More...
 
double bilinearDistance (const Point &point, double cellSize=1)
 
double bilinearDistance (const ob::State *state, double cellSize=1)
 
bool distanceGradient (double x, double y, double &dx, double &dy, double p=0.1, double cellSize=1)
 Computes negative gradient of distance field at position x, y. More...
 
virtual std::string name () const
 
void estimateStartGoalOrientations ()
 Estimates potentially suitable theta values for the start and goal state by running a simple line search from start to goal. More...
 
bool thetasDefined () const
 
void setThetas (double start, double goal)
 
ompl::base::StatestartState () const
 
ompl::base::StategoalState () const
 
ompl::base::ScopedState< ob::SE2StateSpace > startScopedState () const
 
ompl::base::ScopedState< ob::SE2StateSpace > goalScopedState () const
 
ob::RealVectorBounds getBounds () const
 
double startTheta () const
 
double goalTheta () const
 
virtual void to_json (nlohmann::json &j)
 
virtual double unit () const
 Unit, e.g. More...
 
void resetCollisionTimer ()
 
double elapsedCollisionTime () const
 

Static Public Member Functions

static std::shared_ptr< GridMazecreateRandom (unsigned int width=DefaultWidth, unsigned int height=DefaultHeight, double obsRatio=0.3, unsigned int seed=(unsigned int) time(nullptr), int borderSize=1)
 
static std::shared_ptr< GridMazecreateRandomCorridor (unsigned int width=DefaultWidth, unsigned int height=DefaultHeight, double radius=2, int branches=30, unsigned int seed=(unsigned int) time(nullptr), int borderSize=1)
 
static std::shared_ptr< GridMazecreateFromObstacles (const std::vector< Rectangle > &obstacles, unsigned int width=DefaultWidth, unsigned int height=DefaultHeight, int borderSize=1)
 
static std::shared_ptr< GridMazecreateSimple ()
 
static std::shared_ptr< GridMazecreateFromMovingAiScenario (Scenario &scenario)
 
static std::shared_ptr< GridMazecreateFromImage (const std::string &filename, double occupancy_threshold=0.5, int width=0, int height=0)
 Creates a map from a grayscale image where tones below the occupancy threshold are considered obstacles. More...
 

Static Public Attributes

static const unsigned int DefaultWidth = 50
 
static const unsigned int DefaultHeight = 50
 

Protected Member Functions

unsigned int coord2key (double x, double y) const
 
void fill (double x, double y, bool value)
 
void fill (const Rectangle &r, bool value)
 
void fillBorder (bool value, int size=1)
 
distance_computation::Method distanceComputationMethod () const
 

Protected Attributes

Stopwatch _collision_timer
 
- Protected Attributes inherited from Environment
Point _start
 
Point _goal
 
double _start_theta {0}
 
double _goal_theta {0}
 
bool _thetas_defined {false}
 
ob::RealVectorBounds _bounds {2}
 
Stopwatch _collision_timer
 

Friends

std::ostream & operator<< (std::ostream &stream, const GridMaze &m)
 

Constructor & Destructor Documentation

◆ GridMaze() [1/3]

GridMaze::GridMaze ( )
default

◆ GridMaze() [2/3]

GridMaze::GridMaze ( const GridMaze environment)

◆ GridMaze() [3/3]

GridMaze::GridMaze ( unsigned int  seed,
unsigned int  width,
unsigned int  height,
double  voxelSize = 1. 
)

◆ ~GridMaze()

GridMaze::~GridMaze ( )

Member Function Documentation

◆ cells()

unsigned int GridMaze::cells ( ) const
inline

◆ collides() [1/2]

bool GridMaze::collides ( const Polygon polygon)
overridevirtual

Reimplemented from Environment.

◆ collides() [2/2]

bool GridMaze::collides ( double  x,
double  y 
)
overridevirtual

Reimplemented from Environment.

◆ computeDistances()

void GridMaze::computeDistances ( )

Brute-force, quadratic in the number of cells, algorithm to compute the distance field, i.e.

distance to the nearest obstacle for every voxel.

◆ coord2key()

unsigned int GridMaze::coord2key ( double  x,
double  y 
) const
inlineprotected

◆ createFromImage()

std::shared_ptr< GridMaze > GridMaze::createFromImage ( const std::string &  filename,
double  occupancy_threshold = 0.5,
int  width = 0,
int  height = 0 
)
static

Creates a map from a grayscale image where tones below the occupancy threshold are considered obstacles.

Optional resizing is applied if the provided width and height are nonzero.

◆ createFromMovingAiScenario()

std::shared_ptr< GridMaze > GridMaze::createFromMovingAiScenario ( Scenario scenario)
static

◆ createFromObstacles()

shared_ptr< GridMaze > GridMaze::createFromObstacles ( const std::vector< Rectangle > &  obstacles,
unsigned int  width = DefaultWidth,
unsigned int  height = DefaultHeight,
int  borderSize = 1 
)
static

◆ createRandom()

std::shared_ptr< GridMaze > GridMaze::createRandom ( unsigned int  width = DefaultWidth,
unsigned int  height = DefaultHeight,
double  obsRatio = 0.3,
unsigned int  seed = (unsigned int)time(nullptr),
int  borderSize = 1 
)
static

◆ createRandomCorridor()

std::shared_ptr< GridMaze > GridMaze::createRandomCorridor ( unsigned int  width = DefaultWidth,
unsigned int  height = DefaultHeight,
double  radius = 2,
int  branches = 30,
unsigned int  seed = (unsigned int)time(nullptr),
int  borderSize = 1 
)
static

◆ createSimple()

shared_ptr< GridMaze > GridMaze::createSimple ( )
static

◆ distance() [1/3]

double GridMaze::distance ( double  x,
double  y 
)
inlineoverridevirtual

Computes distances field if necessary, and returns the distance to the nearest obstacle.

Reimplemented from Environment.

◆ distance() [2/3]

double GridMaze::distance ( unsigned int  index)
inline

Computes distances field if necessary, and returns the distance to the nearest obstacle.

◆ distance() [3/3]

double GridMaze::distance ( unsigned int  xi,
unsigned int  yi 
)
inline

Computes distances field if necessary, and returns the distance to the nearest obstacle.

◆ distanceComputationMethod()

distance_computation::Method GridMaze::distanceComputationMethod ( ) const
inlineprotected

◆ empty()

bool GridMaze::empty ( ) const
inline

◆ fill() [1/2]

void GridMaze::fill ( const Rectangle r,
bool  value 
)
protected

◆ fill() [2/2]

void GridMaze::fill ( double  x,
double  y,
bool  value 
)
protected

◆ fillBorder()

void GridMaze::fillBorder ( bool  value,
int  size = 1 
)
protected

◆ generatorType()

std::string GridMaze::generatorType ( ) const

◆ mapData()

void GridMaze::mapData ( unsigned char *  data,
double  resolution = 1. 
)

◆ mapDistances()

std::vector< double > GridMaze::mapDistances ( )

◆ mapString()

std::string GridMaze::mapString ( ) const

◆ name() [1/2]

std::string & GridMaze::name ( )
inline

◆ name() [2/2]

std::string GridMaze::name ( ) const
inlineoverridevirtual

Reimplemented from Environment.

◆ obstacleRatio()

double GridMaze::obstacleRatio ( ) const

◆ obstacles() [1/2]

std::vector< Rectangle > GridMaze::obstacles ( ) const

◆ obstacles() [2/2]

std::vector< Rectangle > GridMaze::obstacles ( double  x1,
double  y1,
double  x2,
double  y2 
) const

◆ occupied() [1/2]

bool GridMaze::occupied ( double  x,
double  y 
)
inline

◆ occupied() [2/2]

bool GridMaze::occupied ( unsigned int  index) const
inline

◆ occupiedCell()

bool GridMaze::occupiedCell ( unsigned int  xi,
unsigned int  yi 
) const
inline

◆ saveSbplConfigFile()

bool GridMaze::saveSbplConfigFile ( const std::string &  filename) const

Writes cfg file for planners based on sbpl.

Parameters
filenameThe filename of the ".cfg" file.
Returns
True if saving succeeded, false otherwise.

◆ seed()

unsigned int GridMaze::seed ( ) const
inline

◆ to_json()

void GridMaze::to_json ( nlohmann::json &  j)
inlineoverridevirtual

Reimplemented from Environment.

◆ voxels_x()

unsigned int GridMaze::voxels_x ( ) const
inline

◆ voxels_y()

unsigned int GridMaze::voxels_y ( ) const
inline

◆ voxelSize()

double GridMaze::voxelSize ( ) const
inline

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  stream,
const GridMaze m 
)
friend

Member Data Documentation

◆ _collision_timer

Stopwatch Environment::_collision_timer
protected

◆ DefaultHeight

const unsigned int GridMaze::DefaultHeight = 50
inlinestatic

◆ DefaultWidth

const unsigned int GridMaze::DefaultWidth = 50
inlinestatic

The documentation for this class was generated from the following files: