Determinant of the Jacobian as a constraint couldn't avoid atan2(x,y) get into negative.

6 views (last 30 days)
I've been trying to avoid singularity using determinant as a constraint. However, some anglar values obtained using atan2 () keep giving me the follwoing error message.
"Error using atan2 Inputs must be real."
while the determinant of the Jacobian is non-zero. This is because one of the input of atan2 is complex . Could this be related to matlab ? What function should I replace it with to scape from this trap? I believe, there is no singularity as long as the Jacobian has non-zero determinant.
Thanks
  2 Comments
Matt J
Matt J on 12 Apr 2022
Edited: Matt J on 12 Apr 2022
You have given us no information about the calculations you are doing, but I can say in general that no, a non-zero determinant is not usually a good way to ensure invertibility. For example, this matrix A has a non-zero determinant, but for numerical purposes, it is non-invertible.
A=[1,1;0 1e-20]; b=rand(2,1);
A\b
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.000000e-20.
ans = 2×1
1.0e+19 * -5.1126 5.1126
Also, every singular matrix has a non-singular matrix infinitely close to it,. So, if this is part of an iterative optimization problem, a non-singularity constraint cannot prevent the iterations from getting arbitrarily close to a singular solution.
HN
HN on 12 Apr 2022
I am dealing with some physical thing and determinant of its Jacobian is zero when there is some collinearity between lines. This point is singular and should not be included in the solution set. So, minimum determinant is set to be 0.0001. Any value above this limit are in the solution set. So, I expected non-zero determinant should't give complex value in th11, th21, th12, th22, th13 and th23. So, I am a little bit confused.
The program file is somehow large to put eveything here. So, I tried my best to provide sufficient information to you.
function result = workspace(point,point2,min_det)
Jacobian = jaco(point, point2); % is analytic 6 x 6 Jacobian matrix representing robot configuration.
result1 = isreal(Jacobian);
deter = abs(det(Jacobian)); % at some point it becomes negative and can't use it for comparison. So, abs(det) is used
if result1 == 1 && deter > min_det % if the current determinant is greater than minimum threshold, search in one direction. if not chnage the search direction.
result = 1;
else
result = 0;
end
end
Equations inside the jaco () are given below
c1x=(g1(1)^2+g1(3)^2+L_11^2-L_21^2)/(2*L_11);
c1z=sqrt(g1(1)^2+g1(3)^2-c1x^2);
scth1=inv([c1x, -c1z ;c1z, c1x])*[g1(1);g1(3)];
cos_th1=scth1(1); sin_th1_1=scth1(2);
th11=atan(sin_th1_1/cos_th1); % at some configuration gets into complex because of c1z
cth21 = (c1x-L_11)/L_21; sth21_1 = c1z/L_21;
th21=atan(sth21_1/cth21); % at some configuration gets into complex because of c1z
c2x=(g2(1)^2+g2(3)^2+L_12^2-L_22^2)/(2*L_12);
c2z=sqrt(g2(1)^2+g2(3)^2-c2x^2);
scth2=inv([c2x, -c2z ;c2z, c2x])*[g2(1);g2(3)];
cos_th2=scth2(1); sin_th2=scth2(2);
th12=atan(sin_th2/cos_th2); % at some configuration gets into complex because of c2z
cth22 = (c2x-L_12)/L_22; sth22 = c2z/L_22;
th22=atan(sth22/cth22); % at some configuration gets into complex because of c2z
c3x=(g3(1)^2+g3(3)^2+L_13^2-L_23^2)/(2*L_13);
c3z=sqrt(g3(1)^2+g3(3)^2-c3x^2);
scth3=pinv([c3x, -c3z ;c3z, c3x])*[g3(1);g3(3)];
cos_th3=scth3(1); sin_th3=scth3(2);
th13=atan2(sin_th3,cos_th3); % at some configuration gets into complex because of c3z
cth23 = (c3x-L_13)/L_23; sth23 = c3z/L_23;
th23=atan(sth23/cth23); % at some configuration gets into complex because of c1z

Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 13 Apr 2022
While I do not know what you are really doing, you should know that nonlinear constraints are not satisfied at intermediate iterations. See Iterations Can Violate Constraints. That means your attempt to satisfy nonsingularity by including a nonlinear constraint is doomed to failure.
Instead, you should modify your objective function to be robust to infeasible points. Have the objective return NaN at these points, instead of getting into a situation where MATLAB throws an error.
Alan Weiss
MATLAB mathematical toolbox documentation
  5 Comments
HN
HN on 15 Apr 2022
@Walter Roberson, I got the following error
Error using svd
Input to SVD must not contain NaN or Inf.
Error in InvJac_RRS_RRRU (line 211)
Ga = pinv(wqa)*[wa1;wa2;wa3];
HN
HN on 8 Jun 2022
Edited: HN on 8 Jun 2022
Thank you and sorry for not replying early to this conversation. Problem is solved using global variable.
In the case of
syms c1z
imag(c1z)~=0
ans = 
the previous value is used to calculate the rest of the variables and proceed.
Thanks

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!