grasp
All Data Structures Namespaces Functions Modules
drawHandiCub.m
1 function drawHandiCub(x,hand,varargin)
2 
3  if (size(varargin,2)>0)
4  rotmat2=varargin{1};
5  else
6  rotmat2=eye(4,4);
7  end;
8  rotmat=axis2dcm(x(end-3:end));
9  rotmat(1:3,4)=x(end-6:end-4);
10 
11  fkiCub(1,hand,x(1:3)',1,rotmat2*rotmat);
12  fkiCub(2,hand,x(4:6)',1,rotmat2*rotmat);
13  if (size(x,2)>13)
14  fkiCub(3,hand,x(7:8)',1,rotmat2*rotmat);
15  pos3link1=fkiCub(3,hand,x(7:8)',0,rotmat2*rotmat,0);
16  else
17  pos3link1=fkiCub(3,hand,[0 0]',0,rotmat2*rotmat,0);
18  end
19  ee=rotmat2*rotmat*[0 0 0 1]';
20  hold on;
21  plot3(ee(1),ee(2),ee(3),'*y','LineWidth',8.0);
22 
23  rotmat3=rotmat2*rotmat;
24 
25  scale=100;
26  quiver3(ee(1),ee(2),ee(3),rotmat3(1,1)/scale,rotmat3(2,1)/scale,rotmat3(3,1)/scale, 'r:', 'LineWidth', 2);
27  quiver3(ee(1),ee(2),ee(3),rotmat3(1,2)/scale,rotmat3(2,2)/scale,rotmat3(3,2)/scale, 'g:', 'LineWidth', 2);
28  quiver3(ee(1),ee(2),ee(3),rotmat3(1,3)/scale,rotmat3(2,3)/scale,rotmat3(3,3)/scale, 'b:', 'LineWidth', 2);
29 
30  pos1link1=fkiCub(1,hand,x(1:3)',0,rotmat2*rotmat,1);
31  pos2link1=fkiCub(2,hand,x(4:6)',0,rotmat2*rotmat,0);
32 
33  plot3([pos1link1(1) pos2link1(1)], [pos1link1(2) pos2link1(2)], [pos1link1(3) pos2link1(3)],'k');
34  plot3([pos3link1(1) pos2link1(1)], [pos3link1(2) pos2link1(2)], [pos3link1(3) pos2link1(3)],'k');
35  plot3([ee(1) pos1link1(1)], [ee(2) pos1link1(2)], [ee(3) pos1link1(3)],'k');
36  plot3([ee(1) pos3link1(1)], [ee(2) pos3link1(2)], [ee(3) pos3link1(3)],'k');
37 
38  fill3([pos1link1(1) ee(1) pos2link1(1)], [pos1link1(2) ee(2) pos2link1(2)], [pos1link1(3) ee(3) pos2link1(3)], [0 0 0]);
39  fill3([pos3link1(1) ee(1) pos2link1(1)], [pos3link1(2) ee(2) pos2link1(2)], [pos3link1(3) ee(3) pos2link1(3)], [0 0 0]);
40 
41  axis equal;
42 end