Loading...
Searching...
No Matches
LabeledSymbol.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <functional>
#include <gtsam/inference/Symbol.h>
namespace gtsam {
class GTSAM_EXPORT LabeledSymbol {
protected:
unsigned char c_, label_;
std::uint64_t j_;
public:
LabeledSymbol();
LabeledSymbol(const LabeledSymbol& key);
LabeledSymbol(unsigned char c, unsigned char label, std::uint64_t j);
LabeledSymbol(gtsam::Key key);
operator gtsam::Key() const;
// Testable Requirements
void print(const std::string& s = "") const;
bool equals(const LabeledSymbol& expected, double tol = 0.0) const {
return (*this) == expected;
}
gtsam::Key key() const { return (gtsam::Key) *this; }
inline unsigned char label() const { return label_; }
inline unsigned char chr() const { return c_; }
inline size_t index() const { return j_; }
operator std::string() const;
bool operator<(const LabeledSymbol& comp) const;
bool operator==(const LabeledSymbol& comp) const;
bool operator==(gtsam::Key comp) const;
bool operator!=(const LabeledSymbol& comp) const;
bool operator!=(gtsam::Key comp) const;
// Checks only the type
static std::function<bool(gtsam::Key)> TypeTest(unsigned char c);
// Checks only the robot ID (label_)
static std::function<bool(gtsam::Key)> LabelTest(unsigned char label);
// Checks both type and the robot ID
static std::function<bool(gtsam::Key)> TypeLabelTest(unsigned char c, unsigned char label);
// Converts to upper/lower versions of labels
LabeledSymbol upper() const { return LabeledSymbol(c_, toupper(label_), j_); }
LabeledSymbol lower() const { return LabeledSymbol(c_, tolower(label_), j_); }
// Create a new symbol with a different character.
LabeledSymbol newChr(unsigned char c) const { return LabeledSymbol(c, label_, j_); }
// Create a new symbol with a different label.
LabeledSymbol newLabel(unsigned char label) const { return LabeledSymbol(c_, label, j_); }
friend GTSAM_EXPORT std::ostream &operator<<(std::ostream &, const LabeledSymbol &);
private:
friend class boost::serialization::access;
template<class ARCHIVE>
void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
ar & BOOST_SERIALIZATION_NVP(c_);
ar & BOOST_SERIALIZATION_NVP(label_);
ar & BOOST_SERIALIZATION_NVP(j_);
}
}; // \class LabeledSymbol
inline Key mrsymbol(unsigned char c, unsigned char label, size_t j) {
return (Key)LabeledSymbol(c,label,j);
}
inline unsigned char mrsymbolChr(Key key) { return LabeledSymbol(key).chr(); }
inline unsigned char mrsymbolLabel(Key key) { return LabeledSymbol(key).label(); }
inline size_t mrsymbolIndex(Key key) { return LabeledSymbol(key).index(); }
template<> struct traits<LabeledSymbol> : public Testable<LabeledSymbol> {};
} // \namespace gtsam
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::mrsymbolChr
unsigned char mrsymbolChr(Key key)
Return the character portion of a symbol key.
Definition LabeledSymbol.h:131
gtsam::mrsymbolIndex
size_t mrsymbolIndex(Key key)
Return the index portion of a symbol key.
Definition LabeledSymbol.h:137
gtsam::mrsymbolLabel
unsigned char mrsymbolLabel(Key key)
Return the label portion of a symbol key.
Definition LabeledSymbol.h:134
gtsam::operator!=
bool operator!=(const Matrix &A, const Matrix &B)
inequality
Definition Matrix.h:134
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
gtsam::mrsymbol
Key mrsymbol(unsigned char c, unsigned char label, size_t j)
Create a symbol key from a character, label and index, i.e.
Definition LabeledSymbol.h:126
gtsam::operator==
bool operator==(const Matrix &A, const Matrix &B)
equality is just equal_with_abs_tol 1e-9
Definition Matrix.h:127
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::LabeledSymbol
Customized version of gtsam::Symbol for multi-robot use.
Definition LabeledSymbol.h:35
gtsam::LabeledSymbol::LabeledSymbol
LabeledSymbol()
Default constructor.
Definition LabeledSymbol.cpp:29
gtsam::LabeledSymbol::chr
unsigned char chr() const
Retrieve key character.
Definition LabeledSymbol.h:70
gtsam::LabeledSymbol::key
gtsam::Key key() const
return the integer version
Definition LabeledSymbol.h:64
gtsam::LabeledSymbol::index
size_t index() const
Retrieve key index.
Definition LabeledSymbol.h:73
gtsam::LabeledSymbol::label
unsigned char label() const
Retrieve label character.
Definition LabeledSymbol.h:67
Symbol.h