Operácie

Robotics

Z SensorWiki

Verzia z 09:37, 3. október 2016, ktorú vytvoril Balogh (diskusia | príspevky) (L3.10 2-axis representation)

Helper page for the Peter Corke: Introduction to robotics MOOC.

L3.10 2-axis representation

Check understanding: The rotation matrix

 0.9363 −0.2896  0.1987
 0.3130  0.9447 −0.0978
−0.1593  0.1538  0.9752

is equivalent to the 2-vector representation:

  • A=(−1.8833,6.1427,1.0000),O=(1.0000,−0.4925,4.9085)
  • A=(1.0000,−0.4925,4.9085),O=(2.9914,1.0000,−0.5091)
  • A=(1.0000,−0.4925,4.9085),O=(−1.8833,6.1427,1.0000) (CORRECT)
  • A=(−1.8833,6.1427,1.0000),O=(2.9914,1.0000,−0.5091)

Solution:

o=[-1.8833, 6.1427, 1.0000];     %Orientation vector
a=[1.0000, -0.4925, 4.9085];     %Approach vector
R=oa2r(o,a)    %To create rotation matrix R from o and a vectors

R =

 0.9363         -0.2896         0.1987
 0.3130          0.9447        -0.0978
-0.1593         0.1538         0.9752
 
n=cross(o,a)     %To calculate normal vector n
n =
30.6439       10.2442       -5.2152

r=[n' o' a']     %To create rotation matrix r with columns of n, o, a vectors

# Wrong, n, o and a are unit vectors: 

r=[unit(n') unit(o') unit(a')]     %To create rotation matrix r with columns of n, o, a vectors

tr2rpy(R)     %To calculate roll, pitch and yaw angles from rotation matrix R
tr2rpy(r)     %To calculate roll, pitch and yaw angles from rotation matrix r

Can you please explain:

1. How can matrices R=oa2r(o,a) and r=[n' o' a'] proved to be equivalent? 2. Why is a difference appearing in the yaw angle calculated from matrix R and from matrix r?


Explanation

We can really only do this by trial error, try each of the potential answers and see if it gives the desired rotation matrix. Note that the arguments to the oa2r() function are given in the order O then A, the reverse of what's above.

>> oa2r( [1.0000,   -0.4925,  4.9085], [-1.8833,  6.1427, 1.0000])
>> oa2r( [2.9914, 1.0000,  -0.5091], [1.0000,   -0.4925,  4.9085])
>> oa2r( [-1.8833,  6.1427, 1.0000], [1.0000,   -0.4925,  4.9085])
>> oa2r( [2.9914, 1.0000,  -0.5091], [-1.8833,  6.1427, 1.0000])


L3.12 Quaternions

Exercise

  • In the MATLAB workspace create a rotation matrix equivalent to a rotation of 30° about the x-axis, and store it in the workspace as the variable R1.
  • Create another which is equivalent to a rotation of 60° about the y-axis and store that in the variable R2.
  • Create a unit-quaternion equivalent to the rotation R1 and store it in the workspace as the variable q1.
  • Use the notation q1.R to convert the quaternion to a rotation matrix. Compare this to the original rotation matrix R1.
  • Create another quaternion, call this one q2, equivalent to the rotation matrix R2.
  • Inspect the vector part of the quaternions, what axes are these parallel to?
  • Multiply quaternion q1 by quaternion q2, using the standard MATLAB multiplication operation.
  • Compute the inverse of quaternion q1, using the MATLAB function inv.
  • Use the .R notation from above to convert the quaternion to a rotation matrix. Compare this result to directly computing the inverse of R1.
  • Multiply quaternion q1 by its inverse and inspect the result. Convert the result back to a rotation matrix.

Hints/Solutions to Exercise

R1 = rotx(30, 'deg')
R2 = roty(60, 'deg')

q1 = Quaternion(R1)

q1.R

q2 = Quaternion(R2)

q1*q2

ans.R
R1*R2

inv(q1)
ans.R
inv(R1)

q1*inv(q1)
ans.R