# Thread: robotics and simple ik

1. ## robotics and simple ik

Question: how do we solve SYSTEM 2 (see bellow) to prove SYSTEM 3?
-----------------------------------------------------------
hello,
im having a little trouble with robotics, inverse kinematics and its equations
if you do have heard of robotics IK, then this should be fairly easy
its the simplest occasion (
planar 2-link/2-dof/2r manipulator) from the introduction to kinematics (robotics)
-----------------------------------------------------------
[L1, L2] = length of each link, [1, 2] = angles, [cos12] = cos(1 + 2), [sin12] = sin(1+2)
-----------------------------------------------------------
SYSTEM 1 (forward kinematics equations)
-----------------------------------------------------------
px = L1cos1 + L2cos12

py = L1sin1 + L2sin12
-----------------------------------------------------------
SYSTEM 2 (rearrangement of system 1)
-----------------------------------------------------------
px = (L1 + L2cos2)cos1 + (-L2sin2)sin1

py = (L2sin2)cos1 + (L1 + L2cos2)sin1
-----------------------------------------------------------
SYSTEM 3 (system 2 solved for sin1, cos1)
-----------------------------------------------------------
sin1 = px (-L2sin2) + py (L1 + L2cos2)

cos1 = px (L1 + L2cos2) + py (L2sin2)
-----------------------------------------------------------

Question: How do we get from SYSTEM 2 to SYSTEM 3?

of course i dont expect an analytical answer, i wont bother you that much
i just hope for some internet directions since i dont know the correct english terms to run a proper search

the problem is that i have found different answers/ solutions for sin1, cos1 in different books but not one has the proof
-----------------------------------------------------------
thank you

2. Originally Posted by sklnner
Question: how do we solve SYSTEM 2 (see bellow) to prove SYSTEM 3?
-----------------------------------------------------------
hello,
im having a little trouble with robotics, inverse kinematics and its equations
if you do have heard of robotics IK, then this should be fairly easy
its the simplest occasion (
planar 2-link/2-dof/2r manipulator) from the introduction to kinematics (robotics)
-----------------------------------------------------------
[L1, L2] = length of each link, [1, 2] = angles, [cos12] = cos(1 + 2), [sin12] = sin(1+2)
-----------------------------------------------------------
SYSTEM 1 (forward kinematics equations)
-----------------------------------------------------------
px = L1cos1 + L2cos12

py = L1sin1 + L2sin12
-----------------------------------------------------------
SYSTEM 2 (rearrangement of system 1)
-----------------------------------------------------------
px = (L1 + L2cos2)cos1 + (-L2sin2)sin1

py = (L2sin2)cos1 + (L1 + L2cos2)sin1
-----------------------------------------------------------
SYSTEM 3 (system 2 solved for sin1, cos1)
-----------------------------------------------------------
sin1 = px (-L2sin2) + py (L1 + L2cos2)

cos1 = px (L1 + L2cos2) + py (L2sin2)
-----------------------------------------------------------

Question: How do we get from SYSTEM 2 to SYSTEM 3?

of course i dont expect an analytical answer, i wont bother you that much
i just hope for some internet directions since i dont know the correct english terms to run a proper search

the problem is that i have found different answers/ solutions for sin1, cos1 in different books but not one has the proof
-----------------------------------------------------------
thank you
Do you know how to solve two linear equations in two unknowns, say by elimination or substitution or using matrices? If not, try this Google search on

solving 2 linear equations in 2 unknowns elimination.

System 2 is equations of this form

$\begin{matrix} p_x = a x + by \\ p_y = cx + dy \end{matrix}
$

where $x = \cos 1,\ y = \sin 1,\ a = L_1 + L_2 \cos 2,$ etc.

In matrix form

$\begin{bmatrix} p_x \\ p_y \end{bmatrix} =
\begin{bmatrix} a & b \\ c & d \end{bmatrix}
\begin{bmatrix} x \\ y \end{bmatrix}.
$

The solution is

$\begin{bmatrix} x \\ y \end{bmatrix} =
{\begin{bmatrix} a & b \\ c & d \end{bmatrix}}^{-1}
\begin{bmatrix} p_x \\ p_y \end{bmatrix}
=\begin{bmatrix} d & -b \\ -c & a \end{bmatrix}
\begin{bmatrix} p_x \\ p_y \end{bmatrix}
= \begin{bmatrix} d p_x - b p_y \\ -c p_x + a p_y \end{bmatrix}.
$

Back to non-matrix form, System 3 is

$\begin{array}{l}x = d p_x - b p_y \\ y = -c p_x + a p_y \end{array}$.

But note the order of the equations is reversed as you have written it:

$\begin{array}{l}y = -c p_x + a p_y \\ x = d p_x - b p_y \end{array}$.

