The workspace

Mobile robots live in a rectangular region of the plane, the workspace, written as [xmin, xmax, ymin, ymax]. It is the extent of a map, the limits of a plot, and the region from which random goals, landmarks and particles are drawn.

Many classes have a workspace argument: the vehicles, the drivers (RandomPath), the maps (LandmarkMap, BinaryOccupancyGrid, PolygonMap) and the estimators (EKF, ParticleFilter). All of them accept the same things:

workspace

meaning

x-range, y-range

A (scalar)

a square about the origin

-A:A, -A:A

[A, B]

the same range on both axes

A:B, A:B

[A, B, C, D]

both ranges

A:B, C:D

an object

anything with a workspace

that object’s workspace

so a vehicle can be told to move in the world of a map, or a map can be made to fit a vehicle, by passing one to the other:

map = LandmarkMap(20, workspace=10)
veh = Bicycle(workspace=map)
veh.control = RandomPath(workspace=map)

Precedence

When more than one workspace is available, the one that is used is, in order:

  1. an explicit workspace argument;

  2. a map that already has a concrete extent (an occupancy grid, a landmark map);

  3. the vehicle’s workspace;

  4. otherwise there is none, which is an error for the classes that need one.

The principle is that something with a concrete extent beats something that is declared: a map loaded from a file cannot change its size, so the vehicle conforms to it, whereas a map that is being generated can be made to fit the vehicle by giving it the vehicle as its workspace. For example, a RandomPath with no workspace of its own chooses waypoints inside the workspace of the vehicle it is attached to, and an EKF that is animated shows the vehicle in the workspace of its map.

Classes never modify the workspace of another object other than through its public workspace property.

resolve_workspace(*sources)[source]

Resolve a workspace from several candidate sources

Parameters:

sources (Union[float, ndarray, Sequence[float], HasWorkspace, None, Any]) – candidates in order of precedence, each a scalar, a 2-vector, a 4-vector, an object with a workspace attribute, or None

Raises:

ValueError – the first usable candidate is not a valid workspace

Return type:

ndarray[Tuple[Literal[4]], dtype[floating]] | None

Returns:

workspace bounds [xmin, xmax, ymin, ymax], or None if no candidate has a workspace

The first candidate that is not None, and is not an object whose workspace is None, is converted by expand_dims():

candidate

x-range

y-range

A (scalar)

-A:A

-A:A

[A, B]

A:B

A:B

[A, B, C, D]

A:B

C:D

For example, a class that takes an explicit workspace but otherwise uses that of its map and then its vehicle:

workspace = resolve_workspace(workspace, map, vehicle)

See also

expand_dims()