-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptimal_move_iiwa.m
58 lines (39 loc) · 1.01 KB
/
optimal_move_iiwa.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function [ q_final ] = optimal_move_iiwa( q0, goal_T)
%optimal_move_iiwa calc optima delta q for inv_kin_iiwa
% Calculated delta q by SNS algorithm with diffrent qN(speed in null
% space
del_Q=0;
del_Q_min(1)=2*pi*7;
q_final(1:7)=0;
for q3=-0.2:0.05:0.2
qN=[0 0 q3 0 0 0 0];
Tq=forward_kin_iiwa(q0);
eps=calc_error(Tq,goal_T);
diff=sum(sqrt(eps.^2));
diff_old=diff;
c=1;
q=q0;
while diff>10^-2
Jac = jac_iiwa(q);
Jinv = Jac'*inv(Jac*Jac');
qt=inv_kin_iiwa_del_qSNS(q,eps,qN);
q=q+0.01*qt';
% error
Tq=forward_kin_iiwa(q);
eps=calc_error(Tq,goal_T);
diff=sum(sqrt(eps.^2));
if diff>diff_old
disp(['limit exceeded',' diff=',num2str(diff)]);
disp(q3);
break;
end
diff_old=diff;
c=c+1;
end
del_Q=sum(sqrt((q0-q).^2));
if del_Q<del_Q_min(1); del_Q_min(1)=del_Q; del_Q_min(2)=q3; q_final=q; end;
disp(q3);
disp(num2str(q));
end
disp(['optimal:',num2str(del_Q_min(2))]);
end