Main Content

move

Move map in world frame

Description

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.

move(map,moveValue,Name=Value) specifies additional options specified by one or more name-value arguments.

example

Examples

collapse all

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 an occupancy map from the ternaryMap.

load exampleMaps.mat
map = occupancyMap(ternaryMap);
show(map)

Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains an object of type image.

Create a smaller local map.

mapLocal = occupancyMap(ternaryMap(end-200:end,1:200));
show(mapLocal)

Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains an object of type image.

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 = [100 100
        100 250
        200 250
        300 250];
show(map)
hold on
plot(path(:,1),path(:,2))
hold off

Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains 2 objects of type image, line.

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(mapLocal,map) 
        show(mapLocal)
        drawnow limitrate
    end
end

Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains an object of type image.

Input Arguments

collapse all

Map representation, specified as a occupancyMap, mapLayer, multiLayerMap, or signedDistanceMap object.

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 Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: MoveType="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.

Data Types: char | string

Fill value for revealed locations because of the shifted map limits, specified as 0 or 1.

Secondary map to sync with, specified as a occupancyMap object. Any revealed locations based on the move are updated with values in this map using the world coordinates.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2019b

expand all