Error using atan2 Inputs must be real.
古いコメントを表示
Error using atan2
Inputs must be real.
how can i fix this?
clc;
clear all;
a1 = 150; alpha1 = pi/2; d1 = 470;
a2 = 600; alpha2 = 0; d2 = 0;
a3 = 120; alpha3 = pi/2; d3 = 720;
syms c1 c2 c23 c3 c4 c5 c6 s1 c1 s2 s23 s3 s4 s5 s6 R03 R36 th1 th2 th3 th4 th5 th6 Xc Yc Zc R06 ox oz oy d6 r d D r11 r12 r13 r21 r22 r23 r31 r32 r33
c1 = cos(th1)
c2 = cos(th2)
c3 = cos(th3)
s1 = sin(th1)
s2 = sin(th2)
s3 = sin(th3)
c23 = cos(th2+th3)
s23 = sin(th2+th3)
d = a1
d6 = 50
%assume d6 = 5
R = [1 0 0 500;
0 1 0 100;
0 0 1 1500;
0 0 0 1];
r11 = R(1,1)
r12 = R(1,2)
r13 = R(1,3)
r21 = R(2,1)
r22 = R(2,2)
r23 = R(2,3)
r31 = R(3,1)
r32 = R(3,2)
r33 = R(3,3)
ox = R(1,4)
oy = R(2,4)
oz = R(3,4)
Xc = ox - d6*R(1,3)
Yc = oy - d6*R(2,3)
Zc = oz - d6*R(3,3)
D = (Xc^2+Yc^2-d^2+(Zc-d1)^2-a2^2-a3^2)/(2*a2*a3)
%inverse kinematic
th1 = atan2(Xc,Yc)
th2 = atan2(sqrt(Xc^2+Yc^2-d^2),Zc-d1)-atan2(a2+a3*c3,a3*s3)
th3 = atan2 (D,sqrt((1-d^2)))
th4 = atan2(c1*c23*r13+s1*c23*r23+s23r33,-c1*s23*r13-s1*s23*r23+c23*r33)
th5 = atan2(s1*r13-c1*r23,sqrt(1-(s1*r13-c1*r23)^2))
th6 = atan2(-s1*r11+c1*r21, s1*r12-c1*r22)
2 件のコメント
Walter Roberson
2020 年 6 月 23 日
d is 150 so sqrt(1-d^2) is not going to be real.
That appears to be the only place you are using complex numbers, so I recommend you recheck your formula.
Tony Yu
2020 年 6 月 23 日
採用された回答
その他の回答 (1 件)
Javed Ahmed
2021 年 4 月 1 日
0 投票
now way . it doesnt work.
1 件のコメント
Walter Roberson
2021 年 4 月 1 日
What code are you using that it is not working for?
カテゴリ
ヘルプ センター および File Exchange で Simulation, Tuning, and Visualization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!