You are on page 1of 11

# Introduction To Robotics

EL424
LABORATORY MANUAL
Spring 2018

LAB 01
Coordinate Transformations in Robotics Using MATLAB
Engr. Iqra Akram

## ________________________________________ __________ ___

STUDENT NAME ROLL NO SEC

______________________________________
LAB ENGINEER SIGNATURE & DATE

## MARKS AWARDED: /10

________________________________________________________________
NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES (NUCES), ISLAMABAD

## Prepared by: Engr. Iqra Akram Version: 1.01

Last Edited by: Engr. Iqra Akram Date: 22Jan, 2018
Verified by: Dr. Mukhtar Ullah Date: 22Jan, 2018
Coordinate Transformations in Robotics LAB: 01
LAB: 01 Coordinate Transformations in Robotics

1. Learning Objectives:
a. Introduction To MATLAB Robotics Toolbox
b. Understanding of Translation Vector
c. Understanding Rotation Matrix
d. Understanding of Euler Angles
e. Coordinates trnasformation

2. Equipment Required:
 MATLAB
 PC
3. Introduction
In robotics applications, many different coordinate systems can be used to define where
robots, sensors, and other objects are located. In general, the location of an object in 3-D
space is defined by its position and orientation. There are multiple possible representations
for these quantities, some of which are specific to certain applications. Translation and
rotation are alternative terms for position and orientation. Robotics System Toolbox™
supports representations that are commonly used in robotics and allows you to convert
between them. You can transform between coordinate systems when you apply these
representations to 3-D points. These supported representations are detailed below with brief
explanations of their usage and numeric equivalent in MATLAB®. Each representation has
an abbreviation for its name. This is used in the naming of arguments and conversion
functions that are supported in this toolbox. Robotics System Toolbox assumes that positions
and orientations are defined in a right-handed Cartesian coordinate system.

What is Translation:
In a translation transformation all the points in the object are moved in a straight line in the
same direction. The size, the shape and the orientation of the image are the same as that of the
original object. Same orientation means that the object and image are facing the same
direction.

## Introduction to Robotics NUCES, ISLAMABAD Page 2 of 11

Coordinate Transformations in Robotics LAB: 01

What is Rotation:
In linear algebra, a rotation matrix is a matrix that is used to perform a rotation in Euclidean
space. For example, using the convention below, the matrix rotates points in the xy-plane
counterclockwise through an angle θ about the origin of the Cartesian coordinate system. To
perform the rotation using a rotation matrix R, the position of each point must be represented
by a column vector v, containing the coordinates of the point. A rotated vector is obtained by
using the matrix multiplication Rv.

Rotation in 3D:

## Introduction to Robotics NUCES, ISLAMABAD Page 3 of 11

Coordinate Transformations in Robotics LAB: 01
Euler Angle:

## 1- Convert axis-angle rotation to rotation matrix

Syntax
rotm = axang2rotm(axang)
Description
rotm = axang2rotm(axang) converts a rotation given in axis-angle form, axang, to an orthonormal
rotation matrix,rotm. When using the rotation matrix, premultiply it with the coordinates to be rotated
(as opposed to postmultiplying).

## 2- Convert axis-angle rotation to homogeneous transformation

Syntax
tform = axang2tform(axang)
Description
tform = axang2tform(axang) converts a rotation given in axis-angle form, axang, to a homogeneous
transformation matrix, tform. When using the transformation matrix, premultiply it with the
coordinates to be transformed (as opposed to postmultiplying).

## 3- Convert Euler angles to rotation matrix

Syntax
rotm = eul2rotm(eul)
rotm = eul2rotm(eul,sequence)
Description

## Introduction to Robotics NUCES, ISLAMABAD Page 4 of 11

Coordinate Transformations in Robotics LAB: 01
rotm = eul2rotm(eul) converts a set of Euler angles,eul, to the corresponding rotation matrix, rotm.
When using the rotation matrix, premultiply it with the coordinates to be rotated (as opposed to
postmultiplying). The default order for Euler angle rotations is 'ZYX'.

## 4- Convert Euler angles to homogeneous transformation

Syntax
eul = eul2tform(eul)
tform = eul2tform(eul,sequence)
Description
eul = eul2tform(eul) converts a set of Euler angles,eul, into a homogeneous transformation
matrix, tform. When using the transformation matrix, premultiply it with the coordinates to be
transformed (as opposed to postmultiplying). The default order for Euler angle rotations is 'ZYX'.

## 5- Convert rotation matrix to axis-angle rotation

