License: CC-BY-NC-SA 4.0
I found an issue¶
Thank you! Please report it at https://
Latex Macros¶
\providecommand{\myvec}[1]{{\mathbf{\boldsymbol{{#1}}}}}
\providecommand{\mymatrix}[1]{{\mathbf{\boldsymbol{{#1}}}}}Valid imports¶
from math import pi, sin, cos
import numpy as npq_A0 = pi/4.0 # As given in the exercise
q_A1 = -0.1 # As given in the exercise
H_A0_A0p = np.array(
[[cos(q_A0), -sin(q_A0), 0, 0],
[sin(q_A0), cos(q_A0), 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]]
)
H_A0p_A0pp = np.array(
[[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0.5],
[0, 0, 0, 1]]
)
H_A0pp_A1 = np.array(
[[1, 0, 0, 0],
[0, cos(pi/2), -sin(pi/2), 0],
[0, sin(pi/2), cos(pi/2), 0],
[0, 0, 0, 1]]
)
H_A1_A2 = np.array(
[[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, q_A1],
[0, 0, 0, 1]]
)
H_A0_A2 = H_A0_A0p @ H_A0p_A0pp @ H_A0pp_A1 @ H_A1_A2
# Printing the result is NOT a mandatory part of the answer.
print(f'H_A0_A2 = {H_A0_A2}')H_A0_A2 = [[ 7.07106781e-01 -4.32978028e-17 7.07106781e-01 -7.07106781e-02]
[ 7.07106781e-01 4.32978028e-17 -7.07106781e-01 7.07106781e-02]
[ 0.00000000e+00 1.00000000e+00 6.12323400e-17 5.00000000e-01]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
Exercise c¶
# All rotations are the same
H_Rz = np.array(
[[cos(pi/5.0), -sin(pi/5.0), 0, 0],
[sin(pi/5.0), cos(pi/5.0), 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]]
)
# All translations are the same
H_Tx = np.array(
[[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0.25],
[0, 0, 0, 1]]
)
H_C0_C3 = H_Rz @ H_Tx @ H_Rz @ H_Tx @ H_Rz @ H_Tx
# Printing the result is NOT a mandatory part of the answer.
print(f'H_C0_C3 = {H_C0_C3}')H_C0_C3 = [[-0.30901699 -0.95105652 0. 0. ]
[ 0.95105652 -0.30901699 0. 0. ]
[ 0. 0. 1. 0.75 ]
[ 0. 0. 0. 1. ]]
Challenge 1¶
# Consider manipulator DoFs as the length of the following lists.
# Consider it as the configuration space of the RRR...RRR robot
q = [pi/2, pi/10, -pi/10, pi/2] # Increase length of q if you'd like to check
l = [1, 2, 3, 4] # l must be same size of q
if len(q) != len(l):
raise Exception("q and l are not the same length")
def link_rotation(qi):
return np.array(
[[cos(qi), -sin(qi), 0],
[sin(qi), cos(qi), 0],
[0, 0, 1]])
def link_translation(li):
return np.array(
[[1, 0, li],
[0, 1, 0],
[0, 0, 1]])
H = np.eye(3)
for qi, li in zip(q, l):
H = H @ link_rotation(qi) @ link_translation(li)
# Printing the result is NOT a mandatory part of the answer.
print(f"Final answer is {H}")Final answer is [[-1.00000000e+00 -1.28674811e-16 -4.61803399e+00]
[ 1.02095262e-16 -1.00000000e+00 5.90211303e+00]
[ 0.00000000e+00 0.00000000e+00 1.00000000e+00]]