n-link planar serial chain robots

Three link plainer serial chain linkage

From the figure above we can write the coordinates of each of the joints as

\begin{equation} \vec{x}^T=\vec{l} F(\vec\theta) \label{fig:fk1} \end{equation}

where

\[ \vec{l}= \begin{bmatrix} l_{1} & l_{2} & l_{3} \end{bmatrix} \]

is a vector of linklengths such that

and

\[ F(\vec\theta)= \begin{bmatrix} c_{1} & s_1 \\ c_{12} & s_{12}\\ c_{123} &s_{123} \end{bmatrix} \]

where $c_{1} =\cos\theta_{1}$, $s_1 = \sin\theta_{1}$, $c_{12} = \cos\left(\theta _{1}+\theta _{2}\right)$, $s_{12} = \sin\left(\theta _{1}+\theta _{2}\right)$ $c_{123} = \cos\left(\theta _{1}+\theta _{2}+\theta _{3}\right)$, etc

You can cross check with the above figure by using following Matlab code

>> syms theta1 theta2 theta3 l1 l2 l3 real
>> theta=[theta1; theta2; theta3]
>> l=[l1 l2 l3]
>> F=[cos(cumsum(theta)) sin(cumsum(theta))]
>> x=l*F

It is also possible to use an anonymous function in Matlab to compute the position of the end of the last link

The forward kinematics of any number of links can be done with the anonymous function

>> fk=@(len,theta) len*[cosd(cumsum(theta)) sind(cumsum(theta))];

Where $len$ is a vector of link lengths and $theta$ is a vector of angles.

the length of the vectors len and theta must be the same (and theta must be in degrees) but this function will work for any number of links in an open (serial) chain.