Hello,
I just started with Mathematica a week ago and tried to implement inverse kinematics of a plane robot.
Dependent of the length x1 and x2 the position (f1,f2) is described. The idea is to calculate (x1,x2) which will reach given point Xps. The vector X12l saves the initial and later on the iterating lengths of beams x1 and x2.
The trouble I have is that the loop is not working at all, and I am only getting weird therms.
Xps = {4, 3};
X12l = {3, 3};
a := 4;
i = 0;
f1[x1_, x2_] = x1 (a^2 + x1^2 - x2^2)/(2 a x1) ;
f2[x1_, x2_] = x1* Sqrt[1 - (((a^2 + x1^2 - x2^2)/(2 a x1))^2) ];
J[x1_, x2_] = ( {{D[f1[x1, x2], x1], D[f1[x1, x2], x2]},{D[f2[x1, x2], x1], D[f2[x1, x2], x2]} } ) // MatrixForm;
dx = N[Norm[Xps - {f1[X12l[[1]], X12l[[2]]], f2[X12l[[1]], X12l[[2]]]}], 5];
While[dx > 0.1,
X12l = Inverse[J[X12l[[1]], X12l[[2]]]].(Xps - {f1[X12l[[1]], X12l[[2]]], f2[X12l[[1]], X12l[[2]]]});
dx = Norm[Xps - {f1[X12l[[1]], X12l[[2]]], f2[X12l[[1]], X12l[[2]]]}];
i++;
]
i
N[{f1[X12l[[1]], X12l[[2]]], f2[X12l[[1]], X12l[[2]]]}, 3] (*Position of the TCP after dx<0.1*)
N[X12l, 3] (*the lengths needed to reach Xps*)