Syntax
axang = rotm2axang(rotm)
Description
axang = rotm2axang(rotm) converts a rotation given as an orthonormal rotation matrix, rotm, to the
corresponding axis-angle representation, axang. The input rotation matrix must be in the premultiply
form for rotations.

## 6- Convert rotation matrix to Euler angles

Syntax
eul = rotm2eul(rotm)
eul = rotm2eul(rotm,sequence)
Description
eul = rotm2eul(rotm) converts a rotation matrix, rotm, to the corresponding Euler angles, eul. The
input rotation matrix must be in the premultiply form for rotations. The default order for Euler angle
rotations is 'ZYX'.

## 7- Convert rotation matrix to homogeneous transformation

Syntax
tform = rotm2tform(rotm)
Description
tform = rotm2tform(rotm) converts the rotation matrix,rotm, into a homogeneous transformation
matrix, tform. The input rotation matrix must be in the premultiply form for rotations. When using the
transformation matrix, premultiply it with the coordinates to be transformed (as opposed to
postmultiplying).

## 8- Convert homogeneous transformation to axis-angle rotation

Syntax
axang = tform2axang(tform)
Description
axang = tform2axang(tform) converts the rotational component of a homogeneous
transformation, tform, to an axis-angle rotation, axang. The translational components
Introduction to Robotics NUCES, ISLAMABAD Page 5 of 11
Coordinate Transformations in Robotics LAB: 01
oftform are ignored. The input homogeneous transformation must be in the premultiply form
for transformations.

## 9- Extract Euler angles from homogeneous transformation

Syntax
eul = tform2eul(tform)
eul = tform2eul(tform, sequence)
Description
eul = tform2eul(tform) extracts the rotational component from a homogeneous
transformation, tform, and returns it as Euler angles, eul. The translational components
of tform are ignored. The input homogeneous transformation must be in the premultiply form
for transformations. The default order for Euler angle rotations is 'ZYX'.

## 10- Extract rotation matrix from homogeneous transformation

Syntax
rotm = tform2rotm(tform)
Description
rotm = tform2rotm(tform) extracts the rotational component from a homogeneous
transformation, tform, and returns it as an orthonormal rotation matrix, rotm. The
translational components of tform are ignored. The input homogeneous transformation must
be in the pre-multiply form for transformations. When using the rotation matrix, premultiply
it with the coordinates to be rotated (as opposed to postmultiplying).

## 11- Extract translation vector from homogeneous transformation

Syntax
trvec = tform2trvec(tform)
Description
trvec = tform2trvec(tform) extracts the Cartesian representation of translation vector, trvec ,
from a homogeneous transformation, tform. The rotational components of tform are ignored.
The input homogeneous transformation must be in the premultiply form for transformations.

## 12- Convert Cartesian coordinates to homogeneous coordinates

Syntax
hom = cart2hom(cart)
Description
hom = cart2hom(cart) converts a set of points in Cartesian coordinates to homogeneous
coordinates.

## 13- Convert homogeneous coordinates to Cartesian coordinates

Syntax
cart = hom2cart(hom)
Description
cart = hom2cart(hom) converts a set of homogeneous points to Cartesian coordinates.

## Introduction to Robotics NUCES, ISLAMABAD Page 6 of 11

Coordinate Transformations in Robotics LAB: 01
14- Convert translation vector to homogeneous transformation

Syntax
tform = trvec2tform(trvec)
Description
tform = trvec2tform(trvec) converts the Cartesian representation of a translation vector, trvec,
to the corresponding homogeneous transformation, tform. When using the transformation
matrix, premultiply it with the coordinates to be transformed (as opposed to postmultiplying).

MATLAB Toolbox

## Convert axis-angle rotation to rotation matrix

i. [1 0 0 pi]

Convert axis-angle rotation to homogeneous transformation

i. [0 1 0 pi/2]

i. [0 0 pi/2]

i. [0 0 pi/2]

## Convert rotation matrix to axis-angle rotation

i. [1 0 0 ; 0 -1 0; 0 0 -1]

## Convert rotation matrix to Euler angles

i. [1 0 0 ; 0 -1 0; 0 0 -1]

Introduction to Robotics NUCES, ISLAMABAD Page 7 of 11
Coordinate Transformations in Robotics LAB: 01
Convert rotation matrix to homogeneous transformation

i. [1 0 0 ; 0 -1 0; 0 0 -1]

## Convert homogeneous transformation to axis-angle rotation

i. [1 0 0 0; 0 0 -1 0; 0 1 0 0; 0 0 0 1]

