0% found this document useful (0 votes)
20 views

TN2 ProgrammingRobotMATLAB 26.05.2020 English

Uploaded by

Duy Thoại Lê
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

TN2 ProgrammingRobotMATLAB 26.05.2020 English

Uploaded by

Duy Thoại Lê
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

FL061

Mechanical Engineering Faculty Programming and Simulating the Position


Department of Mechatronics
Kinematics of a 2DOF Robot for Tracking
Desired Paths

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.

Students need to prepare the following tasks before coming to class:


- Take simulating files in MATLAB of Lab. 1 “Design and Simulate Robot Motion using
Simscape Multibody Link”, all files in MATLAB.
- Reading textbook about the inverse kinematics (Theory of Applied Robotics: Kinematics,
Dynamics, and Control, chapter 6, example 184 of a 2DOF robot).
- Know how to use basic commands in MATLAB: if, else, for, …

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.

Faculty of Mechanical Engineering @HCMUT 1


FL061
2.1.2 Position inverse kinematics
Figure 1 show the solution of the inverse kinematic of the 2DOF robot.

a) Elbow up b) Elbow down


Figure 1: Solution of the Inverse Kinematics of the 2DOF robot
Elbow up configuration has following solutions:

 l1  l2   X 2 Y 2 
2

 2  2a tan
X 2
 Y 2    l1  l2 
2

1  a tan 2 Y , X   a tan 2  l2 sin  2 , l1  l2 cos 2 


Elbow down configuration has following solutions:

 l1  l2   X 2 Y 2 
2

 2  2a tan
X 2
 Y 2    l1  l2 
2

1  a tan 2 Y , X   a tan 2  l2 sin  2 , l1  l2 cos  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 Programming to Tracking Desired Paths


To control the end-effector of the robot to track a desired path, we need to do following steps:
- Step 1: Divide the desired path into many small parts (usually equal paths), we need to
know the value of intermediate points.
- Step 2: Solving position inverse kinematic at these intermediate points.
- Step 3: Program robot to move according to the value of joints in the step 2.

2.2.1 Insert “From Workspace” Block


To give the information about the value of the joints of the robot with the time, we need to
insert block “From Workspace” (in Simulink-1) into the simulated file.
Faculty of Mechanical Engineering @HCMUT 2
FL061

Figure 2: “From Workspace” Block in simulated file

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));

Faculty of Mechanical Engineering @HCMUT 3


FL061
g1 = atan2(Y,X) + atan2(l2*sin(g2),l1+l2*cos(g2));
t = 0.01*i;
T = [T t];
G1 = [G1 g1];
G2 = [G2 g2];
end
input = [T' G1' G2']
-----

Figure 3: Give the name “input” for the input data

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

Where:  x1 , y1  is the start position,  x2 , y2  is the end position, t change from 0 to 1.

Faculty of Mechanical Engineering @HCMUT 4


FL061
2) Exercise 2: Program and control robot to track a triangle path?
Guide: You should choose the trajectory that is in the same configuration (elbow up or elbow
down).

3) Exercise 3: Program and control robot to track a square path?


Guide: You should choose the trajectory that is in the same configuration (elbow up or elbow
down). You should consider the workspace of the robot, there is some point that the robot cannot
reach.

4) Exercise 4: Program and control robot to track a circular path?


Guide: The equation of a circular path in the XOY plane can be:
x  x0  R cos t
y  y0  R sin t
Where:  x0 , y0  is the center of the circle, R is the radius of the circle, t change from 00 to 3600.

Faculty of Mechanical Engineering @HCMUT 5


FL061
4. Experimental Results (Note: Students should submit this paper to the Teacher after class)
Exercise 1:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Exercise 2:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Exercise 3:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

Exercise 4:

Not work □ Not work perfectly □ Work perfectly □


Another Idea:

References
[1] Website MATLAB

Name of Student:……….………….……..………Student ID:……...….………….Group:………


Name of Student:……….………….……..………Student ID:……...….………….Group:………
Name of Student:……….………….……..………Student ID:……...….………….Group:………
Name of Student:……….………….……..………Student ID:……...….………….Group:………
Name of Student:……….………….……..………Student ID:……...….………….Group:………

Date:……………………….

Faculty of Mechanical Engineering @HCMUT 6

You might also like