Skip to article frontmatterSkip to article content

GTSAM Concepts

GTSAM is built upon a foundation of generic programming, using C++ concepts to define the requirements for types used in optimization and modeling. A “concept” is a set of requirements that a type must fulfill to be used with GTSAM’s generic algorithms. These requirements can include associated types, specific methods, and mathematical invariants.

This document provides a high-level overview of the most important concepts in GTSAM. For detailed instructions on how to implement a custom class that satisfies these concepts, please refer to the specific guides in the gtsam/base/doc/ directory.

GTSAM uses two primary mechanisms to connect user-defined types to its framework:

  1. Traits-based Metaprogramming: Instead of traditional inheritance, you specialize a gtsam::traits struct for your class. This specialization informs GTSAM about the capabilities and properties of your type.
  2. Concept Checking Macros: GTSAM provides compile-time macros (e.g., GTSAM_CONCEPT_MANIFOLD_INST) that verify your class correctly implements all requirements of a concept.

Testable

Nearly every concept in GTSAM requires the Testable concept as a prerequisite. This provides a common interface for unit testing. To be Testable, a class must provide two methods:

The detailed guides for each concept explain this requirement further.

Manifold

A differentiable manifold is a non-linear space that can be locally approximated at any point by a vector space, known as the tangent space. This is the most fundamental concept for non-linear optimization in GTSAM.

The core operations for a manifold are:

These operations must be inverses of each other: p.retract(p.localCoordinates(q)) should be equal to q.

For a detailed guide on creating a new Manifold type, see Creating a Manifold Class.

Group

A group is an algebraic structure with a composition operation that is associative, has an identity element, and for which every element has an inverse.

Key operations are compose, inverse, and between. GTSAM distinguishes between two “flavors” of groups based on their composition operator:

For a detailed guide on creating a Group type, see Guide to Creating a Group.

Lie Group

A Lie group is a space that is both a Group and a Manifold, with the added requirement that the group operations are smooth. This is the central concept for representing poses and rotations in robotics and computer vision.

Lie groups have a special identity element, which allows for defining global Expmap and Logmap operations that map between the manifold and its tangent space at the identity. In GTSAM, implementing a LieGroup is often simplified by inheriting from a Curiously Recurring Template Pattern (CRTP) base class, which provides many methods for free.

Most Lie groups in GTSAM are also Matrix Lie Groups, which have an underlying matrix representation. These require additional Lie algebra operations like Hat and Vee.

Vector Space

A VectorSpace is a specialized AdditiveGroup that also supports scalar multiplication, a dot product, and the calculation of a norm. This concept should be satisfied by types that behave like mathematical vectors. In GTSAM, vector spaces are the foundation for tangent spaces on manifolds.

For a detailed guide, see Creating a VectorSpace.

Overview

The Mermaid diagram below summarizes the relationships between the different geometry concepts:


Future Concepts

The concepts below describe more advanced usage patterns, such as the action of a group on a manifold.

Group Action

Group actions are concepts in and of themselves. In particular, a group can act on another space. We formalize this by the following extension of the concept:

Lie Group Action

When a Lie group acts on a space, we have two derivatives to care about:

An example is a similarity transform in 3D, which can act on 3D space. The derivative in p, Hp, depends on the group element g. The derivative in g, Hg, is in general more complex.