robotics quaternions

7
1 Autonomous Systems Lecture HW01 Arturo Gomez Chavez Due: 19-Sep-2013 1 Problem Given the quaternions q 1 = (1, (2, 3, 4)) and q 2 = (0.4811480, (0.1984591, 0.7246066, 0.4517253)) Which of the two represents an orientation? And why? In order to represent an orientation (an angle displacement in the 3D space), a quaternion q = q o + ~ q must have a norm equal to 1; N (q) = 1. If this is the case, q o 2 + |~ q| 2 =1 And since for any angle θ we know that cos 2 θ + sin 2 θ =1 there must be some angle θ such that cos 2 θ = q o 2 and sin 2 θ = |~ q| 2 . In this way, if we have a unit quaternion we can associate an angle θ to it and represent an orientation. Based upon this, we compute the norm of the given quaternions to know if they are unit quaternions. N (q 1 )= 1 2 +2 2 +3 2 +4 2 5.477 > 1 N (q 2 )= 0.4811480 2 +0.1984591 2 +0.7246066 2 +0.4517253 2 1 As we can see, quaternion q 1 cannot represent an orientation because it is not a unit vector, but quaternion q 2 can. 2 Problem What are the quaternion representations of the three axes x, y and z in a Carte- sian coordinate systems? Vectors are represented in R 4 as quaternions with a scalar value of zero. Hence, since the axes x, y, z are represented in R 3 as < 1, 0, 0 >, < 0, 1, 0 > and < 0, 0, 1 > respectively, their quaternions representations are: q x = (0, (1, 0, 0)) = 0 + i for axis x q y = (0, (0, 1, 0)) = 0 + j for axis y q z = (0, (0, 0, 1)) = 0 + k for axis z

Upload: arturo-gomez

Post on 11-Nov-2015

7 views

Category:

Documents


1 download

DESCRIPTION

examples

