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
- In the MATLAB Command Window run
>> rtbdemo
3 Tasks
Task 1: Planar rotations
- Choose a value of an angle θ1
- Write a formula for a rotation matrix R in planar case (in R2 space)
- Define matrix R1 in Matlab
>> R1=rot2(theta1)
check transpose, determinant and inverse of R1.
- Define matrix R2 for a different angle and verify properties of R2.
- Calculate the product of R1 and R2, verify its properties.
- Repeat for the changed order of R1 and R2.
- Compute the logarithm matrix S1 of R1, and exponent of the result
>> S1=logm(R1) >> expm(S1)
verify the properties of S1.
- 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?
- 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:
- 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?
- What is the form of a logarithm of rotation matrix? To what group it belongs, what are its properties?
- What are the properties of a product of two rotations?
Task 2: Homogenous transformations in 2D
- 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')
- Calculate compounds of transformations (3 cases: two rotations, two translations, a rotation and a translation, all in various order). Observe the properties of results.
- Check commutativity of the calculated above compounds. Plot the results.
- 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.
- 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:
- What is the form of a homogenous transformations and to what group it belongs?
- What are properties of compounds of transformations?
- How to transform coordinates of a point between an original and transformed coordinate frames (and back)?
Task 3: Basic rotations in 3D
- 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.
- Follow the steps of the task 1 in 3D case.
- Questions:
- What are similarities and differences between planar and spatial case?
Task 4: Three parameter represenation
- 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)
- For a rotation matrix calculate corresponding Euler angles.
>> tr2eul(R)
Observe the result.
- Repeat the previous steps for angles φ=0.1 , θ=-0.2, ψ=0.3.
- Repeat the steps again for angles φ=0.1 , θ=0, ψ=0.3.
- Follow the same steps in RPY representation
>> rpy2r(0.1, 0.2, 0.3) >> tr2rpy(R)
- Note: a tripleangle application may be used a help to understand the 3 angle representations
- Questions:
- What is the reason of the result in step 3?
- Which 3 angles for RPY representation have the same property?
Task 5: Vector angle representation
- Choose a rotation matrix R2 (with 1, 2 or 3 non-zero parameters in Euler representation), let R1 be the identity matrix.
- Calculate axis-angle representation of R2 and R1 (tr2angvec)
- Choose an axis and an angle of rotation, calculate corresponding matrix R3 (angvec2r)
- 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)
- * 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:
- Include the plot and code illustrating the rotation around the axis
Task 6: Homogenous transformations in 3D
- Define and visualize exemplary transformations
Tt=transl(1, 2, 3) Tr=eul2tr(0.3, 0.4, 0.5) trplot(Tt*Tr)
- Follow the steps from task 2
- Questions:
- What are similarities and differences between planar and spatial case?
- What is a structure of inverse matrix in 3D case?
Task 7*: Toward kinematics
- Define length parameters and angles of double pendulum
- Calculate points corresponding to the center of rotation and the end-points of each link using homogenous transformations.
- Plot the double pendulum and coordinate systems associated with each link
- Define initial and final angles, divide pendulum motion time to k periods, plot intermediate poses
- (*) use tranimate() or <object>.animate to show animated motion
- (**) use ode solver to calculate a solution of the pendulum motion, animate the result
- To report:
- 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.