TN2 ProgrammingRobotMATLAB 26.05.2020 English
TN2 ProgrammingRobotMATLAB 26.05.2020 English
1. INTRODUCTION
In this Laboratory, students need to program and simulate the position kinematics of a 2DOF
robot using Simscape Multibody Link tool in MATLAB. Kinematics includes the problems
relative to position, velocity, and acceleration. In this Lab., we just consider the position kinematics
which divide into 2 problems: the forward kinematics and the inverse kinematics. In the position
forward kinematics problem, we know the value of each joint of the robot and we need to
determine the position of the end-effector of the robot. In case of the position inverse kinematics,
we know the position of the end-effector of the robot and we need to look for the value of joints
of robot to satisfy this position. Solving the inverse kinematics, we can control the robot to follow
a desired path.
Goal:
Ability to solve the position forward kinematics and the position inverse kinematics.
Ability to program and simulate the robot to track a desired path (line, square, circle).
Ability to show tracking trajectory on the monitor of Laptop.
2. BASIC KNOWLEDGE
2.1 Position Kinematics of a 2DOF robot
In this section, we solve the position forward kinematics and the position inverse kinematics
of the 2DOF robot.
2.1.1 Position forward kinematics
Equations of the forward kinematic of a 2DOF robot are:
X l1 cos 1 l2 cos 1 2
Y l1 sin 1 l2 sin 1 2
Where: X , Y are positions of the end-effector of the robot, l1 , l2 are dimension of the links, 1 , 2
are value of joints of the robot.
l1 l2 X 2 Y 2
2
2 2a tan
X 2
Y 2 l1 l2
2
l1 l2 X 2 Y 2
2
2 2a tan
X 2
Y 2 l1 l2
2
Depending on the position of the path that we want the robot to track, we should choose the
suitable configuration. The axis in these solutions may be different from the axis in the
simulating file because of choosing the direction of Z-axis. Thus, maybe we need to change the
configuration or the sign of the angle to get the right result.
2.2.2 Create the values at each joint of the robot for the desired trajectory
Next, we need to give the value for “input” variable. In Command Windows of MATLAB,
we create a matrix including 3 columns: column 1 is time, column 2 is 1 , column 3 is 2 .
Example of the code to make the line trajectory along X-axis:
-----
l1 = 0.3;
l2 = 0.2;
X = 0.5;
Y = 0;
g1 = 0;
g2 = 0;
m1 = ((l1+l2)^2-(X^2+Y^2))/((X^2+Y^2)-(l1-l2)^2);
g2 = 2*atan(sqrt(m1));
g1 = atan2(Y,X) + atan2(l2*sin(g2),l1+l2*cos(g2));
T = 0;
G1 = g1;
G2 = g2;
for i=1:300
X = 0.5 - 0.001*i;
Y = 0;
m1 = ((l1+l2)^2-(X^2+Y^2))/((X^2+Y^2)-(l1-l2)^2);
g2 = 2*atan(sqrt(m1));
3. EXPERIMENTAL CONTENT
3.1 Time: 5 hours for each group of students.
3.2 Content
Students do the following exercises:
1) Exercise 1: Program and control robot to track a line path?
Guide: Do the same example code in the section 2.2.2. Please consider the direction of the Z-axis
of joint 1 and joint 2. You should choose the line along X-axis or Y-axis.
Equation of a line in XOY plane:
x x1 x2 x1 t
y y1 y2 y1 t
Exercise 2:
Exercise 3:
Exercise 4:
References
[1] Website MATLAB
Date:……………………….