Cubic Joint Trajectory

~12 mincode completion

Implement cubic_trajectory(q0, qf, T, t) returning the array [q, qdot] at time .

Examples

At t = 0 the joint is at q0 and at rest

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

At t = T the joint is at qf and at rest

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

At the midpoint: halfway there, peak velocity 1.5 * delta / T

Input
cubic_trajectory(0, 2, 4, 2)
Output
[1, 0.75]

Hints

Hint 1

Convert the input with before doing elementwise work.

Hint 2

Watch for this: used linear interpolation.

Requirements

  • : duration

  • : time in [0, T]

  • Return array [q, qdot]

Constraints

  • Allowed library: NumPy only

  • Time limit: 200 ms, Memory: 64 MB

Where this shows up

~12 min

6 employers weight this skill

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

Python
import numpy as np


def cubic_trajectory(q0, qf, T, t):
    """
    Position and velocity on a rest-to-rest cubic.

    Args:
        q0, qf: start and end joint positions
        T:      duration
        t:      time in [0, T]

    Returns:
        array [q, qdot]
    """
    # 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.