Registry / ai-ml / gtsam
library4.2.1pypypi✓ verified 84d ago

GTSAM is a C++ library for smoothing and mapping (SLAM and bundle adjustment) with Python bindings. Current version 4.2.1. Release cadence is irregular, roughly 1-2 major versions per year with minor patches as needed.

pip install gtsam
INSTALL
IMPORT
SIG · GTSAM
G
gtsam
ai-mlpythonv4.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gtsam
import gtsam
from gtsam import *
Wildcard import is discouraged; namespace may have conflicts.
gtsam.utils.plot
from gtsam.utils import plot
import gtsam.utils.plot as plot
Wrong: plotting module is a subpackage; correct import ensures plot functions are available.

Simple 2D pose graph SLAM with a single odometry constraint.

import gtsam import numpy as np # Create a factor graph and initial estimates graph = gtsam.NonlinearFactorGraph() initial = gtsam.Values() # Pose prior at origin prior_noise = gtsam.noiseModel.Diagonal.Sigmas(np.array([0.3, 0.3, 0.1])) graph.add(gtsam.PriorFactorPose2(1, gtsam.Pose2(0, 0, 0), prior_noise)) initial.insert(1, gtsam.Pose2(0.2, -0.3, 0.2)) # Odometry measurement odo_noise = gtsam.noiseModel.Diagonal.Sigmas(np.array([0.2, 0.2, 0.1])) graph.add(gtsam.BetweenFactorPose2(1, 2, gtsam.Pose2(2, 0, 0), odo_noise)) initial.insert(2, gtsam.Pose2(2.1, 0.1, -0.1)) # Optimize optimizer = gtsam.LevenbergMarquardtOptimizer(graph, initial) result = optimizer.optimize() print(result)
Debug
Known issues
breakingIn GTSAM 4.2.0+, the `DiscreteDistribution` API changed: `DiscreteDistribution` constructor no longer takes a `spec` argument; use `DiscreteDistribution.BayesNet`.
fix
Update code to use new API; see migration guide at https://gtsam.org/docs/4.2/migration.html
affects: >=4.2.0
gotchaUsing `opengtsam` prefix (e.g., `opengtsam.NonlinearFactorGraph`) is legacy and may be removed in future versions.
fix
Use `gtsam` directly, e.g., `gtsam.NonlinearFactorGraph`.
affects: >=4.2.0
gotchaSome Python `__init__.py` files may be missing in older installations, causing `ImportError: No module named gtsam.unstable`. Reinstall with `--no-cache-dir` if this occurs.
fix
pip install --no-cache-dir --force-reinstall gtsam
affects: <=4.1
deprecated`gtsam.ISAM2` is deprecated; use `gtsam.ISAM2Params` and `gtsam.ISAM2` with explicit parameters.
fix
Construct `ISAM2` using `gtsam.ISAM2(gtsam.ISAM2Params())`.
affects: >=4.2.0
Errors
Common errors & fixes
ImportError: cannot import name 'gtsam' from 'gtsam'
Conflicting local file named 'gtsam.py' in working directory shadowing the installed package.
fix
Rename or remove the local file 'gtsam.py'.
RuntimeError: The docstring of gtsam.Pose2 is not available. Install with 'pip install gtsam[docs]' or use -numpy.
Optional docstring extra not installed.
fix
pip install gtsam[docs]
Failed to import `gtsam.utils` due to missing `matplotlib`.
Matplotlib is not installed but required by `gtsam.utils.plot`.
fix
pip install matplotlib
TypeError: __init__() got an unexpected keyword argument 'some_param'
API change between GTSAM 4.1 and 4.2 for certain factor constructors or noise models.
fix
Check the API documentation for version 4.2 and adjust code accordingly.
Upgrade
Version history
4.2.1latest on PyPI · released May 1, 2026
Audit
Dependencies
numpyrequiredCore dependency for numerical operations and array handling
matplotliboptionalRequired for GTSAM's plotting utilities
Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
1
Resources
gtsam — pip install gtsam · libregistry