20PWMCT0732 Lab#4

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

1|Page

DEPARTMENT OF MECHATRONICS ENGINEERING


UNIVERSITY OF ENGINEERING & TECHNOLOGY, PESHAWAR
Robotics MtE-405L, 7th Semester

Student Name: Imad Ahmad


Reg No: 20PWMCT0732
Instructor Name: Dr. Riaz Akbar Shah
Submission Date: October 26, 2023

Lab No 4:

Lab Rubrics:
BelowBasic (1)
Criteria Excellent (4) Proficient (3) Basic (2) Student’s
Score
Report is mostly
Report is
Report is as per as per the Sections/Steps
disorganized
To organize the the guidelines. are not ordered
guidelines and and follows
lab report and All and Report is
most some
practice sections/steps not as per the
sections/steps guidelines
th e writing skills are clearly guidelines
but most of
as per the organized in a are ordered well
the guidelines
guidelines logical order. but requires are missing
minor
improvements.
The report
completely The report The report The report is
discusses the discusses the discusses the totally irrelevant
To discuss the required task in required task lab work but to the lab work
actual own words with have
task some relevant irrelevant
additional information
information
Calculations Calculations and Most data and Calculations and
and data analysis observations data analyses of
were performed were lab were missing
data analyses
To perform accurately, but recorded
calculations and minor errors adequately,
were performed
data analysis were made both but with
clearly,
in calculations several
concisely, and
and in applying significant
accurately, with
correct units errors
correct
units. or omissions.
Graphs, if Graphs, if Graphs, if Major
necessary, were necessary, were necessary, components of
To present results drawn drawn were drawn but lab
in the form of accurately and adequately inadequately. were
graphs neatly and were missing
clearly labelled.

Course Instructor: Dr. Riaz Akbar Shah


2|Page

Table of Contents
Contents
Objectives..............................................................................................................................................................
Theory....................................................................................................................................................................
Rotation Matrix......................................................................................................................................................
Rotation about X....................................................................................................................................................
Rotation about Y ...................................................................................................................................................
Rotation about Z.....................................................................................................................................................
Procedure...............................................................................................................................................................
Task1......................................................................................................................................................................
Task 2.....................................................................................................................................................................
Task 3....................................................................................................................................................................
References.............................................................................................................................................................

Course Instructor: Dr. Riaz Akbar Shah


3|Page

Lab No: 4 Rotation Matrix in MATLAB


Objectives:
 To learn about robotics toolbar.
 To study about rotation matrix.
 To implement rotation matrix in matlab.

Theory:
Rotation Matrix:
Rotation matrices are used in two senses: they can be used to rotate a vector into a new position or they
can be used to rotate a coordinate basis (or coordinate system) into a new one.

Rotation about X axis:

Figure 1Rotation about x-axis

Course Instructor: Dr. Riaz Akbar Shah


4|Page

Rotation about Y axis:

Figure 2Rotation about Y-axis

Rotation about Z axis:

Rotation Matrix in MATLAB:


Procedure
Step 1: Install Robotics Toolbox
Ensure that the Robotics Toolbox is installed in your
MATLAB environment. If not, download and install it from
MathWorks.

Step 2: Set Up MATLAB Script


Open MATLAB and create a new script or function to
perform the rotation matrix calculation.
Figure 3 Rotation about Z-axis

Step 3: Import Robotics Toolbox


Include the Robotics Toolbox in your script by adding the toolbox's path to the MATLAB search path.
% Import the Robotics Toolbox
addpath(genpath('path_to_your_robotics_toolbox'));
Replace 'path_to_your_robotics_toolbox' with the actual path to your Robotics Toolbox folder.

Step 4: Define Rotation Angle


Set the desired rotation angle in degrees. Modify the theta variable to your specific angle
Course Instructor: Dr. Riaz Akbar Shah
5|Page

% Define the rotation angle in degrees


theta = 45; % Change this to your desired angle

Step 5: Create Rotation Matrix


Utilize the rotz function from the Robotics Toolbox to
create a rotation matrix for a rotation about the z-axis.
% Create a rotation matrix for rotation about the z-
axis
R = rotz(theta);

Step 6: Display the Rotation Matrix


Show the resulting rotation matrix in the MATLAB
command window.
% Display the rotation matrix
disp('Rotation Matrix:');
disp(R);

Conclusion
This tutorial demonstrates the process of creating a rotation matrix for a specified angle using the Robotics
Toolbox in MATLAB. The provided steps can be adapted for different rotation axes and angles, offering a
versatile tool for robotics applications.

Task 1: Frame Rotation about X-axis:


MATLAB Code:
angle = 45;
a = rotx(2*pi*angle/360);
trplot(a);
tranimate(a);

Code Explanation:
 First of all I defined a variable angle and stored 45 in it.
 Then to find rotation matrix about x axis I used rotx and save result in a variable.
 then I used trplot function to plot output.
 Then I used tranimate function to animate the results.
Output:

Course Instructor: Dr. Riaz Akbar Shah


6|Page

Task 2: Frame Rotation about Y-axis:


MATLAB Code:
angle = 45;
b = roty(2*pi*angle/360);
trplot(b);
tranimate(b);

Code Explanation:
 First of all I defined a variable angle and stored 45 in it.
 Then to find rotation matrix about x axis I used rotx and save result in b variable.
 then I used trplot function to plot output.
 Then I used tranimate function to animate the results.
Output:

Figure 4 Rotation about y

Task 3: Frame Rotation about Z-axis:


MATLAB Code:
angle = 45;
c = rotz(2*pi*angle/360);
trplot(c);
tranimate(c);

Code Explanation:
 First of all I defined a variable angle and stored 45 in it.
 Then to find rotation matrix about x axis I used rotz and save result in c variable.
Course Instructor: Dr. Riaz Akbar Shah
7|Page

 then I used trplot function to plot output.


 Then I used tranimate function to animate the results.

Outputs:

Figure 5 Rotation about z axis

References:
[1] https://www.indiamart.com/ proddetail/pick-place-
systems-6600798248.html
[2] https://www.ebay.com/ itm/293659659435
[3] https:// americanhistory.si.edu/
collections/search/object/ nmah_1028521
[4] %20a,dynamics%2C %20assuming%20zero
%20initial%20conditions.

Course Instructor: Dr. Riaz Akbar Shah

You might also like