R1. Rotations and homogenous transformations

Table of Contents

1 Info

The assignment presents properties of rotations and homogenous transformations in 2D and 3D cases.

The points marked with (*) are optional (not obligatory).

2 Preparation

Download, install, and test

  • Download the Robotic toolbox package from the link on the laboratory page.
  • From within the MATLAB File Browser double click on the downloaded file, it should install the toolbox and configure the paths correctly.
  • In the MATLAB Command Window run
    >> startup_rvc
    	    
    which allows to verify if the installation is correct (there should be no warnings and error messages).
  • In the MATLAB Command Window run
    >> rtbdemo
    	    
    which will run the toolbox demo menu. Enjoy (but remember, it's not perfect one).

3 Tasks

Task 1: Planar rotations

  1. Choose a value of an angle θ1
  2. Write a formula for a rotation matrix R in planar case (in R2 space)
  3. Define matrix R1 in Matlab
    >>  R1=rot2(theta1)
    

    check transpose, determinant and inverse of R1.

  4. Define matrix R2 for a different angle and verify properties of R2.
  5. Calculate the product of R1 and R2, verify its properties.
  6. Repeat for the changed order of R1 and R2.
  7. Compute the logarithm matrix S1 of R1, and exponent of the result
    >>  S1=logm(R1)
    >>  expm(S1)
    

    verify the properties of S1.

  8. Check transformations between a number om1 and a skew-symmetric matrix S1
    >>  om1=vex(S1)
    >>  S1b=skew(om1)
    

    What is a relation between om1 and theta1? Does it hold for other angles?

  9. Repeat the last step for the product of two matrices for theta1 and theta2
    >>  R_pr=R1*R2
    >>  S_pr=logm(R_pr)
    >>  om_pr=vex(S_pr)
    

    What is a releation between ompr, theta1 and theta2?

  • Questions:
    1. What is the form of a rotation matrix on a plane, to what group it belongs, what are the properties of the elements of the group?
    2. What is the form of a logarithm of rotation matrix? To what group it belongs, what are its properties?
    3. What are the properties of a product of two rotations?

Task 2: Homogenous transformations in 2D

  1. Define homogenous transformations for rotations and translations for two different angles and vectors
    >> Tr1=trot2(30, 'deg')
    >> Tr2=trot2(pi/6)
    >> Tt1=transl2(1, 2)
    >> Tt2=transl2(2, 1)
    

    Observe the structure of matrices, then plot the examples

    >> plotvol([-1 6 -1 6]);
    >> trplot2(Tr1,'frame', 'r1', 'color', 'b')
    >> trplot2(Tt1,'frame', 't1', 'color', 'r')
    
  2. Calculate compounds of transformations (3 cases: two rotations, two translations, a rotation and a translation, all in various order). Observe the properties of results.
  3. Check commutativity of the calculated above compounds. Plot the results.
  4. Define a point with chosen coordinates P in the global coordinate system and a homogenous transformation T1=Tt1*Tr1
    >> P=[3;1.5];
    >> Ph=e2h(P)  % its homogenous representation
    >> h2e(Ph)    % back to origin
    >> plot_point(P, 'label', 'P', 'solid', 'ko');
    >> T1=Tt1*Tr1
    

    Find coordinates of P expressed in the coordinate system defined by T1.

  5. Let it be given a point P1 having coordinates P in the coordinate system defined by T1. Calculate its coordinates in the global coordinate system and plot it.
  • Questions:
    1. What is the form of a homogenous transformations and to what group it belongs?
    2. What are properties of compounds of transformations?
    3. How to transform coordinates of a point between an original and transformed coordinate frames (and back)?

Task 3: Basic rotations in 3D

  1. Define rotations around main axes (rotx, roty, rotz) and visualize them
    >> Rx = rotx(pi/6)
    >> trplot(Rx,'frame', 'x', 'color', 'b')
    

    check the properties as in task 1.

  2. Follow the steps of the task 1 in 3D case.
  • Questions:
    1. What are similarities and differences between planar and spatial case?

Task 4: Three parameter represenation

  1. Choose 3 angles φ, θ, ψ representing Euler angles ZYZ. Calculate basic rotations around respective axes and a resulting compound rotation. Compare the result with the result of package function.
    >> R = eul2r(phi, theta, psi)
    
  2. For a rotation matrix calculate corresponding Euler angles.
    >> tr2eul(R)
    

    Observe the result.

  3. Repeat the previous steps for angles φ=0.1 , θ=-0.2, ψ=0.3.
  4. Repeat the steps again for angles φ=0.1 , θ=0, ψ=0.3.
  5. Follow the same steps in RPY representation
    >> rpy2r(0.1, 0.2, 0.3)
    >> tr2rpy(R)
    
  6. Note: a tripleangle application may be used a help to understand the 3 angle representations
  • Questions:
    1. What is the reason of the result in step 3?
    2. Which 3 angles for RPY representation have the same property?

Task 5: Vector angle representation

  1. Choose a rotation matrix R2 (with 1, 2 or 3 non-zero parameters in Euler representation), let R1 be the identity matrix.
  2. Calculate axis-angle representation of R2 and R1 (tr2angvec)
  3. Choose an axis and an angle of rotation, calculate corresponding matrix R3 (angvec2r)
  4. For one of above cases plot initial and final orientation and the axis of rotation, add intermediate orientations (by using intermediate angles and calculations in loop)
  5. * Extend the previous case by using translations to obtain a spiral motion along the axis, with a center of coordinate frame in a distance d from the axis of rotation
  • To report:
    1. Include the plot and code illustrating the rotation around the axis

Task 6: Homogenous transformations in 3D

  1. Define and visualize exemplary transformations
    Tt=transl(1, 2, 3)
    Tr=eul2tr(0.3, 0.4, 0.5)
    trplot(Tt*Tr)
    
  2. Follow the steps from task 2
  • Questions:
    1. What are similarities and differences between planar and spatial case?
    2. What is a structure of inverse matrix in 3D case?

Task 7*: Toward kinematics

  1. Define length parameters and angles of double pendulum
  2. Calculate points corresponding to the center of rotation and the end-points of each link using homogenous transformations.
  3. Plot the double pendulum and coordinate systems associated with each link
  4. Define initial and final angles, divide pendulum motion time to k periods, plot intermediate poses
  5. (*) use tranimate() or <object>.animate to show animated motion
  6. (**) use ode solver to calculate a solution of the pendulum motion, animate the result
  • To report:
    1. Include code, parameters and final illustration of the example

4 Summary

  • The report should include the result of the tasks and answers to the questions.
  • Please do not forget to indicate the author of the report!
  • The report in PDF format should be submitted before the beginning of next classes using a method defined by the instructor.