Warning: Imaginary part is currently ignored.

1 回表示 (過去 30 日間)
Nikolaos
Nikolaos 2011 年 11 月 9 日
Hello !
I am currently making a small program about the movement of a robotic finger (kinematics). This one is for the inverse kinematics
function [T]=anti_kinimatiko(x,y,f)
global l1 l2 l3
f=f*pi/180;
sigma=(x^2+y^2-l3^2-2*l3*(x*cos(f)+y*sin(f)))/2/l1/l2;
q2=atan2(+sqrt(1-sigma^2),sigma);
num1=(y-l3*sin(f))*(l1+l2*cos(q2))-(x-l3*cos(f))*l2*sin(q2);
den=(l1^2+l2^2+2*l1*l2*cos(q2));
num2=(x-l3*cos(f))*(l1+l2*cos(q2))+(y-l3*sin(f))*l2*sin(q2);
q1=atan2(num1/den,num2/den);
q3=f-q1-q2;
%ta kanw apo aktinia se moires
q1=q1*180/pi;
q2=q2*180/pi;
q3=q3*180/pi;
T=[q1 q2 q3]';
kinimatiko(q1,q2,q3)
axis equal
end
where kinimatiko(q1,q2,q3) is another program for the forward kinematics.
When i run the program the problem i take is this ,
Warning: Imaginary part is currently ignored.
Future behavior of ATAN2 with complex inputs may change.
> In anti_kinimatiko at 10"
What does that mean exactly ,what do i have to change to make it work ?

採用された回答

Jonathan
Jonathan 2011 年 11 月 9 日
This warning means that one of the inputs to atan2 is imaginary. The two places you use atan2 are extracted below.
q2=atan2(+sqrt(1-sigma^2),sigma);
q1=atan2(num1/den,num2/den);
So, one or more of the arguments to atan2 (namely: +sqrt(1-sigma^2), sigma, num1/den, and num2/den) are imaginary or complex. The most likely candidate is +sqrt(1-sigma^2), since this will be imaginary whenever sigma is greater than 1. Make sure your sigma is properly bounded and try again.
~Jonathan
  1 件のコメント
Nikolaos
Nikolaos 2011 年 11 月 9 日
Thanks a lot for your answer Jonathan ! I am gonna check this out as soon as i get home ! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by