GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
Classes | Public Types | Public Member Functions | List of all members
gtsam::Values Class Reference

#include <Values.h>

Classes

struct  ConstKeyValuePair
 A key-value pair, which you get by dereferencing iterators. More...
 
struct  deref_iterator
 
struct  KeyValuePair
 A key-value pair, which you get by dereferencing iterators. More...
 

Public Types

typedef std::shared_ptr< Valuesshared_ptr
 A shared_ptr to this class.
 
typedef std::shared_ptr< const Valuesconst_shared_ptr
 A const shared_ptr to this class.
 
typedef KeyValuePair value_type
 

Public Member Functions

void insert (Key j, const Value &val)
 
void insert (const Values &values)
 
template<typename ValueType >
void insert (Key j, const ValueType &val)
 
void insertDouble (Key j, double c)
 version for double
 
void update (Key j, const Value &val)
 
template<typename T >
void update (Key j, const T &val)
 
void update (const Values &values)
 
void insert_or_assign (Key j, const Value &val)
 If key j exists, update value, else perform an insert.
 
void insert_or_assign (const Values &values)
 
template<typename ValueType >
void insert_or_assign (Key j, const ValueType &val)
 Templated version to insert_or_assign a variable with the given j.
 
void erase (Key j)
 
KeyVector keys () const
 
KeySet keySet () const
 
Valuesoperator= (const Values &rhs)
 
void swap (Values &other)
 
void clear ()
 
size_t dim () const
 
std::map< Key, size_t > dims () const
 
VectorValues zeroVectors () const
 
template<class ValueType >
size_t count () const
 
template<class ValueType >
std::map< Key, ValueType > extract (const std::function< bool(Key)> &filterFcn=&_truePredicate< Key >) const
 
template<typename ValueType >
void update (Key j, const ValueType &val)
 
Constructors
 Values ()=default
 
 Values (const Values &other)
 
 Values (Values &&other)
 
 Values (std::initializer_list< ConstKeyValuePair > init)
 
 Values (const Values &other, const VectorValues &delta)
 
