Unrecognized method, property, or field 'verts' for class 'PRM'.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I keep getting this error:
"Unrecognized method, property, or field 'verts' for class 'PRM'.
Error in testPRM (line 64)
for j = 1:1:size(RM.verts,1)"
The code is as follow:
%% Create a link for the robot
link2 = createCapsule( createLineSeg( [0.0 0.0], [1 0.0] ), 0.075 );
%% Put links together to make an arm
% make a 2D robot
clf
subplot(1,2,1);
setupGraphics
% Robot is defined by an array of links, plus an array of where to attach
% the origin of a link to the frame of the last link.
robot = createRobot( [link2 link2],[0 0; 1 0] );
% Specify the kind of link. 'r' for rotational, 't' for prismatic
robot.type = ['r' 'r'];
% Give which link to attach to, 0 is ground.
robot.attach = [0 1];
% Give the joint limits (and search space) for each joint. Since
% I avoided dealing with wrap-around, make the space redundant.
robot.cspace = [-pi 2*pi; -pi 2*pi];
% Calculate the dimension of the robot from the number of links.
robot.dim = length(robot.type);
%% move the arm into some configuration q and display it
q = [pi-0.2 0];
positioned = forwardKin( robot, q );
for i = 1:length(positioned)
drawCapsule( positioned(i) );
end
%% Create some circular obstacles and display them
obs = [createCircle([-0.8 1.2], 0.2 ) createCircle( [-1.2 -0.9], 0.3) ...
createCircle([0.8 1.5], 0.2 ) createCircle( [-1.2 0.9], 0.3)];
subplot(1,2,1);
for o = obs
drawCircle( o );
end
%% Now do the decomposition
clf;
% c-space on the right
subplot(1,2,2);
setupGraphics;
% workspace on the left
subplot(1,2,1);
setupGraphics;
for o = obs
drawCircle( o );
end
% How many vertices to test
maxverts = 200;
% Compute the roadmap. RM is the graph. After max verts comes the desired
% number of links to make to a new vert, followed by the max distance to
% search for neighbors.
RM = PRM( robot, obs, maxverts, 4, 3.5 )
%% Draw the RM (only for 2 and 3 D)
% draw every nth milestone as a robot in workspace
for j = 1:1:size(RM.verts,1)
q = RM.verts(j,:);
subplot(1,2,1);
positioned = forwardKin( robot, q );
for i = 1:length(positioned)
drawCapsule( positioned(i) );
end
end
%%
% Only draw for 2d or 3d c-spaces
subplot(1,2,2);
% Plot all milestones in c-space
for j = 1:size(RM.verts,1)
q = RM.verts(j,:);
if ( robot.dim == 2 )
plot(q(1), q(2),'rx');
end
if ( robot.dim == 3 )
plot3(q(1), q(2), q(3),'rx');
end
end
%%
% draw all edges of graph
if ( robot.dim == 2 || robot.dim == 3 )
[r,c,v] = find(RM.adjMat);
for i = 1:length(r)
t = createLineSeg( RM.verts(r(i),:), RM.verts(c(i),:) );
drawLineSeg( t );
end
end
%% set a start and end
startq = [0 0];
subplot(1,2,1,'replace');
setupGraphics
positioned = forwardKin( robot, startq );
for k = 1:length(positioned)
drawCapsule( positioned(k) );
end
%%
endq = [pi 0];
subplot(1,2,1);
positioned = forwardKin( robot, endq );
for k = 1:length(positioned)
drawCapsule( positioned(k) );
end
%% Attach the start and end to the RM
subplot(1,2,2);
if ( robot.dim == 2 )
plot( startq(1), startq(2),'rO','MarkerFaceColor','r','MarkerSize',6);
plot( endq(1), endq(2),'rO','MarkerFaceColor','r','MarkerSize',6);
end
if ( robot.dim == 3 )
plot3( startq(1), startq(2), startq(3), 'rO','MarkerFaceColor','r','MarkerSize',6);
plot3( endq(1), endq(2), endq(3), 'rO','MarkerFaceColor','r','MarkerSize',6);
end
startvert = attach( startq, RM, robot, obs )
endvert = attach( endq, RM, robot, obs )
if ( robot.dim == 2 )
plot( RM.verts(startvert,1), RM.verts(startvert,2),'rO','MarkerFaceColor','g','MarkerSize',6);
plot( RM.verts(endvert,1), RM.verts(endvert,2),'rO','MarkerFaceColor','g','MarkerSize',6);
end
if ( robot.dim == 3 )
plot3( RM.verts(startvert,1), RM.verts(startvert,2), RM.verts(startvert,3),'rO','MarkerFaceColor','g','MarkerSize',6);
plot3( RM.verts(endvert,1), RM.verts(endvert,2), RM.verts(endvert,3),'rO','MarkerFaceColor','g','MarkerSize',6);
end
%% Use Dijkstra's algorithm to find the shortest path
path = dijkstra2( length(RM.verts), RM.adjMat, startvert, endvert);
%% Add the vertices to the end of the graph verts so the animation doesn't
% need special cases
RM.verts(end+1,:) = startq;
RM.verts(end+1,:) = endq;
path = [ size(RM.verts,1)-1 path size(RM.verts,1) ]
%% Draw the path (only works for 2D and 3D)
subplot(1,2,2);
for i = 1:length(path)-1
l = createLineSeg( RM.verts(path(i),:), RM.verts(path(i+1),:) );
h = drawLineSeg(l,'g');
set(h,'LineWidth',3)
end
%% Move the robot along
for i = 1:length(path)-1
for t = 0:0.25:1
h = subplot(1,2,1,'replace');
setupGraphics;
border = createCircle( [0 0], robot.dim*1.1);
drawCircle(border);
for o = obs
drawCircle( o );
end
interpq = RM.verts(path(i),:) + t * ( RM.verts(path(i+1),:) - RM.verts(path(i),:));
subplot(1,2,2);
plot(interpq(1), interpq(2),'gX');
subplot(1,2,1);
positioned = forwardKin( robot, interpq );
for k = 1:length(positioned)
drawCapsule( positioned(k) );
end
pause(0.15);
end
end
%% If you want to add more nodes to the graph, remove the start and end
% vertices first
RM.verts = RM.verts(1:end-2,:);
0 comentarios
Respuestas (1)
Walter Roberson
el 10 de Jun. de 2022
This code uses a number of routines that are not part of anything provided by Mathworks. I have not been successful in figuring out which third-party toolbox they are from. Some of the functions I only find by the same name in a support package for the iRobot iCreate, but with calls that do not match. Some of the other functions I only find as part of particular university courses. Some I just cannot find at all.
This appears to be a question about some external package.
3 comentarios
Walter Roberson
el 12 de Jun. de 2022
You are expected to copy PRMstub.m to PRM.m . Then you are expected to complete the code in PRM.m in order to have it build the Probabalistic Road Map.
That is, the point of the assignment is for you to figure out how to build a Probabilistic Road Map.
Ver también
Categorías
Más información sobre Robotics en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!