You are on page 1of 8

Práctica 1.

Matlab’s Robotics Toolbox


Robotics Toolbox
Robótica I MTR8B
Mayo-agosto 2011

Abstract

This Toolbox provides many functions that are useful in robotics including such things as kinematics, dynamics, and
trajectory generation. The Toolbox is useful for simulation as well as analyzing results from experiments with real
robots. The Toolbox has been developed and used over the last few years to the point where I now rarely write ‘C’ code
for these kinds of tasks.

The Toolbox is based on a very general method of representing the kinematics and dynamics of serial-link
manipulators. These parameters are encapsulated in Matlab objects. Robot objects can be created by the user for any
serial-link manipulator and a number of examples are provided for well know robots such as the Puma 560 and the
Stanford arm. The toolbox also provides functions for manipulating datatypes such as vectors, homogeneous
transformations and unit-quaternions which are necessary to represent 3-dimensional position and orientation.

The routines are generally written in a straightforward manner which allows for easy understanding, perhaps at the
expense of computational efficiency. If you feel strongly about computational efficiency then you can rewrite the
function to be more efficient compile the M-file using the Matlab compiler, or create a MEX version.

1. Configuración del Robotics Toolbox para Matlab

I. Bajar el archivo que se encuentra en el curso en Moodle de la materia de Robótica I 8B.


II. Descomprimir la carpeta llamada Robot (o copiar y pegar) en la carpeta llamada Toolbox dentro del
directorio de Matlab.
C:\MATLAB6p5\toolbox

III. Seleccionar en la barra de herramienta en el menú FILE la opción de Set Path…

1
IV. Se debe dar mayor prioridad a los comandos del Toolbox Robot, así que debe mandar la carpeta al fondo
después de la carpeta llamada WORK en la ventana de Set Path como se muestra en la figura.

V. Finalmente, compruebe con la siguiente instrucción (robot) si la herramienta fue bien configurada.

2. Comandos iniciales
Para correr el DEMO del Toolbox se utiliza el siguiente comando:

>> rtdemo

En este parcial se ven Transformaciones Homogéneas

>> help robot

>> help rotx

>> help roty

2
>> help rotz

NOTA: Recuerden que los ángulos deben ser ingresados en RADIANES.

>> help tr2rot

TR2ROT Return rotational submatrix of a homogeneous transformation

R = TR2ROT(T)

Return R the 3x3 orthonormal rotation matrix from the homogeneous


transformation T.

SEE ALSO: ROT2TR

>> help ROTVEC

Ejemplo 1:
Encuentre la matriz de rotación básica en 3D si un sistema coordenado es girado 20º respecto al eje X.

Solución

>> T=rotx(pi/9)
>> R=TR2ROT(T)

Ejemplo 2,
Calcular la matriz de rotación R x , . Si se rota primero 1   / 6 rad y luego  2   / 4 rad .

>> rotx(pi/6)*rotx(pi/4)
ans=

1.0000 0 0 0
0 0.2588 -0.9659 0
0 0.9659 0.2588 0
0 0 0 1.0000
>> rotx(pi/6 + pi/4)

¿Qué resultado se obtuvo?

Ejemplo 3,

El vector v0  0,4,5 modifica el valor de sus coordenadas al hacer rotar 90º el eje Yo. Encuentre las nuevas
coordenadas y verifíquelo dibujándolo.

>> V0=[0,4,5]' %La apóstrofe nos permite realizar la transpuesta


>> T= roty(pi/2)
>> R=TR2ROT(T)
>> V1= R*V0

V1 =

5.0000
4.0000
0.0000

3
Ejemplo 4,

Suponga que la matriz de rotación resultante R representa la rotación del ángulo Ø alrededor del eje Y0
seguido por una rotación del ángulo  alrededor del eje Z1. La matriz R se encuentra de la siguiente manera:

>> syms phi theta;


>> R=roty(phi)*rotz(theta);
>> pretty(R)

Resultado

[cos(phi) cos(theta) -cos(phi) sin(theta) sin(phi) 0]


[ ]
[ sin(theta) cos(theta) 0 0]
[ ]
[-sin(phi) cos(theta) sin(phi) sin(theta) cos(phi) 0]
[ ]
[ 0 0 0 1]

Ejemplo 5,

Suponiendo que   30º y   60º en el ejemplo 4.

>> R=roty(pi/6)*rotz(pi/3)
>> TR2ROT(R)

ans =

0.4330 -0.7500 0.5000


0.8660 0.5000 0
-0.2500 0.4330 0.8660

Ejemplo 6,
¿Se obtendrá el mismo resultado? Si R z , R y , …

>> R1= rotz(pi/3)*roty(pi/6)


>> TR2ROT(R)

Escriba su conclusión acerca de este ejercicio y la propiedad de conmutación en la multiplicación de


matrices.
________________________________________________________________________________________
________________________________________________________________________________________
________________________________________________________________________________________

3. Otros comandos útiles


>> twolink %Ejemplo de un robot articulado de 2RR en dos dimensiones

4
Genera un objeto llamado tl y un vector qz

>> plot(tl,qz)

Modificar el valor de q a [pi/2 0]

>> qz=[pi/2 –pi/2]

5
>> drivebot(tl)

Otros ejemplos Robot PUMA


>> puma560 % define the robot
>> plot(p560,qz) % draw it
>> drivebot(p560) % now drive it

4. Ejercicios

Si un punto en el marco de referencia O1X1Y1 tiene coordenadas P1=(1, 2).

B) ¿Cuál sería el valor de la coordenada cuando es visto desde el marco de referencia O0 X0Y0 si
   / 18 rad ?

5. Ejercicio 5. Robot articulado de 2 DOF.


6
A) Encontrar la matriz de rotación en 2D del robot R02 si 1  30º y  2  20º .

6. Anexos
6.1 quaternion/plot
Purpose Plot quaternion rotation
Synopsis plot(Q)
Description plot is overloaded for quaternion objects and displays a 3D plot which shows how the standard axes are
transformed under that rotation.

Examples

A rotation of 0.3rad about the X axis. Clearly the X axis is invariant under this rotation.
>> q=quaternion(rotx(0.3))
>> plot(q)

q1=quaternion(roty(0))
plot(q1)

q2=quaternion(rotz(pi/6))
plot(q2)
7
q3=quaternion(roty(0)*rotz(pi/2))
plot(q3)

NOTA: Utilicen el commando HOLD para graficar diferentes cuaterniones en la misma gráfica.

http://sites.google.com/site/docenciajg/Home/sistemas-mecanicos-2009-2010/practicas-lab-0910

You might also like