syncWith

Sync map with overlapping map

Description

example

mat = syncWith(map,sourcemap) updates map with data from another binaryOccupancyMap object, sourcemap. Locations in map that are also found in sourcemap are updated. All other cells in map are set to map.DefaultValue.

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 a binary occupancy map from the complexMap.

load exampleMaps.mat
map = binaryOccupancyMap(complexMap);
show(map)

Create a smaller local map.

mapLocal = binaryOccupancyMap(complexMap(end-20:end,1:20));
show(mapLocal)

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)
    end
end

Input Arguments

collapse all

Map representation, specified as a binaryOccupancyMap object.

Map representation, specified as a binaryOccupancyMap object.

Introduced in R2019b