Warning
This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

Homework 04 - Rigid motion as a coordinate transformation

Task

You can find the description of the task here.

For task 1:

# approximate rotation
R = np.array([[0.8047,   -0.5059,   -0.3106],
              [0.3106,    0.8047,   -0.5059],
              [0.5059,    0.3106,    0.8047]])
# less approximate rotation
u, s, vh = np.linalg.svd(R)
R = u.dot(vh)
# translation t, or OO' in beta
o_o_pr_beta = np.array([[-1], [0.5], [1]])

For task 2:

Create a function compute_rot_t(R_1, t_1, R_2, t_2, R_3, t_3) which takes as inputs three transformations as mentioned in the task description and outputs object pose after the motion.

Input/Output specifications for compute_rot_t:

  1. R_1, R_2, R_3 : rotation matrices (3×3 matrix of type np.ndarray)
  2. t_1, t_2, t_3 : translation (3×1 matrix of type np.ndarray)
  3. Return value : dictionary with 2 keys “r” and “t”, whose values are the rotation (3×3 matrix of type np.ndarray) and the translation (3×1 matrix of type np.ndarray) of the object after the motion expressed in the world frame.

Implement the solution in a single file hw04.py. The file must contain the compute_rot_t function, such that it can be imported (by the automatic evaluation) as

import hw04
res = hw04.compute_rot_t(*args)

Upload

Upload a zip archive hw04.zip (via the course ware) containing:

  1. hw04.json - json file containing the solution of Task 1
  2. hw04.py - python script containing the implemented function compute_rot_t
All the files must be contained in the root of hw04.zip.

Creating hw04.json:

Create an empty dictionary in Python:

solution = {}

The key for this dictionary will be “x_pr_beta”, translation, a list of three float values.

import json
with open("hw04.json", "w") as outfile:
    json.dump(solution, outfile)

courses/pkr/labs/hw04.txt · Last modified: 2022/10/24 14:18 by zorinkat