Unrecognized method, property, or field 'vertices' for class 'triangulation'.

4 views (last 30 days)
I am trying to create a virtual robot and can not get this code to run without getting a error.
clc
clear all
dtr = pi/180;
base =stlread('base.stl');
arm=stlread('arm.stl');
head=stlread('head.stl');
finger=stlread('finger.stl');
patch(base, 'EdgeColor', 'None','FaceColor','r');
patch(arm, 'EdgeColor', 'None','FaceColor', 'b');
patch(head, 'EdgeColor', 'None','FaceColor', 'g');
patch(finger, 'EdgeColor', 'None','FaceColor', 'y');
xlabel('x');
ylabel('y');
zlabel('z');
%Make base larger
for ind=1:length(base.vertices(:,1))
base.vertices(ind,:)=(1150*eye(3)*base.vertices(ind,:)')';
end
%Move the base in the y direction
R=[1 0 0;0 1 0;0 0 1]';d=[0;75;0];
for ind =1:length(base.vertices(:,1))
base.vertices(ind,:) = (R*base.vertices(ind,:)'+d)';
end
%move arm in x and z direction
R=[1 0 0; 0 1 0 ; 0 0 1]';d=[-75;0;0.03];
for ind =1:length(arm.vertices(:,1))
arm.vertices(ind,:) = (R*arm.vertices(ind,:)'+d)';
end
%change head x direction and move 100.03 on z and 300 on x
R=[1 0 0; 0 1 0; 0 0 -1]';d=[250;0;265];
for ind = 1:length(head.vertices(:,1))
head.vertices(ind,:) = (R*head.vertices(ind,:)'+d)';
end
%moving finger
R=[1 0 0; 0 1 0; 0 0 -1]'; d=[520;-171;400];
for ind = 1:length(finger.vertices(:,1))
finger.vertices(ind,:) = (R*finger.vertices(ind,:)'+d)';
end
baseo=base; armo=arm; heado=head; fingero=finger;
patch(baseo, 'EdgeColor', 'None','FaceColor','r');
patch(armo, 'EdgeColor', 'None','FaceColor', 'b');
patch(heado, 'EdgeColor', 'None','FaceColor', 'g');
patch(fingero, 'EdgeColor', 'None','FaceColor', 'y');
axis equal
view(3)
xlabel('x');
ylabel('y');
zlabel('z');
pause
When trying to run this code I keep receiving the error
Unrecognized method, property, or field 'vertices'
for class 'triangulation'.
Error in robot (line 26)
for ind =1:length(base.vertices(:,1))

Accepted Answer

Steven Lord
Steven Lord on 5 Dec 2020
The stlread function's documentation page states it returns a triangulation object. The documentation page for triangulation indicates that this object does not have a vertices property so the error message is correct. You likely want to work with the Points property of the triangulation objects.

More Answers (0)

Categories

Find more on Robotics System Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!