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.

Symbol

A Symbol is a GTSAM class used to create semantically meaningful keys (gtsam.Key) for variables. It combines a character (unsigned char) and an index (uint64_t) into a single 64-bit integer key. This allows for easy identification of variable types and their indices, e.g., ‘x’ for poses and ‘l’ for landmarks, like x0, x1, l0.

Open In Colab

Initialization

A Symbol can be created by providing a character and an index. It can also be created by decoding an existing gtsam.Key (integer).

Symbol from char/index: x5
Symbol from key 8646911284551352325: x5

Properties and Usage

You can access the character, index, and underlying integer key.

Symbol: l10
  Char: 108
  Index: 10
  Key: 7782220156096217098

Shorthand Functions

GTSAM provides convenient shorthand functions X(j), L(j), etc., which are equivalent to gtsam.Symbol('x', j), gtsam.Symbol('l', j). To use these, first import with from gtsam import symbol_shorthand, then set up the variables you want to use with statements like X = symbol_shorthand.X.

Symbol('x', 0).key() == X(0): True
Symbol('l', 1).key() == L(1): True