Forward Kinematics of a DH Chain
Implement dh_chain(params), where params is an (n,4) array of rows , returning the 4x4 base-to-tool transform.
Examples
One link, a = 1: a pure translation along x
- Input
- dh_chain([[0, 0, 1, 0]])
- Output
- [[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
Two straight links: the reach adds up
- Input
- dh_chain([[0, 0, 1, 0], [0, 0, 1, 0]])
- Output
- [[1, 0, 0, 2], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
First joint at 90 degrees: the tip is at (0, 2), not (2, 0)
- Input
- dh_chain([[1.5707963267948966, 0, 1, 0], [0, 0, 1, 0]])
- Output
- [[0, -1, 0, 0], [1, 0, 0, 2], [0, 0, 1, 0], [0, 0, 0, 1]]
Hints
Hint 1
Use a matrix product rather than nested loops, and check which operand transposes.
Hint 2
Watch for this: multiplied the link transforms in reverse order.
Requirements
params: (n, 4) array, row i is [theta, d, a, alpha] for link iReturn (4, 4) product A_1 A_2 ... A_n
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
Industrial Robotics: Kinematics and Control · ~14 min
Industrial Robotics: Kinematics and Control · ~16 min
Industrial Robotics: Kinematics and Control · ~18 min
Industrial Robotics: Kinematics and Control · ~16 min
Where this shows up
6 employers weight this skill
4 autonomy companies, 2 defense companies. Top match scores 92.
import numpy as np
def dh_chain(params):
"""
Base-to-tool transform of a Denavit-Hartenberg chain.
Args:
params: (n, 4) array, row i is [theta, d, a, alpha] for link i
Returns:
(4, 4) product A_1 A_2 ... A_n
"""
# YOUR CODE HERE
pass