[isValid,lastValid] = isMotionValid(validator,state1,state2)
checks if the path between two states is valid by interpolating between states. The function
also returns the last valid state along the path.
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
Initial 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.
Data Types: single | double
state2 — Final state positions n-element row vector | m-by-n matrix
Final 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.
isValid — Valid states m-element logical column vector
Valid states, returned as an m-element logical column
vector.
Data Types: logical
lastValid — Final valid state along each path n-element row vector | m-by-n matrix
Final valid state along each path, returned as an n-element row
vector or m-by-n matrix. n is
the dimension of the state space specified in the state space property in
validator. m is the number of paths validated.
Each row contains the final valid state along the associated path.
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.