Kinematics analysis of 2-DOF robot
1. Introduction
Kinematics is the science of motion that treats the subject without regard to the forces that
cause it. Hence, the study of the kinematics of manipulators refers to all the geometrical and time-
based properties of the motion. Forward kinematics is the static geometrical problem of computing
the position and orientation of the end-effector of the manipulator. On the other hand, given the
position and orientation of the end-effector of the manipulator, calculate all possible sets of joint
angles that could be used to attain this given position and orientation. This is a fundamental
problem in the practical use of manipulators.
Objectives:
Import joint data (with respect to time) to the joint actuators in the Simulink of 2-DOF
robot model.
Compare positions of the end-effector obtained from kinematic equations and from the
Simmechanics Link model.
Simulate motion of the end-effector in linear paths and circular paths.
2. Equipment
2.1 Devices and cad model
- Programs installed in the computer:
Solidworks, e.g. 2014 version
Matlab, e.g. R2015a version
SimMechanics Link.
- 2-DOF robot modelled in 3D cad, e.g. Solidworks in which l1 = 100 mm and l2 = 50 mm
Z
X
1
2.2 Preparation
a) Installation
Soliworks
Matlab
Simmechanics Link
At the MATLAB command prompt, enter install_addon('zipname')
At the command prompt, enter regmatlabserver.
b) From Solidworks to Simulink
Note that the universal frame should be assigned properly and the initial posture of the model
should be chosen as above so that the cad model appears appropriately in the Matlab as shown in
the kinematic diagram below
q2
l2
l1
q1
The kinematics equation for this RR mechanism is given as follows:
0
𝑥𝐷 = 𝑙1 𝑐𝑜𝑠𝜃1 + 𝑙2 𝑐𝑜𝑠(𝜃1 + 𝜃2 )
{ 0
𝑦𝐷 = 𝑙1 𝑠𝑖𝑛𝜃1 + 𝑙2 𝑠𝑖𝑛(𝜃1 + 𝜃2 )
Where
l1 = 100 (mm): link length of the first link.
l2 = 50 (mm): link length of the second link.
c) Useful block from Simulink.
Actuates a Joint primitive with generalized force/torque or linear/angular position,
velocity, and acceleration motion signals.
Measures the motion of the Body coordinate system to which the Sensor is connected.
Sensor measures any combination of translational position, velocity, and acceleration;
and rotational orientation, angular velocity, and angular acceleration.
2
Display signals generated during simulation
Plots second input (Y) against first input (X) at each time step to create an X-Y plot.
Read data values specified in time series, matrix, or structure format from the MATLAB
workspace, model workspace, or mask workspace.
3. Experimental contents
3.1 Time duration: 4-5 periods for each group of 4 students.
3.2 Requirements
a) Implement a forward kinematic problem when the joint angles are changed in a pattern as
given below. Determine the coordinates of the end effector by comparing computational
results from the kinematic equations and simulation results measured from Simulink.
900
q2
450
q1
10
b) Implement an inverse kinematic problem when the end-effector is planned to move
constantly in a straight line from A (150, 0, 0) to B (100, 50, 0) during 10 seconds.
c) Implement an inverse kinematic problem when the end-effector is planned to move
constantly on a circle, centered at (100, 0, 0) with a radius of 25 mm, during 10 seconds.
3
d) Implement an inverse kinematic problem when the end-effector is planned to move along
a curve of a heart shape in the workspace.
Results from these four problems need to be reported in Part 4.
3.3 Guidelines of solving problem
3.3.1. Recall the basic tasks implemented in the Simulink model
After merging the 3D cad model from Solidworks to Simulinks through Simmechanics Link, some
steps need to be done:
Attach ‘Joint Actuator’ to mechanism joints with inputs of motion signals.
Apply a variety of inputs to the actuators: const signal, ramp signal, sinusoidal signal.
Know how to generate and attach a body frame at the point (of the end effector) to be
measured.
Use ‘Body Sensor’ to measure the coordinates of the end effector and display data on
‘Display’, ‘Scope’, and ‘XY Graph’.
3.3.2. Implement a forward kinematic problem
Do followings:
- Add two blocks ‘From Workspace’ to the inputs of rotational orientation.
- Change variables simin in the block parameter into variables tt1 and tt2 for the joint,
respectively. In addition, change ‘Extrapolation’ to ‘Holding final value’ at the form output in
the parameter.
- Create time variable t in the Matlab workspace during 10 seconds with an increment of 0.01.
>> t = 0 : 0.01 : 10
4
- Create data for the first joint angles.
>> theta1 = linspace(0, 45, 1001)
>> theta2 = linspace(0, 90, 1001)
- Form the data values for tt1 and tt2 used in the Simulink.
>> tt1 = [t’ theta1’]
>> tt2 = [t’ theta2’]
- Set the Simulation stop time ( 10), click run, and observe the motion.
- Determine the coordinates of the end effector by comparing computational results from the
kinematic equations and simulation results measured from Simulink. They should be the same
as follows:
5
3.3.3. Implement the linear inverse kinematic problem
Do followings:
- Implement an m file, creating data in task space with respect to time
function [pos] = kinematics_linear_path(x, y, duration)
clc
l1 = 100;
l2 = 50;
t = 0:0.01:duration;
delta_x = (x(2) - x(1)) / (length(t)-1);
delta_y = (y(2) - y(1)) / (length(t)-1);
for i=1:length(t)
x(i) = (i-1)*delta_x + x(1);
y(i) = (i-1)*delta_y + y(1);
end
pos = [t' x' y'];
- Plot the results in task space to verify the data
- Implement an m file to find the inverse kinematic solutions. As there are two solutions in the
inverse kinematic problem. One of them should be chosen, e.g. the second joint angle is
selected to be negative as in the diagram.
q2
l2
l1 a
b
q1 g
- From the diagram above, applying the "law of cosines“ for the triangle in plane geometry,
values of joint angles can be determined by following steps in an m file
6
function [theta] = inv_kinematics(t, x, y)
clc
l1 = 100;
l2 = 50;
for i=1:length(t)
alpha = …………………………………………… // calculate 𝛼
theta_2(i) = …………………………………….… // result in 𝜃2
beta = …………………………………………… // calculate 𝛽
gamma = ………………..……………………… // calculate 𝛾
theta_1(i) = beta + gamma ……………………… // result in 𝜃1
end
theta(:,1) = t';
theta(:,2) = theta_1';
theta(:,3) = theta_2';
- Plot the results in joint space to verify the computational data
q1
q2
- If they are correct, then click run in the Simulink, and observe the motion.
7
3.3.4. Implement the circular inverse kinematic problem
Do followings:
- Implement an m file, creating data in task space with respect to time.
function [pos] = kinematics_circle_path(center, radius, start, duration)
clc
l1 = 100;
l2 = 50;
y = 0;
t = 0:0.01:duration;
angle = linspace(0,360, length(t));
for i=1:length(t)
x(i) = radius*cosd(angle(i) + start) + center(1);
y(i) = radius*sind(angle(i) + start) + center(2);
end
pos = [t' x' y'];
- Plot the results in task space to verify the data
- Calculate values of joint angles in the function ‘inv_kinematics(t, x, y)’ implemented above,
then plot the results in task space to verify the data
q1
q2
8
- If they are correct, form the data values for tt1 and tt2 used in the Simulink. Then, click run in
the Simulink, and observe the motion.
3.3.5. Implement the inverse kinematic problem when the end-effector is planned to move along
a curve of a heart shape in the workspace
Do followings:
- By combining two functions ‘kinematics_linear_path(x, y, duration)’ and
‘kinematics_circle_path(center, radius, start, duration)’, a data of the heart shape in task space
with respect to time can be determined. The boundary of heart shape should be choose within
the workspace. Note that the heart shape is composed of four segments: two half-circles and
two lines. Therefore coordinate data from these segments need to be arranged continuously.
- Calculate values of joint angles in the function ‘inv_kinematics(t, x, y)’ from the coordinate
data. Then click run in the Simulink, and observe the motion.
- The data of the heart shape can also be derived from the figure below.
9
4. Experimental results
4.1 Compare computational results from the kinematic equations and simulation results measured
from Simulink in Section 3.3.2.
The same Different
Give comments if they are different: ……......................................................................................
.........................................................................................................................................................
4.2 Complete codes in solving the inverse kinematic problem.
......................................................................................................................................................... ..
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
.........................................................................................................................................................
Implement linear inverse kinematic problem in Section 3.3.3
Complete Incomplete
Implement circular inverse kinematic problem in Section 3.3.4
Complete Incomplete
Implement the inverse kinematic problem to draw the heart shape in Section 3.3.5
Complete Incomplete
Instructor’s name:
Date: Room: Time of report:
Student’s names: Student’s IDs:
………………………………………………………… …………………..
………………………………………………………… …………………..
………………………………………………………… …………………..
………………………………………………………… …………………..
10
References:
[1] Install and Register SimMechanics Link Software: http://www.mathworks.com/help/
physmod/smlink/ug/installing-and-linking-simmechanics-link-software.html.
[2] Getting Started with Simscape Multibody Link:
https://www.mathworks.com/help/physmod/smlink/getting-started-with-simmechanics-link.html.
Appendices: this lab procedures could be similarly applied to followings:
Example 1: Hexapod simulation
Example 2: Tripod system for 3D movies / games
11