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.

Pose2 SLAM Stress Test

Open In Colab

This stress test creates a large chain of poses to test GTSAM’s performance on open-loop SLAM problems. The test:

  1. Creates N 3D poses with unit translation (1, 0, 0) between consecutive poses

  2. Adds random noise to the x value of each pose’s translation

  3. Creates a prior factor for the first pose

  4. Adds N-1 between factors for consecutive poses

  5. Runs optimization using Levenberg-Marquardt

This tests GTSAM’s ability to handle large sparse factor graphs efficiently.

Stress Test Function

Main Execution

Invalid number of nodes. Using default value of 1000.
Running Pose2 SLAM Stress Test with 1000 nodes
Creating stress test with 1000 nodes...
Created factor graph with 1000 factors
Starting optimization...
Initial error: 810.02902132Optimization completed in 0.020 seconds
Initial error: 810.029021
Final error: 0.000000

Stress test completed successfully!
Performance: 49290.2 nodes per second

newError: 7.18522916506e-11
errorThreshold: 7.18522916506e-11 > 0
absoluteDecrease: 810.02902132 >= 1e-05
relativeDecrease: 1 >= 1e-05
newError: 1.1004643035e-17
errorThreshold: 1.1004643035e-17 > 0
absoluteDecrease: 7.1852280646e-11 < 1e-05
relativeDecrease: 0.999999846844 >= 1e-05
converged
errorThreshold: 1.1004643035e-17 <? 0
absoluteDecrease: 7.1852280646e-11 <? 1e-05
relativeDecrease: 0.999999846844 <? 1e-05
iterations: 2 >? 100

Interactive Example

You can run the stress test with different numbers of nodes to see how GTSAM performs with increasing problem size.

Running stress tests with different problem sizes:
==================================================

Testing with 100 nodes:
Creating stress test with 100 nodes...
Created factor graph with 100 factors
Starting optimization...
Optimization completed in 0.007 seconds
Initial error: 73.785267
Final error: 0.000000
Rate: 14021.2 nodes/second

Testing with 500 nodes:
Creating stress test with 500 nodes...
Initial error: 73.7852667959
Created factor graph with 500 factors
Starting optimization...
newError: 3.19648178005e-14
errorThreshold: 3.19648178005e-14 > 0
absoluteDecrease: 73.7852667959 >= 1e-05
relativeDecrease: 1 >= 1e-05
newError: 3.26892942612e-25
errorThreshold: 3.26892942612e-25 > 0
absoluteDecrease: 3.19648178002e-14 < 1e-05
relativeDecrease: 0.99999999999 >= 1e-05
converged
errorThreshold: 3.26892942612e-25 <? 0
absoluteDecrease: 3.19648178002e-14 <? 1e-05
relativeDecrease: 0.99999999999 <? 1e-05
iterations: 2 >? 100
Initial error: 403.93736772
newError: 1.44414083181e-12
errorThreshold: 1.44414083181e-12 > 0
absoluteDecrease: 403.93736772 >= 1e-05
relativeDecrease: 1 >= 1e-05
newError: 1.00814883652e-20
errorThreshold: 1.00814883652e-20 > 0
absoluteDecrease: 1.44414082173e-12 < 1e-05
relativeDecrease: 0.999999993019 >= 1e-05
converged
errorThreshold: 1.00814883652e-20 <? 0
absoluteDecrease: 1.44414082173e-12 <? 1e-05
relativeDecrease: 0.999999993019 <? 1e-05
iterations: 2 >? 100
Optimization completed in 0.023 seconds
Initial error: 403.937368
Final error: 0.000000
Rate: 21542.6 nodes/second

Testing with 1000 nodes:
Creating stress test with 1000 nodes...
Created factor graph with 1000 factors
Starting optimization...
Initial error: 810.02902132
newError: 7.18522916506e-11
errorThreshold: 7.18522916506e-11 > 0
absoluteDecrease: 810.02902132 >= 1e-05
relativeDecrease: 1 >= 1e-05
newError: 1.1004643035e-17
errorThreshold: 1.1004643035e-17 > 0
absoluteDecrease: 7.1852280646e-11 < 1e-05
relativeDecrease: 0.999999846844 >= 1e-05
converged
errorThreshold: 1.1004643035e-17 <? 0
absoluteDecrease: 7.1852280646e-11 <? 1e-05
relativeDecrease: 0.999999846844 <? 1e-05
iterations: 2 >? 100
Optimization completed in 0.041 seconds
Initial error: 810.029021
Final error: 0.000000
Rate: 24680.9 nodes/second

Testing with 2000 nodes:
Creating stress test with 2000 nodes...
Created factor graph with 2000 factors
Starting optimization...
Initial error: 1629.41004549
newError: 6.70560309189e-11
errorThreshold: 6.70560309189e-11 > 0
absoluteDecrease: 1629.41004549 >= 1e-05
relativeDecrease: 1 >= 1e-05
newError: 1.51418327449e-16
errorThreshold: 1.51418327449e-16 > 0
absoluteDecrease: 6.70558795006e-11 < 1e-05
relativeDecrease: 0.999997741913 >= 1e-05
converged
errorThreshold: 1.51418327449e-16 <? 0
absoluteDecrease: 6.70558795006e-11 <? 1e-05
relativeDecrease: 0.999997741913 <? 1e-05
iterations: 2 >? 100
Optimization completed in 0.040 seconds
Initial error: 1629.410045
Final error: 0.000000
Rate: 50276.6 nodes/second