PIXELBANKv9.1.0
Menu

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
πŸ”’

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

0/0
Run code to see test results.
Range-Bearing Observation - Medium | PixelBank