Jacobian of a 2-Link Arm

~14 mincode completion

Implement jacobian_2link(l1, l2, q1, q2) returning the 2x2 array.

Examples

Stretched along x: the x row is zero (singular)

Input
jacobian_2link(1, 2, 0, 0)
Output
[[0, 0], [3, 2]]

Straight up: the y row is zero instead

Input
jacobian_2link(1, 1, 1.5707963267948966, 0)
Output
[[-2, -1], [0, 0]]

The L shape: full rank

Input
jacobian_2link(1, 1, 0, 1.5707963267948966)
Output
[[-1, -1], [1, 0]]

Hints

Hint 1

Convert the input with before doing elementwise work.

Hint 2

Do not forget to the l2 sin q12 term in the first column. That step is easy to skip.

Requirements

  • Return (2, 2) array mapping [dq1, dq2] to [dx, dy]

Constraints

  • Allowed library: NumPy only

  • Time limit: 200 ms, Memory: 64 MB

Where this shows up

~14 min

6 employers weight this skill

4 autonomy companies, 2 defense companies. Top match scores 93.

Python
import numpy as np


def jacobian_2link(l1, l2, q1, q2):
    """
    Geometric Jacobian of the planar two-link arm.

    Args:
        l1, l2: link lengths
        q1, q2: joint angles in radians

    Returns:
        (2, 2) array mapping [dq1, dq2] to [dx, dy]
    """
    # YOUR CODE HERE
    pass
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.