Check the points of the path are valid states. All three points are in free space, so are considered valid.
isValid = isStateValid(validator,path)
isValid = 3x1 logical array
1
1
1
Check the motion between each sequential path states. The isMotionValid function interpolates along the path between states. If a path segment is invalid, plot the last valid point along the path.
startStates = [path(1,:);path(2,:)];
endStates = [path(2,:);path(3,:)];
for i = 1:2
[isPathValid, lastValid] = isMotionValid(validator,startStates(i,:),endStates(i,:));
if ~isPathValid
plot(lastValid(1),lastValid(2),'or')
endend
hold off
Check the points of the path are valid states. All three points are in free space, so are considered valid.
isValid = isStateValid(validator,path)
isValid = 3x1 logical array
1
1
1
Check the motion between each sequential path states. The isMotionValid function interpolates along the path between states. If a path segment is invalid, plot the last valid point along the path.
startStates = [path(1,:);path(2,:)];
endStates = [path(2,:);path(3,:)];
for i = 1:2
[isPathValid, lastValid] = isMotionValid(validator,startStates(i,:),endStates(i,:));
if ~isPathValid
plot(lastValid(1),lastValid(2),'or')
endend
hold off
Validate Path Through 3-D Occupancy Map Environment
Check the motion between each sequential path states.
isPathValid = zeros(size(pthObj.States,1)-1,1,'logical');
for i = 1:size(pthObj.States,1)-1
[isPathValid(i), ~] = isMotionValid(sv,pthObj.States(i,:),pthObj.States(i+1,:));
end
isPathValid
isPathValid = 5×1 logical array
1
1
1
1
1
Visualize the results.
show(omap)
hold on
scatter3(start(1,1),start(1,2),start(1,3),'g','filled') % draw start state
scatter3(goal(1,1),goal(1,2),goal(1,3),'r','filled') % draw goal state
plot3(pthObj.States(:,1),pthObj.States(:,2),pthObj.States(:,3),'r-','LineWidth',2) % draw path
states — State positions n-element row vector | m-by-n matrix
State positions, specified as an n-element row vector or
m-by-n matrix. n is the
dimension of the state space specified in validator.
m is the number of states to validate.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.