grasp
All Data Structures Namespaces Functions Modules
fkiCub.m
1 function [x,o,z]=fkiCub(finger, hand, q1, draw, rotmat, varargin)
2 
3  dim=max(size(q1,1),size(q1,2));
4  q=reshape(q1,dim,1);
5  if finger==1
6  if (hand=='r')
7  H0=[0.478469 0.063689 -0.875792 -0.024029759;
8  -0.878095 0.039246 -0.476873 -0.01193433;
9  0.004 0.997198 0.074703 -0.00168926;
10  0.0 0.0 0.0 1.0];
11  else
12  H0=[0.478469 0.063689 0.875792 -0.024029759;
13  -0.878095 0.039246 0.476873 -0.01193433;
14  0.004 -0.997198 0.074703 0.00168926;
15  0.0 0.0 0.0 1.0];
16  end
17  color='b';
18  active_joints=[1 0 1 1 1 1];
19  l=size(q,1);
20  qnew=zeros(l+1,1);
21  qnew(1)=q(1);
22  qnew(2)=0;
23  for i=3:size(q)+1
24  qnew(i)=q(i-1);
25  end
26  q=qnew;
27  elseif finger==2
28  if (hand=='r')
29  H0=[0.898138 0.439714 0.0 0.00245549;
30  -0.43804 0.89472 0.087156 -0.025320433;
31  0.038324 -0.078278 0.996195 -0.010973325;
32  0.0 0.0 0.0 1.0];
33  else
34  H0=[0.898138 0.439714 0.0 0.00245549;
35  -0.43804 0.89472 -0.087156 -0.025320433;
36  -0.038324 0.078278 0.996195 0.010973325;
37  0.0 0.0 0.0 1.0];
38  end
39  color='r';
40  active_joints=[1 1 1 1 1];
41  q(1)=q(1)/3;
42  elseif finger==3
43  if (hand=='r')
44  H0=[1.0 0.0 0.0 0.0178;
45  0.0 0.0 -1.0 -0.00830233;
46  0.0 1.0 0.0 -0.0118;
47  0.0 0.0 0.0 1.0];
48  else
49  H0=[1.0 0.0 0.0 0.0178;
50  0.0 0.0 1.0 -0.00830233;
51  0.0 -1.0 0.0 0.0118;
52  0.0 0.0 0.0 1.0];
53  end
54  color='g';
55  active_joints=[1 1 1 1];
56  end
57 
58  l=size(q,1);
59  q(l)=q(l)/2;
60  q(l+1)=q(l);
61 
62  if (size(varargin,2)==0)
63  link=size(q,1);
64  else
65  link=varargin{1};
66  end
67 
68  DH=DHiCub(finger,hand);
69 
70  Hroot=rotmat*FKinStd(DH,q,link,H0);
71 
72  x=Hroot(1:3,4);
73  o=dcm2axis(Hroot);
74 
75  if (draw==1)
76  hold on;
77  view(3);
78  grid;
79  camproj orthographic
80  rotate3d on
81 
82  [Tr,z]=iCubPlot(DH,q,color,rotmat,H0,active_joints);
83  %iCubPlotCAD(DH,q,color,finger,rotmat,H0,active_joints);
84  end
85 
86 end