3. A - thnx a lot
-----------------------------------
B - i tried it with matrices
but isnt the inverse matrix of this:
---
a b
c d
---
this?:
---

d -c
-b a
---
that was my problem, i dont see how (ad-bc) could be 1 in order for the inverse matrix to be without [1/(ad-bc)]
but i must be saying something wrong here(?)
-----------------------------------
C
if you visit here (its not spam, just another site):

Protein Inverse Kinematics and the Loop Closure Problem

press ctrl+f (browser search) and enter this phrase: "click for solution"
you can see that the solution for sin1 / sin(θ1) (last line of the solution text) is the same but with a denominator which is equal to this:
px^2 + py^2
which is different than 1, which means one of the two solutions is wrong(?)
-----------------------------------
D
i cant ask for anything more from you JakeD after the long answer you bothered to write, so i ll practise it some more to find where my silly mistakes are, and i ll get back
-----------------------------------
E
can i too generate these images? i tried but couldnt get it to work - is there any guide in the forum for this?
must i change the script lang somehow?
-----------------------------------
again thnx
edit: its late here, so if anyone replies know that i ll probably check in again tomorrow

4. Originally Posted by sklnner
A - thnx a lot
-----------------------------------
B - i tried it with matrices
but isnt the inverse matrix of this:
---
a b
c d
---
this?:
---

d -c
-b a
---
that was my problem, i dont see how (ad-bc) could be 1 in order for the inverse matrix to be without [1/(ad-bc)]
but i must be saying something wrong here(?)
-----------------------------------
C
if you visit here (its not spam, just another site):

Protein Inverse Kinematics and the Loop Closure Problem

press ctrl+f (browser search) and enter this phrase: "click for solution"
you can see that the solution for sin1 / sin(θ1) (last line of the solution text) is the same but with a denominator which is equal to this:
px^2 + py^2
which is different than 1, which means one of the two solutions is wrong(?)
-----------------------------------
D
i cant ask for anything more from you JakeD after the long answer you bothered to write, so i ll practise it some more to find where my silly mistakes are, and i ll get back
-----------------------------------
E
can i too generate these images? i tried but couldnt get it to work - is there any guide in the forum for this?
must i change the script lang somehow?
-----------------------------------
again thnx
edit: its late here, so if anyone replies know that i ll probably check in again tomorrow
You are right about the missing factor $1/(ad-bc)$ in the inverse. I was looking at System 3 and trying to justify it.

Now

$ad-bc = (L_1 + L_2 \cos \theta_2)^2 + (L_2 \sin \theta_2)^2 = L_1^2 + 2 L_1 L_2 \cos \theta_2 + L_2^2$

using $\sin^2 \theta_2 + \cos^2 \theta_2 = 1.$

Looking at

in the page you provided, I think I see why $ad-bc$ might equal 1. Let $X_1, X_2$ be the coordinate vectors for the links. Then from the picture, the angle between these vectors is angle $\theta_2.$ So

$\cos \theta_2 = X_1^T X_2/L_1 L_2$

where $L_i = || X_i || = \sqrt{ X_i^T X_i}$ and thus

$L_1^2 + 2 L_1 L_2 \cos \theta_2 + L_2^2 = X_1^T X_1 + 2 X_1^T X_2 + X_2^T X_2 = (X_1 + X_2)^T (X_1 + X_2) = || X_1 + X_2 ||^2.$

But the vector $X_1 + X_2 = (x,y)$ in the picture. If this vector is assumed to have length $|| X_1 + X_2 || = 1,$ then $ad - bc = 1.$

Apparently $(x,y) = (p_x,p_y)$ in your equations, so that $ad -bc = ||p||^2 = p_x^2 + p_y^2$, which explains why this would be in the denominator if $(p_x,p_y)$ is not assumed to have length 1.

For the mathematical script, see the http://www.mathhelpforum.com/math-he...-tutorial.html.

5. sorry for abandoning my own topic, yesterday was really busy
i didnt have the chance to read the tutorial yet but i will
---
as for the problem, we agree
the 2 solutions are the actually the same if in the first one the quantity "px^2 + py^2" (or the hypotenuse/length from (0,0) to x,y) is assumed to be 1
---
one problem is im pretty sure its not 1 and now i have found enough sources to say that the denominator should be there expressed in either of the two forms: ~(px, py) or ~(L1, L2)

i ll be examined on this book soon and every solved problem in it solves the 2x2 systems as if 1/(ad-bc) was 1 and im talking about totally different manipulators

so i dont know what to do, most sources in the internet use another, 3rd way splitting the angle θ1 and solving for two more angles but i cant understand this yet because i dont know anything about producing the atan2 function which is needed
---
anyway thanx a lot JakeD, i ll keep trying to figure this out