TRANSCRIPT

  • 1Autonomous Systems Lecture HW01Arturo Gomez Chavez

    Due: 19-Sep-2013

    1 Problem

    Given the quaternions

    q1 = (1, (2, 3, 4)) and q2 = (0.4811480, (0.1984591, 0.7246066, 0.4517253))

    Which of the two represents an orientation? And why?

    In order to represent an orientation (an angle displacement in the 3D space),a quaternion q = qo + ~q must have a norm equal to 1; N(q) = 1. If this is thecase,

    qo2 + |~q|2 = 1

    And since for any angle we know that

    cos2 + sin2 = 1

    there must be some angle such that cos2 = qo2 and sin2 = |~q|2. In this

    way, if we have a unit quaternion we can associate an angle to it and representan orientation.

    Based upon this, we compute the norm of the given quaternions to know ifthey are unit quaternions.

    N(q1) =

    12 + 22 + 32 + 42 5.477 > 1 N(q2) =

    0.48114802 + 0.19845912 + 0.72460662 + 0.45172532 1

    As we can see, quaternion q1 cannot represent an orientation because it is nota unit vector, but quaternion q2 can.

    2 Problem

    What are the quaternion representations of the three axes x, y and z in a Carte-sian coordinate systems?

    Vectors are represented in R4 as quaternions with a scalar value of zero.Hence, since the axes x, y, z are represented in R3 as < 1, 0, 0 >,< 0, 1, 0 > and< 0, 0, 1 > respectively, their quaternions representations are:

    qx = (0, (1, 0, 0)) = 0 + i for axis xqy = (0, (0, 1, 0)) = 0 + j for axis yqz = (0, (0, 0, 1)) = 0 + k for axis z

  • 23 Problem

    Given the quaternion q3 = (0.2191769, (0.4288243, 0.6384718, 0.6003541)). Con-vert it into a rotation matrix.

    First we have to check that the given quaternion is a unit quaternion for thereasons explained in Problem 1.

    N(q3) =

    0.21917692 + 0.42882432 + 0.63847182 + 0.60035412 1

    Once this is verified, the correspondent equivalent rotational matrix R of thequaternion q3 = qo + ~q = qo + q1i + q2j + q3k can be found to be:

    R =

    q2o + q21 q22 q23 2q1q2 2qoq3 2q1q3 + 2qoq22q1q2 + 2qoq3 q2o q21 + q22 q23 2q2q3 2qoq12q1q3 2qoq2 2q2q3 2qoq1 q2o q21 q22 + q23

    Replacing the components of q3 by their numerical values, we obtained the

    following rotation matrix:

    R =

    0.536072517511710 0.284369945185620 0.7947453713038600.810704947346780 0.088700546274690 0.5785757654820600.235040335434660 0.954529288356740 0.183002987279070

    4 Problem

    Find out how to convert a rotation matrix into a quaternion. Then, use thequaternion multiplication to rotate the following two homogeneous coordinatematrices by an angle of 30 degrees around the y-axis and express the resultingframe as a quaternion/point-pair (i.e., quaternion for the orientation plus therelated 3D point of the origin of the frame):

    H1 =

    0.866 0.433 0.250 0

    0 0.5 0.866 00.5 0.75 0.433 0

    0 0 0 1

    H2 =

    0.866 0.433 0.250 2

    0 0.5 0.866 40.5 0.75 0.433 1

    0 0 0 1

    First we have to derive the quaternion q4 with rotation vector j (the basis

    vector associated with the y axis) for it to perform a rotation of pi/6 or 30.According to what we explained in Problem 1 and considering that quaternions

  • 3perform a rotation twice as large as the angles associated with them, we choose = (pi/6)/2 = pi/12 and write the quaternion q4 in the form

    q4 = cos + j sin = 0.9659 + 0.2588 j

    Then, it is necessary to consider the general form of a homogeneous matrix.

    H =

    R1,1 R1,2 R1,3 t1R2,1 R2,2 R2,3 t2R3,1 R3,2 R3,3 t3

    0 0 0 1

    The elements in the first 3 columns and rows in the homogeneous matrix

    represent a rotation transformation. So we want to convert this 3 3 matrix Rinto a quaternion to apply quaternion multiplication with q4. To convert froma rotation matrix to a quaternion a code in Matlab was generated based on [1],the code is sent as another attachment.

    Solution for H1:

    First we transform the rotation matrix from the homogeneous matrix into aquaternion qH1

    R1 =

    0.866 0.433 0.2500 0.5 0.8660.5 0.75 0.433

    0.483 + 0.836i 0.129j 0.224k = qH1Then we multiply qH1 by q4 to rotate the homogeneous matrix H1. If we

    define qH1 = so + ~s and q4 = po + ~p, the quaternion product is

    qH1q4 = soqo ~s ~p+ so~p+ po~s+ ~s ~p

    soqo = (0.483)(0.9659) = 0.466~s ~p = (0.836)(0) + (0.129)(0.2588) + (0.224)(0) = 0.0333

    so~p = (0.483)(0.2588)j = 0.124224jpo~s = (0.9659)(0.836i 0.129j 0.224k) = 0.8075i 0.1246j 0.2164k

    ~s ~p =

    i j k0.836 0.129 0.224

    0 0.2588 0

    = (0.224 0.2588)i+ (0.836 0.2588)k

    ~s ~p = 0.05797i+ 0.21635k

    Agrouping terms,

    qH1q4 = (0.466 + 0.0333) + (0.8075 + 0.05797)i+(0.124224 0.1246)j+ (0.2164 + 0.21635)k

    qH1q4 = 0.433 + 0.866i 0.25j+ 0k

  • 4Finally we can express the resulting frame as follows. Since in this case notranslation has been done (the first 3 elements of H1 last column are zeros), the3D point of the origin of the frame is (0,0,0).

    F1 0.433 + 0.866i 0.25j/(0, 0, 0)

    Solution for H2:

    It can be observed that the rotation transformation in this homogeneousmatrix is the same as H1, and it will rotated 30 degrees as well. Thus, thequaternion to represent the resultant frame will be the same as the one obtainedfor H1.

    However, H2 indicates that there has been also a translation transformation.The origin of the frame has been translated by the vector t = (2,4, 1)T ; so the3D point of the frames origin will be (2,-4,1). The resulting frame is

    F2 0.433 + 0.866i 0.25j/(2,4, 1)

    5 Problem

    Given the homogeneous matrices A, B and C. Suppose that B and C are knownand that

    A B = C

    What is the easiest way, i.e., takes least computations, to determine A byexploiting the fact that the three matrices are homogeneous?

    The easiest way to determine A would be to multiply both sides of the equa-tion by the inverse of matrix B as follows

    A B = CA B B1 = C B1

    A I = C B1A = C B1

    This will be the easiest method because a homogeneous matrix is formedby a rotational matrix whose inverse is its transpose. This inverse rotationwill be applied to rotate back the frame and the vector used to translate it.Hence, just the matrix multiplication between the inverse rotation matrix andthe translation vector is needed. The rest is only a rearrangement of elements.

  • 5An example of a homogeneous matrix H and its inverse H1 is given below.

    H =

    [R t0 1

    ]H1 =

    [RT RT t0 1

    ]Where R is the rotation matrix, t is the column vector indicating the trans-

    lation transformation and 0 is the row vector with all elements equal to zeroand same number of elements as columns in the rotation matrix R.

    6 Problem

    Use the insight from above to determine A in

    A B = Cwith

    B =

    0.866 0.433 0.250 2

    0 0.5 0.866 40.5 0.75 0.433 1

    0 0 0 1

    C =

    0.5 0.433 0.75 50 0.866 0.5 3

    0.866 0.25 0.433 00 0 0 1

    As stated in Problem 5, we have to obtained the inverse of matrix B. So,

    first we derived the inverse of the rotation matrix associated with B.

    RB =

    0.866 0.433 0.2500 0.5 0.8660.5 0.75 0.433

    RB1 = RBT = 0.866 0 0.50.433 0.5 0.750.250 0.866 0.433

    Then we have to obtained the new translation vector t = RBT t according

    to the inverse of a homogeneous matrix shown in the previous problem.

    t = RBT t = 0.866 0 0.50.433 0.5 0.750.250 0.866 0.433

    241

    =1.23200.3840

    4.3970

    If we concatenate RB

    T and t, we obtained the inverse B1.

    B1 =[RB

    T RBT t0 1

    ]=

    0.866 0 0.5 1.23200.433 0.5 0.75 0.38400.250 0.866 0.433 4.3970

    0 0 0 1

  • 6Finally, we multiply C by B1 to obtain the homogeneous matrix A.

    A = C B1 =0.5 0.433 0.75 50 0.866 0.5 3

    0.866 0.25 0.433 00 0 0 1

    0.866 0 0.5 1.23200.433 0.5 0.75 0.38400.250 0.866 0.433 4.3970

    0 0 0 1

    A =

    0.8080 0.4330 0.3995 1.25250.2500 0.8660 0.4330 5.53100.5335 0.2500 0.8080 0.7410

    0 0 0 1

  • Bibliography

    [1] Funda, J.; Taylor, R.H.; Paul, R.P., On homogeneous transforms, quater-nions, and computational efficiency, Robotics and Automation, IEEETransactions on , vol.6, no.3, pp.382,388, Jun 1990

    7