WS5 Lecture2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

MCTG 1021 Robotics

Workshop #5

Name:

SLerp + ScLerp: The RRR case

Background:

clear

Quaternions

Q=q_0 + q_1 i + q_2 j + q_3 k = (q0, q)

You can mathematically handle quaternions in different ways: row, column, structure, array

q_row=[sqrt(3)/2 1/2 0 0]

q_row = 1×4
0.8660 0.5000 0 0

q_row2=[sqrt(2)/2 0 sqrt(2)/2 0]

q_row2 = 1×4
0.7071 0 0.7071 0

q_column=[sqrt(3)/2; 1/2; 0; 0]

q_column = 4×1
0.8660
0.5000
0
0

q_column2=[sqrt(2)/2; 0; sqrt(2)/2; 0];


q_struct(1).scalar=sqrt(3)/2;
q_struct(1).vector=[1/2;0;0];
q_struct(2).scalar=sqrt(2)/2;
q_struct(2).vector=[0;sqrt(2)/2;0];
q_struct

q_struct = 1×2 struct


Fields scalar vector

1 0.866 [0.5000;...
2 0.7071 [0;0.707...

q_array(1,:)={sqrt(3)/2, [1/2 0 0]};


q_array(2,:)={sqrt(2)/2, [0 sqrt(2)/2 0]};
q_array

q_array = 2×2 cell


1 2

1 0.866 [0.5,0,0]

1
1 2

2 0.7071 [0,0.707...

Conjugate Q* = (q0, -q)

q1=q_row; q2=q_row2;
conjq1=[q1(1) -q1(2:4)];
conjq2=[q2(1) -q2(2:4)];
[conjq2; conjQ(q2); q2]

ans = 3×4
0.7071 0 -0.7071 0
0.7071 0 -0.7071 0
0.7071 0 0.7071 0

Product

%(?)
q1tq2=[q1(1)*q2(1)-dot(q1,q2) q1(1)*q2(2:4)+q2(1)*q1(2:4)+cross(q1(2:4),q2(2:4))]

q1tq2 = 1×4
0 0.3536 0.6124 0.3536

Magnitude must be 1 for unit quaternions (product of q and its conjugate)

magnq1=norm(q1)

magnq1 = 1

Power of a unit quaternion

tau=0.5;
%for example
a0=pi/6; u=[0 0 -1];
q0=[cos(a0/2) u*sin(a0/2)];
q0pow=[cos(tau*a0/2) u*sin(tau*a0/2)]

2
q0pow = 1×4
0.9914 0 0 -0.1305

Assignment 1: (submit main .m file + your functions)

• Write functions for each one of the operations described, and validate them. Use the conjQ conjugate
function that has been provided.
• Use your functions and perform spherical linear interpolation from an intended starting to a final
orientation. Assume the case of the end-effector of a 3R robot and the data from the example solved in
class. Plot the results (\theta vs \tau)

• Perform inverse kinematics and obtain the plots for each joint vs \tau. You can assume x,y and link
lengths (An IK function has been provided)
• Would there be any difference if we directly used a third degree polynomial to interpolate between the
initial and final configurations?

Assignment 2, Optional (due by the end of the day on Friday):

• For a UR10 robot perform spherical linear interpolation in Matlab. Assume that the robot EE firmly holds
a cup filled with water and you need to provide the joint angles that pour the water into a container. Plot
all joint and Cartesian displacements

You might also like