v9.1.1
Menu

Range-Bearing Observation

Compute the expected range and bearing observation of a landmark from a robot pose.

In SLAM, robots often observe landmarks using range-bearing sensors (like lidar). Given the robot pose and landmark position, we predict what the sensor should observe:

r=(lx−x)2+(ly−y)2r = \sqrt{(l_x - x)^2 + (l_y - y)^2} ϕ=arctan⁡2(ly−y,lx−x)−θ\phi = \arctan2(l_y - y, l_x - x) - \theta

where:

  • (x,y,θ)(x, y, \theta) is the robot pose
  • (lx,ly)(l_x, l_y) is the landmark position
  • rr is the range (distance to landmark)
  • ϕ\phi is the bearing (angle relative to robot heading)

This observation model is used in EKF-SLAM and particle filter SLAM.

Example

Input
observe_landmark([0, 0, 0], [3, 4])
Output
[5.0, 0.9273]
Reasoning

Robot at origin, landmark at (3, 4):

  1. Compute displacement: dx = 3-0 = 3, dy = 4-0 = 4
  2. Range: r = sqrt(3² + 4²) = sqrt(9 + 16) = sqrt(25) = 5
  3. Absolute angle: atan2(4, 3) ≈ 0.9273 rad (≈ 53°)
  4. Bearing: 0.9273 - 0 = 0.9273 (angle relative to heading) The landmark is 5 units away, about 53° to the left.

Constraints

  • pose: [x, y, theta] robot pose
  • landmark: [lx, ly] landmark world position
  • Return [range, bearing] 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.