Damped Least-Squares Velocity Step

~16 mincode completion

Implement dls_joint_velocity(J, v, damping) returning as a 1D array.

Examples

Identity Jacobian, no damping: joint velocity equals task velocity

Input
dls_joint_velocity([[1, 0], [0, 1]], [1, 0], 0)
Output
[1, 0]

Identity Jacobian, lambda = 1: the step is halved

Input
dls_joint_velocity([[1, 0], [0, 1]], [1, 0], 1)
Output
[0.5, 0]

Singular Jacobian with damping: the unreachable direction is dropped, not amplified

Input
dls_joint_velocity([[1, 0], [0, 0]], [0, 1], 1)
Output
[0, 0]

Hints

Hint 1

Solve the linear system rather than inverting by hand.

Hint 2

Watch for this: inverted J directly and blew up at the singularity.

Requirements

  • J: (m, n) Jacobian

  • v: (m,) desired task-space velocity

  • damping: lambda >= 0

  • Return (n,) joint velocities

Constraints

  • Allowed library: NumPy only

  • Time limit: 200 ms, Memory: 64 MB

Where this shows up

~16 min

6 employers weight this skill

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

Python
import numpy as np


def dls_joint_velocity(J, v, damping):
    """
    Damped least-squares joint velocities for a task-space velocity.

    Args:
        J:       (m, n) Jacobian
        v:       (m,) desired task-space velocity
        damping: lambda >= 0

    Returns:
        (n,) joint velocities
    """
    # 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.