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

Lab2 1

This document discusses various topics in robotics including: 1. Converting between 2D and 3D transformation matrices and representing translations and rotations in 3D space. 2. Functions for creating rotational and translational transformations as well as visualizing transformations. 3. Different representations of 3D rotations including fixed/Euler angles, roll-pitch-yaw, and rotation about an arbitrary axis. 4. Combining translations and orientations into homogeneous transformation matrices.

Uploaded by

N M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lab2 1

This document discusses various topics in robotics including: 1. Converting between 2D and 3D transformation matrices and representing translations and rotations in 3D space. 2. Functions for creating rotational and translational transformations as well as visualizing transformations. 3. Different representations of 3D rotations including fixed/Euler angles, roll-pitch-yaw, and rotation about an arbitrary axis. 4. Combining translations and orientations into homogeneous transformation matrices.

Uploaded by

N M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

University of Sana’a

Faculty of Engineering
Mechatronics Eng. Department

MT502 - Robotics

Lab.2 : Position, Orientation and Transformation in 3-Dimension

Eng. Yahya AL-Lathi


2D Form (3*3) to 3D (4*4)
➢ se3(t2) returns a homogeneous transform (4 ×4) that represents the same
X,Y translation and Z rotation as does t2 (3 ×3).
>> se2(1,2,pi/2)
ans =

0.0000 -1.0000 1.0000


1.0000 0.0000 2.0000
0 0 1.0000
>> se3(ans)
ans =
0.0000 -1.0000 0 1.0000
1.0000 0.0000 0 2.0000
0 0 1.0000 0
0 0 0 1.0000
3D –Translation

➢ Create a translational transformation matrix:


homogeneous transform (4 ×4) representing a pure translation of x, y and z.

>> T = transl(1, 2, 3)

T=

1 0 0 1

0 1 0 2

0 0 1 3

0 0 0 1
3D –Rotation

➢ The Toolbox provides functions to compute these elementary rotation


matrices, for example Rx(θ) is:
>> R = rotx(pi/2)
R=
1.0000 0 0
0 0.0000 -1.0000
0 1.0000 0.0000

➢ The functions roty and rotz compute Ry(θ) and Rz(θ) respectively.
➢ The corresponding coordinate frame can be displayed graphically:
>> trplot(R)
➢ We can visualize a rotation more powerfully using the Toolbox function tranimate
which animates a rotation
>> tranimate(R)
Animation
Exercise-2:
➢ Create a function that can be used for 3d -animation?

(a)
tranimate(F1)
show the animation of frame (F1) moving from world frame to pose F1.
(b)
tranimate(F1, F2)
show the animation of frame (F2) moving from frame(F1) to pose F2.
3D –Fixed vs Euler Rotation -Example

➢ The position of rotation transformation determine the type of


rotation (fixed or Euler).
F =rotz(pi/2); trplot(F,'color', 'r’); hold on
choice = menu('continue!','Yes');
tranimate(F, rotx(pi/2)*F)

F =rotz(pi/2); trplot(F,'color', 'r’); hold on


choice = menu('continue!','Yes');
tranimate(F, F*rotx(pi/2))
3D –Rotation -Example

➢ Plot the frame as shown in the figure by making the appropriate


rotations?

ans =
0.0000 0 1.0000
1.0000 0.0000 -0.0000
-0.0000 1.0000 0.0000
3D –Rotation -Example

➢ Plot the frame as shown in the figure by making the appropriate


rotations?

ans =
0.0000 0 1.0000
1.0000 0.0000 -0.0000
-0.0000 1.0000 0.0000

>> rotz(pi/2)*rotx(pi/2);
>> rotx(pi/2)*roty(pi/2);
>> roty(pi/2)*rotz(pi/2);
Three-Angle Representations

➢ Widely used convention is roll-pitch-yaw angle sequence


angle:
>> R =rotx(0.1)*roty(0.2)*rotz(0.3);
>> R = rpy2r(0.1, 0.2, 0.3)
R=
0.9363 -0.2896 0.1987
0.3130 0.9447 -0.0978
-0.1593 0.1538 0.9752
>> gamma = tr2rpy(R)
gamma =
0.1000 0.2000 0.300
Three-Angle Representations

➢Compounding a number of elementary transformations:


>> R = rotz(0.1) * roty(0.2) * rotz(0.3);
>> R = eul2r(0.1, 0.2, 0.3)

➢The inverse problem is finding the Euler angles that


correspond to a given rotation matrix:

>> gamma = tr2eul(R)


gamma =
0.1000 0.2000 0.3000
Rotation about an Arbitrary Vector

➢ Rotation can be related by a single rotation about some axis


in space. For the example rotation used earlier:
>> R = rpy2r(0.1 , 0.2, 0.3);
>> [theta, v] = tr2angvec(R)
theta =
0.3816
v=
0.3379 0.4807 0.8092

where theta is the amount of rotation and v is the vector


around which the rotation occurs.
Combining Translation and Orientation
➢ The Toolbox has many functions to create homogeneous transformations. For
example we can demonstrate composition of transforms by:
>> T = transl(1, 0, 0) * trotx(pi/2) * transl(0, 1, 0)
T=
1.0000 0 0 1.0000
0 0 -1.0000 0.0000
0 1.0000 0.0000 1.0000
0 0 0 1.0000
>> trplot(T)

We can think of this expression as representing a walk along the x-axis for 1 unit,
then a rotation by 90°about the x-axis and then a walk of 1 unit along the new y-
axis which was the previous z-axis.
Any Questions ?!
Eng. Yahya AL-Lathi

You might also like