Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Range SLAM with Batch Optimization

A 2D Range SLAM example using batch optimization (Levenberg-Marquardt) on the Plaza2 dataset.

This notebook mirrors the functionality of the MATLAB batch SLAM script, adapted using Python and GTSAM, drawing structural elements from the iSAM example.

Author: Frank Dellaert (adapted for batch by AI)

Open In Colab

Data is second UWB ranging dataset, B2 or “plaza 2”, from

“Navigating with Ranging Radios: Five Data Sets with Ground Truth”, by Joseph Djugash, Bradley Hamner, and Stephan Roth, available at https://www.ri.cmu.edu/pub_files/2009/9/Final_5datasetsRangingRadios.pdf

Load Data

Read 4090 odometry entries.
Read 1816 range triples for 4 unique landmarks.

Set Parameters and Noise Models

Build Factor Graph and Initial Estimate

Initializing Landmarks...
Initialized 4 landmarks.

Building Pose Chain and Odometry Factors...
Added 4090 odometry factors and initial pose estimates.

Adding Range Factors...
Added 1816 range factors.

Optimize the Factor Graph


Optimizing the factor graph...
Initial error: 2.9e+02, values: 4095
iter      cost      cost_change    lambda  success iter_time
   0      1.4e+05     -1.4e+05      1e-05      1       0.03
iter      cost      cost_change    lambda  success iter_time
   0      9.1e+03     -8.8e+03     0.0001      1       0.03
iter      cost      cost_change    lambda  success iter_time
   0      1.9e+02        1e+02      0.001      1       0.03
   1      2.7e+03     -2.5e+03     0.0001      1       0.03
   1      1.1e+02           86      0.001      1       0.02
   2      1.7e+03     -1.6e+03     0.0001      1       0.02
   2           85           22      0.001      1       0.03
   3      6.3e+02     -5.5e+02     0.0001      1       0.03
   3           76          8.4      0.001      1       0.02
   4      3.1e+02     -2.3e+02     0.0001      1       0.02
   4           68          8.6      0.001      1       0.03
   5      1.9e+02     -1.2e+02     0.0001      1       0.03
   5           55           13      0.001      1       0.03
   6      2.6e+02       -2e+02     0.0001      1       0.02
   6           39           16      0.001      1       0.02
   7      1.4e+02          -99     0.0001      1       0.04
   7           26           13      0.001      1       0.03
   8           94          -68     0.0001      1       0.03
   8           21          5.5      0.001      1       0.03
   9           63          -43     0.0001      1       0.02
   9           19          2.1      0.001      1       0.02
  10           46          -27     0.0001      1       0.02
  10           17          1.8      0.001      1       0.03
  11           35          -18     0.0001      1       0.03
  11           15          1.5      0.001      1       0.03
  12           27          -12     0.0001      1       0.03
  12           14          1.3      0.001      1       0.02
  13           22         -7.9     0.0001      1       0.02
  13           13          1.2      0.001      1       0.03
  14           18         -5.2     0.0001      1       0.03
  14           12            1      0.001      1       0.03
  15           15         -3.3     0.0001      1       0.03
  15           11          0.9      0.001      1       0.02
  16           13           -2     0.0001      1       0.02
  16           10         0.79      0.001      1       0.04
  17           11         -1.1     0.0001      1       0.03
  17          9.3          0.7      0.001      1       0.03
  18          9.8        -0.44     0.0001      1       0.03
  18          8.7         0.62      0.001      1       0.02
  19          8.7        0.023     0.0001      1       0.02
  20           67          -58      1e-05      1       0.02
  20            5          3.7     0.0001      1       0.03
  21           23          -18      1e-05      1       0.03
  21          3.5          1.4     0.0001      1       0.03
  22          9.4         -5.9      1e-05      1       0.03
  22            3         0.57     0.0001      1       0.03
  23            5           -2      1e-05      1       0.03
  23          2.6         0.34     0.0001      1       0.02
  24          3.3        -0.71      1e-05      1       0.02
  24          2.4         0.26     0.0001      1       0.03
  25          2.6        -0.19      1e-05      1       0.03
  25          2.2         0.21     0.0001      1       0.03
  26          2.1        0.034      1e-05      1       0.03
  27          3.7         -1.5      1e-06      1       0.03
  27          1.1            1      1e-05      1       0.02
  28          1.4        -0.24      1e-06      1       0.04
  28         0.93          0.2      1e-05      1       0.03
  29         0.96       -0.031      1e-06      1       0.04
  29         0.88        0.048      1e-05      1       0.09
  30         0.88      0.00063      1e-06      1       0.03
Optimization complete in 1.93 seconds.
Initial Error: 294.2927831483431
Final Error: 0.8771120075818397

Optimized Landmark Locations:
  L0: [-48.11741249  31.92467992]
  L1: [-80.92811295  53.95372591]
  L5: [-47.60339748 -19.97294509]
  L6: [-17.70157972  66.35356579]

Extracted 4091 final poses and 4 landmarks.
Loading...