Gravity Torque of a 2-Link Arm
Implement gravity_torque(l1, l2, m1, m2, q1, q2, g) returning the array [tau1, tau2].
Examples
Stretched horizontally: the worst case for both motors
- Input
- gravity_torque(1, 1, 1, 1, 0, 0, 10)
- Output
- [20, 5]
Straight up: the load is balanced and both torques vanish
- Input
- gravity_torque(1, 1, 1, 1, 1.5707963267948966, 0, 10)
- Output
- [0, 0]
Link 2 folded vertical: joint 2 is free, joint 1 still carries link 1
- Input
- gravity_torque(1, 1, 1, 1, 0, 1.5707963267948966, 10)
- Output
- [15, 0]
Hints
Hint 1
Convert the input with before doing elementwise work.
Hint 2
Reach for the half length to the centre of mass rather than the full link length.
Requirements
g: gravitational accelerationReturn (2,) array [tau1, tau2]
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
Industrial Robotics: Kinematics and Control · ~16 min
Industrial Robotics: Kinematics and Control · ~14 min
Industrial Robotics: Kinematics and Control · ~16 min
Industrial Robotics: Kinematics and Control · ~18 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 gravity_torque(l1, l2, m1, m2, q1, q2, g):
"""
Static torques needed to hold a 2-link arm against gravity.
Masses are point masses at the midpoint of each link, gravity acts
along -y.
Args:
l1, l2: link lengths
m1, m2: link masses
q1, q2: joint angles in radians
g: gravitational acceleration
Returns:
(2,) array [tau1, tau2]
"""
# YOUR CODE HERE
pass