Forward Kinematics of a 2-Link Arm
~10 mincode completion
Implement fk_2link(l1, l2, q1, q2) returning the array [x, y].
Examples
Both joints at zero: the arm lies along x
- Input
- fk_2link(1, 2, 0, 0)
- Output
- [3, 0]
q1 = pi/2, q2 = 0: straight up
- Input
- fk_2link(1, 2, 1.5707963267948966, 0)
- Output
- [0, 3]
q1 = 0, q2 = pi/2: an L shape
- Input
- fk_2link(1, 2, 0, 1.5707963267948966)
- Output
- [1, 2]
Hints
Hint 1
Convert the input with before doing elementwise work.
Hint 2
Reach for q1 plus q2 for the second link rather than q2 alone.
Requirements
Return array [x, y]
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
IntroEasyEasyEasy
Build a Homogeneous Transform
Pro
Industrial Robotics: Kinematics and Control · ~8 min
Roll, Pitch, Yaw to a Rotation Matrix
Pro
Industrial Robotics: Kinematics and Control · ~12 min
Cubic Joint Trajectory
Pro
Industrial Robotics: Kinematics and Control · ~12 min
Invert a Homogeneous Transform
Pro
Industrial Robotics: Kinematics and Control · ~10 min
Where this shows up
~10 min
••••••••••••
6 employers weight this skill
4 autonomy companies, 2 defense companies. Top match scores 93.
Python
import numpy as np
def fk_2link(l1, l2, q1, q2):
"""
End-effector position of a planar two-link arm.
Args:
l1, l2: link lengths
q1, q2: joint angles in radians (q2 relative to link 1)
Returns:
array [x, y]
"""
# YOUR CODE HERE
pass