Testable
void print (const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
 
bool equals (const Values &other, double tol=1e-9) const
 
Standard Interface
template<typename ValueType >
const ValueType at (Key j) const
 
double atDouble (size_t key) const
 version for double
 
const Valueat (Key j) const
 
bool exists (Key j) const
 
template<typename ValueType >
const ValueType * exists (Key j) const
 
size_t size () const
 
bool empty () const
 
Iterator
deref_iterator begin () const
 
deref_iterator end () const
 
deref_iterator find (Key j) const
 
deref_iterator lower_bound (Key j) const
 
deref_iterator upper_bound (Key j) const
 
Manifold Operations
Values retract (const VectorValues &delta) const
 
void retractMasked (const VectorValues &delta, const KeySet &mask)
 
VectorValues localCoordinates (const Values &cp) const
 

Detailed Description

A non-templated config holding any types of Manifold-group elements. A values structure is a map from keys to values. It is used to specify the value of a bunch of variables in a factor graph. A Values is a values structure which can hold variables that are elements on manifolds, not just vectors. It then, as a whole, implements a aggregate type which is also a manifold element, and hence supports operations dim, retract, and localCoordinates.

Constructor & Destructor Documentation

◆ Values() [1/5]

gtsam::Values::Values ( )
default

Default constructor creates an empty Values class

◆ Values() [2/5]

gtsam::Values::Values ( const Values other)

Copy constructor duplicates all keys and values

◆ Values() [3/5]

gtsam::Values::Values ( Values &&  other)

Move constructor

◆ Values() [4/5]

gtsam::Values::Values ( std::initializer_list< ConstKeyValuePair init)

Constructor from initializer list. Example usage:

Values v = {{k1, genericValue(pose1)}, {k2, genericValue(point2)}};

◆ Values() [5/5]

gtsam::Values::Values ( const Values other,
const VectorValues delta 
)

Construct from a Values and an update vector: identical to other.retract(delta)

Member Function Documentation

◆ at() [1/2]

template<typename ValueType >
const ValueType Values::at ( Key  j) const

Retrieve a variable by key j. The type of the value associated with this key is supplied as a template argument to this function.

Parameters
jRetrieve the value associated with this key
Template Parameters
ValueTypeThe type of the value stored with this key, this method Throws DynamicValuesIncorrectType if this requested type is not correct. Dynamic matrices/vectors can be retrieved as fixed-size, but not vice-versa.
Returns
The stored value

◆ at() [2/2]

const Value& gtsam::Values::at ( Key  j) const

Retrieve a variable by key j. This version returns a reference to the base Value class, and needs to be casted before use.

Parameters
jRetrieve the value associated with this key
Returns
A const reference to the stored value

◆ clear()

void gtsam::Values::clear ( )
inline

Remove all variables from the config

◆ dim()

size_t gtsam::Values::dim ( ) const

Compute the total dimensionality of all values ( \( O(n) \))

◆ dims()

std::map<Key,size_t> gtsam::Values::dims ( ) const

Return all dimensions in a map ( \( O(n log n) \))

◆ empty()

bool gtsam::Values::empty ( ) const
inline

whether the config is empty

◆ equals()

bool gtsam::Values::equals ( const Values other,
double  tol = 1e-9 
) const

Test whether the sets of keys and values are identical

◆ erase()

void gtsam::Values::erase ( Key  j)

Remove a variable from the config, throws KeyDoesNotExist<J> if j is not present

◆ exists() [1/2]

bool gtsam::Values::exists ( Key  j) const

Check if a value exists with key j. See exists<>(Key j) and exists(const TypedKey& j) for versions that return the value if it exists.

◆ exists() [2/2]

template<typename ValueType >
const ValueType * Values::exists ( Key  j) const

Check if a value with key j exists, returns a pointer to the const version of the value Value if the key does exist, or nullptr if it does not exist. Throws DynamicValuesIncorrectType if the value type associated with the requested key does not match the stored value type.

◆ extract()

template<class ValueType >
std::map< Key, ValueType > Values::extract ( const std::function< bool(Key)> &  filterFcn = &_truePredicate<Key>) const

Extract a subset of values of the given type ValueType.

In this templated version, only key-value pairs whose value matches the template argument ValueType and whose key causes the function argument filterFcn to return true are visited when iterating over the filtered view. This replaces the fancier but very boost-dependent filter methods that were previously available up to GTSAM 4.2.

Template Parameters
ValueTypeThe type that the value in a key-value pair must match to be included in the filtered view. Currently, base classes are not resolved so the type must match exactly, except if ValueType = Value, in which case no type filtering is done.
Parameters
filterFcnThe function that determines which key-value pairs are included in the filtered view, for which this function returns true on their keys (default: always return true so that filter() only filters by type, matching ValueType).
Returns
An Eigen aligned map on Key with the filtered values.

◆ find()

deref_iterator gtsam::Values::find ( Key  j) const
inline

Find an element by key, returning an iterator, or end() if the key was not found.

◆ insert() [1/3]

void gtsam::Values::insert ( Key  j,
const Value val 
)

Add a variable with the given j, throws KeyAlreadyExists<J> if j is already present

◆ insert() [2/3]

void gtsam::Values::insert ( const Values values)

Add a set of variables, throws KeyAlreadyExists<J> if a key is already present

◆ insert() [3/3]

template<typename ValueType >
void Values::insert ( Key  j,
const ValueType &  val 
)

Templated version to add a variable with the given j, throws KeyAlreadyExists<J> if j is already present

◆ insert_or_assign()

void gtsam::Values::insert_or_assign ( const Values values)

Update a set of variables. If any variable key doe not exist, then perform an insert.

◆ keys()

KeyVector gtsam::Values::keys ( ) const

Returns a vector of keys in the config. Note: by construction, the list is ordered

◆ keySet()

KeySet gtsam::Values::keySet ( ) const

Returns a set of keys in the config.

◆ localCoordinates()

VectorValues gtsam::Values::localCoordinates ( const Values cp) const

Get a delta config about a linearization point c0 (*this)

◆ lower_bound()

deref_iterator gtsam::Values::lower_bound ( Key  j) const
inline

Find the element greater than or equal to the specified key.

◆ operator=()

Values& gtsam::Values::operator= ( const Values rhs)

Replace all keys and variables

◆ print()

void gtsam::Values::print ( const std::string &  str = "",
const KeyFormatter keyFormatter = DefaultKeyFormatter 
) const

print method for testing and debugging

◆ retract()

Values gtsam::Values::retract ( const VectorValues delta) const

Add a delta config to current config and returns a new config

◆ retractMasked()

void gtsam::Values::retractMasked ( const VectorValues delta,
const KeySet mask 
)

Retract, but only for Keys appearing in mask. In-place.

Parameters
maskMask on Keys where to apply retract.

◆ size()

size_t gtsam::Values::size ( ) const
inline

The number of variables in this config

◆ swap()

void gtsam::Values::swap ( Values other)
inline

Swap the contents of two Values without copying data

◆ update() [1/3]

void gtsam::Values::update ( Key  j,
const Value val 
)

single element change of existing element

◆ update() [2/3]

template<typename T >
void gtsam::Values::update ( Key  j,
const T &  val 
)

Templated version to update a variable with the given j, throws KeyDoesNotExist<J> if j is not present. If no chart is specified, the DefaultChart<ValueType> is used.

◆ update() [3/3]

void gtsam::Values::update ( const Values values)

update the current available values without adding new ones

◆ upper_bound()

deref_iterator gtsam::Values::upper_bound ( Key  j) const
inline

Find the lowest-ordered element greater than the specified key.

◆ zeroVectors()

VectorValues gtsam::Values::zeroVectors ( ) const

Return a VectorValues of zero vectors for each variable in this Values


The documentation for this class was generated from the following files: