www.gusucode.com > robotics 案例源码程序 matlab代码 > robotics/CreateOrUpdatePRMExample.m

    %% Create or Update PRM
% Create or update your roadmap. To create the roadmap, call 
% |prm = robotics.PRM(map,__)| or specify the |Map| property on the |PRM| 
% object. Then, call the |update|, |findpath|, or |show| method. At this 
% point, the nodes are randomly generated and the connections are made.
%
%
% This roadmap changes only if you call update or change the properties in 
% the |PRM| object. When properties change, any method (|update|, |findpath|, 
% or |show|) called on the object triggers the roadmap points and connections 
% to be recalculated. Because recalculating the map can be computationally 
% intensive, you can reuse the same roadmap by calling |findpath| with 
% different starting and ending locations.

%%
% Load a map file and create an occupancy grid.

filePath = fullfile(fileparts(which('PathPlanningExample')),'data','exampleMaps.mat');
load(filePath)
map = robotics.BinaryOccupancyGrid(simpleMap,2);

%%
% Create a roadmap. Your nodes and connections might look different due to 
% the random placement of nodes.

prm = robotics.PRM(map,100);
show(prm)

%%
% Call |update| or change a parameter to update the |PRM| nodes and connections.

update(prm)
show(prm)

% The PRM algorithm recalculates the node placement and generates a new network of nodes.