more then one tag on object in figure
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a problem whith a line of code in which i have 3 robots with each a seperate tool. Each tool has the tag tool1-3 depending on the robot now the tool is drawn with the line command inside a loop where it extracts vectorised x,y,z values from a struct. The loop is within another loop inside a switch case for each robot.
my initial thought was to maby declare more than one tag to the obj with the use of j for allocating the same line obj ones it's suppoed to redraw it.
code in which the problem stems is this one:
for j = 1: size(td,2) %the td = rd.xyz a
% V 4x4 matrix is the hand position of the robot in the x,y,z plane V(1:3,1:3) = rotation
% V(1:3,4) = translation
p = V(1:3,4); % This is for the starting position of the line
V(1:3,4) = V(1:3,4)+td(1:3,j); % P is the handposition rd.xyz from the TCP!
q = V(1:3,4); % this is the end position of the line from vector in td(:,j)
x = [p(1) q(1)];
y = [p(2) q(2)];
z = [p(3) q(3)];
if isempty(findobj('tag',['tool3',num2str(j)]))
h = line(x,y,z);
set(h,'tag',['tool3',num2str(j)],...
'color','k',...
'linewidth',3)
else
set(findobj('tag',['tool3',num2str(j)],...
'linewidth',3,...
'color','k',...
'xdata',x,...
'ydata',y,...
'zdata',z)
end
end
what i get is a figure that prints multiple tool lines as the robot moves and i need someway to redraw those away for the updated position of the tool.
the thing i'm getting at the moment looks like this:
I might be going at this all wrong and maby whould collect the vectors in seperate x(j) and y(j), z(j) arrays and ones those have been gathered draw the new line with or something.
0 comentarios
Respuestas (2)
Walter Roberson
el 26 de Oct. de 2020
No. The Tag field of an object must be a character vector or a scalar string. The only way to store multiple tags would be to encode them all into a single character vector. But then you cannot findobj() on them as there is no way to ask to process the content of the tags.
You should instead use addprop() to add properties to the objects, in which case you can find them with findobj -property
if ~hasprop(h, 'tool3'); addprop(h, 'tool3'); end
findobj(groot,'-property', 'tool3')
slowlearner
el 26 de Oct. de 2020
1 comentario
Walter Roberson
el 26 de Oct. de 2020
That would create a tag property such as 'tool3tool7' . You would not be able to use findobj() to search for tool3 or tool7 and find those objects.
Ver también
Categorías
Más información sobre Graphics Object Identification en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!