## Extract Euler angles from homogeneous transformation

i. [1 0 0 0.5; 0 -1 0 5; 0 0 -1 -1.2; 0 0 0 1]

## Extract rotation matrix from homogeneous transformation

i. [1 0 0 0.5; 0 -1 0 5; 0 0 -1 -1.2; 0 0 0 1]

## Extract translation vector from homogeneous transformation

i. [1 0 0 0.5; 0 -1 0 5; 0 0 -1 -1.2; 0 0 0 1]

## Introduction to Robotics NUCES, ISLAMABAD Page 8 of 11

Coordinate Transformations in Robotics LAB: 01
i. [0.5 6 100];

## Introduction to Robotics NUCES, ISLAMABAD Page 9 of 11

Coordinate Transformations in Robotics LAB: 01
Submission Declaration by the Student:
In submitting this lab write-up to the Lab Engineer/Instructor, I hereby declare that:
 I have performed all the practical work myself
 I have noted down actual measurements in this writeup from my own working
 I have written un-plagarised answers to various questions
 I have/have not obtained the desired objectives of the lab.
Reasons of not obtaining objectoves (if applicable): _________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________
Student’s signature and Date

## Student Evaluation by the Lab Engineer:

The Lab Engineer can separate this page from the writeup and keep it for his/her own record.
It must be signed by the student with date on it.
 Lab Work: objectives achieved (correctness of measurements, calculations, answers to
questions posed, conclusion) ________/30
 Lab Writeup: Neatness, appropriateness, intime submission ________/10
 Troubleshooting: Were the student able to troubleshoot his/her work when it was
purposedly changed? ________/10
 TOTAL: ________/50

## Feedback on student behaviour:

average score, and +2 means best/most relevant/most adequate.

##  Did the student join the lab at the start/remained in lab? -2 -1 0 1 2

 Did the student remain focused on his/her work during lab? -2 -1 0 1 2
 Rate student's behaviour with fellows/staff/Lab Engineer? -2 -1 0 1 2
 Did the student cause any distraction during the Lab?-2 -1 0 1 2
 Was the student found in any sort of plagiarism? -2 -1 0 1 2

__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
___________________________
Lab Engineer’s signature and Date

## Introduction to Robotics NUCES, ISLAMABAD Page 10 of 11

Coordinate Transformations in Robotics LAB: 01
 Providing feedback for every lab session is optional. No feedback means you are
satisified
 The Lab Committee will consider only duly filled forms submitted within one week after
the lab
 This feedabck is for LAB session: LAB Number: _____, Date: _____________________
 General (to provide feedback on a persistent practice/ocurrence in LABs).
 Your current CGPA is in the range 4.00 to 3.00/2.99 to 2.00/1.99 to 1.00/0.99 to 0.00

## This feedback is:

 For a Particular
 Who conducted the LAB? __________________________________________________
 Actual Start time: _______________ Total Duration of Lab: _______________________
 Instruction Duration: _________________ Practical Duration: _____________________
 LAB writeup available before LAB?Yes/No with the Photocopier/in LAB/in SLATE
 Had the theory related to lab been covered in theory class?Yes/No
average score, and +2 means best/most relevant/most adequate.

## Was duration of instruction session adequate? -2 -1 0 +1 +2

Instruction How much did you understand about the practical? -2 -1 0 +1 +2
Session How much content was irrelevant to the practical? -2 -1 0 +1 +2
Did the instructor allowed Q/A and discussion? -2 -1 0 +1 +2
Practical Did you get sufficient time for practical? -2 -1 0 +1 +2
Presence in lab at all time? -2 -1 0 +1 +2
Ability to convey? -2 -1 0 +1 +2
Lab Readiness to help during practical? -2 -1 0 +1 +2
Engineer Readiness to discuss theoretical aspects? -2 -1 0 +1 +2
Helps in troubleshooting? -2 -1 0 +1 +2
Guides hows & whys of troubleshooting? -2 -1 0 +1 +2
How friendly was the lab staff? -2 -1 0 +1 +2
Staff Presence of staff throughout the lab session? -2 -1 0 +1 +2
Impact of availability of staff on your practical? -2 -1 0 +1 +2
Performance of Electronic Instruments? -2 -1 0 +1 +2
Equipment Performance of Breadboard/experiment kit? -2 -1 0 +1 +2
Performance of circuit components esp. ICs? -2 -1 0 +1 +2
Overall Your overall rating for the whole lab session? -2 -1 0 +1 +2