bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::planning::BoxWorld Class Reference

A rectangular slice of the plane with axis-aligned box obstacles, a start and a goal. More...

#include <box_world.h>

Classes

struct  Box
 An axis-aligned box [x0, x1] x [y0, y1] [m]. More...
struct  RayHit
 What a range beam found: whether it struck anything within reach, and how far away. More...

Public Types

using Point = std::array<real_t, 2>

Public Member Functions

 BoxWorld (real_t width, real_t height, std::vector< Box > obstacles, real_t robot_radius, const Point &start, const Point &goal)
real_t width () const noexcept
real_t height () const noexcept
real_t robot_radius () const noexcept
const std::vector< Box > & obstacles () const noexcept
const Point & start () const noexcept
const Point & goal () const noexcept
bool is_free (const Point &p) const
 True if a disc of the given radius centred at p touches no obstacle and no outer wall. The default radius is the robot's.
bool is_free (const Point &p, real_t radius) const
OccupancyGrid occupancy_grid (real_t cell_size) const
 The world as an OccupancyGrid of square cells, with the obstacles and the outer walls grown by margin so a point planner stays clear of them. The default margin is the robot's radius; a margin of zero gives the obstacles themselves.
OccupancyGrid occupancy_grid (real_t cell_size, real_t margin) const
RayHit ray_cast (const Point &origin, real_t angle, real_t max_range) const
 Cast a ray from origin in the direction angle (radians, measured from the x axis) and return the distance to the nearest obstacle or outer wall, capped at max_range. This is the ground truth a range sensor measures; add noise for a realistic scan.

Static Public Member Functions

static BoxWorld warehouse ()
 The warehouse of the grid_planning and rrt examples: 8 x 5 m, a 0.25 m robot, five shelves and a wall with a door, from (0.5, 0.5) to (7.5, 4.5).

Detailed Description

A rectangular slice of the plane with axis-aligned box obstacles, a start and a goal.

The world is the rectangle [0, width] x [0, height]. Its obstacles are axis-aligned boxes, such as the shelves and the wall of a warehouse. A disc robot of radius robot_radius is planned as a point by keeping its centre at least that far from every obstacle and from the outer walls.

The same world drives a grid planner and a sampling planner, so the two share one map: occupancy_grid() cuts it into cells with the obstacles grown by the robot's radius, and is_free() tests a single point for a planner that samples the free space, such as RRT.

Member Typedef Documentation

◆ Point

using bitsim::planning::BoxWorld::Point = std::array<real_t, 2>

Constructor & Destructor Documentation

◆ BoxWorld()

bitsim::planning::BoxWorld::BoxWorld ( real_t width,
real_t height,
std::vector< Box > obstacles,
real_t robot_radius,
const Point & start,
const Point & goal )
Parameters
widthThe width of the world, along x [m]
heightThe height, along y [m]
obstaclesThe box obstacles [m]
robot_radiusThe radius of the disc robot [m]
startWhere the robot starts [m]
goalWhere it has to go [m]

Member Function Documentation

◆ goal()

const Point & bitsim::planning::BoxWorld::goal ( ) const
inlinenoexcept

◆ height()

real_t bitsim::planning::BoxWorld::height ( ) const
inlinenoexcept

◆ is_free() [1/2]

bool bitsim::planning::BoxWorld::is_free ( const Point & p) const
inline

True if a disc of the given radius centred at p touches no obstacle and no outer wall. The default radius is the robot's.

◆ is_free() [2/2]

bool bitsim::planning::BoxWorld::is_free ( const Point & p,
real_t radius ) const

◆ obstacles()

const std::vector< Box > & bitsim::planning::BoxWorld::obstacles ( ) const
inlinenoexcept

◆ occupancy_grid() [1/2]

OccupancyGrid bitsim::planning::BoxWorld::occupancy_grid ( real_t cell_size) const
inline

The world as an OccupancyGrid of square cells, with the obstacles and the outer walls grown by margin so a point planner stays clear of them. The default margin is the robot's radius; a margin of zero gives the obstacles themselves.

◆ occupancy_grid() [2/2]

OccupancyGrid bitsim::planning::BoxWorld::occupancy_grid ( real_t cell_size,
real_t margin ) const

◆ ray_cast()

BoxWorld::RayHit bitsim::planning::BoxWorld::ray_cast ( const Point & origin,
real_t angle,
real_t max_range ) const

Cast a ray from origin in the direction angle (radians, measured from the x axis) and return the distance to the nearest obstacle or outer wall, capped at max_range. This is the ground truth a range sensor measures; add noise for a realistic scan.

◆ robot_radius()

real_t bitsim::planning::BoxWorld::robot_radius ( ) const
inlinenoexcept

◆ start()

const Point & bitsim::planning::BoxWorld::start ( ) const
inlinenoexcept

◆ warehouse()

BoxWorld bitsim::planning::BoxWorld::warehouse ( )
static

The warehouse of the grid_planning and rrt examples: 8 x 5 m, a 0.25 m robot, five shelves and a wall with a door, from (0.5, 0.5) to (7.5, 4.5).

◆ width()

real_t bitsim::planning::BoxWorld::width ( ) const
inlinenoexcept

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