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

7 views (last 30 days)
HN on 12 Apr 2022
Edited: HN on 8 Jun 2022
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.
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;
result = 0;
Equations inside the jaco () are given below
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
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
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
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
ans = 
the previous value is used to calculate the rest of the variables and proceed.

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!

Translated by