move(map,moveValue)
moves the local origin of the map to an absolute location,
moveValue, in the world frame, and updates the map
limits. Move values are truncated based on the resolution of the map. By
default, newly revealed regions are set to
map.DefaultValue.
This example shows how to move a local egocentric map and sync it with a larger world map. This process emulates a vehicle driving in an environment and getting updates on obstacles in the new areas.
Load example maps. Create a binary occupancy map from the complexMap.
Follow a path planned in the world map and update the local map as you move your local frame.
Specify path locations and plot on the map.
path = [5 2
8 2
8 8
30 8];
show(map)
hold on
plot(path(:,1),path(:,2))
hold off
Create a loop for moving between points by the map resolution. Divide the difference between points by the map resolution to see how many incremental moves you can make.
for i = 1:length(path)-1
moveAmount = (path(i+1,:)-path(i,:))/map.Resolution;
for j = 1:abs(moveAmount(1)+moveAmount(2))
moveValue = sign(moveAmount).*map.Resolution;
move(mapLocal,moveValue, ..."MoveType","relative","SyncWith",map)
show(mapLocal)
drawnow limitrate
pause(0.2)
endend
Map representation, specified as a binaryOccupancyMap object. This object represents the
environment of the vehicle.
moveValue — Local map origin move value [x y] vector
Local map origin move value, specified as an [x y]
vector. By default, the value is an absolute location to move the local
origin to in the world frame. Use the MoveType name-value pair to specify a relative move.
Name-Value Pair Arguments
Specify optional
comma-separated pairs of Name,Value arguments. Name is
the argument name and Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN.
Example: 'MoveType','relative'
'MoveType' — Type of move 'absolute' (default) | 'relative'
Type of move, specified as 'absolute' or
'relative'. For relative moves, specify a
relative [x y] vector for
moveValue based on your current local
frame.
'FillValue' — Fill value for revealed locations 0 (default) | 1
Fill value for revealed locations because of the shifted map limits,
specified as 0 or 1.
'SyncWith' — Secondary map to sync with binaryOccupancyMap object
Secondary map to sync with, specified as a binaryOccupancyMap object. Any revealed locations based on
the move are updated with values in this map using the world
coordinates.