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:
|
meaning |
x-range, y-range |
|---|---|---|
|
a square about the origin |
|
|
the same range on both axes |
|
|
both ranges |
|
an object |
anything with a |
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:
an explicit
workspaceargument;a map that already has a concrete extent (an occupancy grid, a landmark map);
the vehicle’s workspace;
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 aworkspaceattribute, or None- Raises:
ValueError – the first usable candidate is not a valid workspace
- Return type:
- 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
workspaceis None, is converted byexpand_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()