v9.1.1
Menu

Odometry Pose Update

Update a robot's 2D pose given odometry measurements.

In mobile robotics, odometry estimates motion from wheel encoders or visual odometry. The standard 2D motion model is:

(x′y′θ′)=(x+d⋅cos⁡(θ)y+d⋅sin⁡(θ)θ+δθ)\begin{pmatrix} x' \\ y' \\ \theta' \end{pmatrix} = \begin{pmatrix} x + d \cdot \cos(\theta) \\ y + d \cdot \sin(\theta) \\ \theta + \delta\theta \end{pmatrix}

where:

  • (x,y,θ)(x, y, \theta) is the current pose (position and heading)
  • dd is the distance traveled forward
  • δθ\delta\theta is the change in heading
  • (x′,y′,θ′)(x', y', \theta') is the new pose

This "dead reckoning" accumulates error over time, which is why SLAM also uses landmarks.

Example

Input
odometry_update([0, 0, 0], (1, 0))
Output
[1.0, 0.0, 0]
Reasoning
  • Inputs: pose is the robot's current state (x,y,θ)=(0,0,0)(x, y, \theta) = (0, 0, 0): it sits at the origin with heading θ=0\theta = 0 rad, i.e. facing along the positive xx-axis. motion is (d,δθ)=(1,0)(d, \delta\theta) = (1, 0): drive 1 unit forward, then turn by 0 rad.
  • Splitting the step: the forward distance is projected onto the axes by the heading. With cos⁡0=1\cos 0 = 1 and sin⁡0=0\sin 0 = 0, all of it goes into xx: x′=0+1⋅1=1x' = 0 + 1 \cdot 1 = 1 and y′=0+1⋅0=0y' = 0 + 1 \cdot 0 = 0.
  • Heading: θ′=θ+δθ=0+0=0\theta' = \theta + \delta\theta = 0 + 0 = 0, so the robot still faces along xx.
  • Output: the new pose [1.0, 0.0, 0], each entry rounded to 4 decimal places. The positions are decimals because they came out of the trigonometry; the heading is a plain sum of two whole numbers.
  • Notice: the step uses the old heading. Had the robot started at θ=π/2\theta = \pi/2 (facing up), the same 1-unit move would land at (0,1)(0, 1) instead, since cos⁡π2=0\cos\tfrac{\pi}{2} = 0 and sin⁡π2=1\sin\tfrac{\pi}{2} = 1.

Constraints

  • pose: [x, y, theta] current pose (theta in radians)
  • motion: (distance, delta_theta) odometry measurement
  • Return new pose [x', y', theta'] rounded to 4 decimal places

Learn this in

More from CV: Structure from Motion and SLAM

PRO

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test results

Sign in to run your code against the test cases.