Dead-Reckoning Odometry Step

~16 mincode completion

Implement odometry_step(pose, v, omega, dt), where pose is [x, y, theta], returning the new [x, y, theta].

Examples

Straight ahead: the zero-omega branch, no division by zero

Input
odometry_step([0, 0, 0], 1, 0, 2)
Output
[2, 0, 0]

A quarter circle: the arc lands short of the Euler step in x and off the axis in y

Input
odometry_step([0, 0, 0], 1, 1.5707963267948966, 1)
Output
[0.63662, 0.63662, 1.5708]

A spin on the spot: the heading turns, the position does not

Input
odometry_step([1, 2, 0], 0, 1, 1)
Output
[1, 2, 1]

Hints

Hint 1

Convert the input with before doing elementwise work.

Hint 2

Watch for this: integrated with a straight line euler step at the old heading.

Requirements

  • pose: (3,) array [x, y, theta]

  • v: forward speed

  • omega: turn rate

  • : time step

  • Return (3,) array [x, y, theta], heading wrapped into (-pi, pi]

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 odometry_step(pose, v, omega, dt):
    """
    One exact arc integration of a differential-drive pose.

    Args:
        pose:  (3,) array [x, y, theta]
        v:     forward speed
        omega: turn rate
        dt:    time step

    Returns:
        (3,) array [x, y, theta], heading wrapped into (-pi, pi]
    """
    # 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.