Load a data file containing a pretrained MPNet into the MATLAB® workspace. The MPNet has been trained on various 2-D maze maps with widths and heights of 10 meters and resolutions of 2.5 cells per meter. Each maze map contains a passage width of 5 grid cells and wall thickness of 1 grid cell.
Specify the state bounds, and create an SE(2) state space object.
x = map.XWorldLimits;
y = map.YWorldLimits;
z = [-pi pi];
stateBounds = [x; y; z];
stateSpace = stateSpaceSE2(stateBounds);
Configure the mpnetSE2 object to use the pretrained MPNet for predicting state samples on a random map. Set the EncodingSize property values of the mpnetSE2 object to that of the value used for training the network.
Create an MPNet state sampler for the computing state samples. Specify the map environment, the start pose and the goal pose as inputs to the state sampler.
Generate 40 state samples using the MPNet state sampler.
states = sample(sampler,40);
Plot the input data and the computed samples.
show(map)
hold on
plot(start(1),start(2),plannerLineSpec.start{:})
plot(goal(1),goal(2),plannerLineSpec.goal{:})
plot(states(:,1),states(:,2),plannerLineSpec.state{:})
hold off
legend(Location="bestoutside")
State samples, returned as an M-by-N matrix of
real values. M is the number of state samples. N
is the number of state variables. Each row of the matrix contains state variables
corresponding to the input state space model. For the SE(2) state space model,
N is 3 and each row is of the form [xyθ].