print variants for KeyList, KeyVector
parent
9395bb0913
commit
2649b0fd7a
8
gtsam.h
8
gtsam.h
|
@ -1551,8 +1551,12 @@ char symbolChr(size_t key);
|
||||||
size_t symbolIndex(size_t key);
|
size_t symbolIndex(size_t key);
|
||||||
|
|
||||||
// Default keyformatter
|
// Default keyformatter
|
||||||
void printKeySet(const gtsam::KeySet& keys);
|
void printKeyList (const gtsam::KeyList& keys);
|
||||||
void printKeySet(const gtsam::KeySet& keys, string s);
|
void printKeyList (const gtsam::KeyList& keys, string s);
|
||||||
|
void printKeyVector(const gtsam::KeyVector& keys);
|
||||||
|
void printKeyVector(const gtsam::KeyVector& keys, string s);
|
||||||
|
void printKeySet (const gtsam::KeySet& keys);
|
||||||
|
void printKeySet (const gtsam::KeySet& keys, string s);
|
||||||
|
|
||||||
#include <gtsam/inference/LabeledSymbol.h>
|
#include <gtsam/inference/LabeledSymbol.h>
|
||||||
class LabeledSymbol {
|
class LabeledSymbol {
|
||||||
|
|
|
@ -27,31 +27,48 @@
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
std::string _multirobotKeyFormatter(gtsam::Key key) {
|
std::string _multirobotKeyFormatter(Key key) {
|
||||||
const LabeledSymbol asLabeledSymbol(key);
|
const LabeledSymbol asLabeledSymbol(key);
|
||||||
if(asLabeledSymbol.chr() > 0 && asLabeledSymbol.label() > 0)
|
if (asLabeledSymbol.chr() > 0 && asLabeledSymbol.label() > 0)
|
||||||
return (std::string)asLabeledSymbol;
|
return (std::string) asLabeledSymbol;
|
||||||
|
|
||||||
const gtsam::Symbol asSymbol(key);
|
const Symbol asSymbol(key);
|
||||||
if (asLabeledSymbol.chr() > 0)
|
if (asLabeledSymbol.chr() > 0)
|
||||||
return (std::string)asSymbol;
|
return (std::string) asSymbol;
|
||||||
else
|
else
|
||||||
return boost::lexical_cast<std::string>(key);
|
return boost::lexical_cast<std::string>(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void printKeySet(const gtsam::KeySet& keys, const std::string& s, const KeyFormatter& keyFormatter) {
|
template<class CONTAINER>
|
||||||
|
static void print(const CONTAINER& keys, const std::string& s,
|
||||||
|
const KeyFormatter& keyFormatter) {
|
||||||
std::cout << s << " ";
|
std::cout << s << " ";
|
||||||
if (keys.empty())
|
if (keys.empty())
|
||||||
std::cout << "(none)" << std::endl;
|
std::cout << "(none)" << std::endl;
|
||||||
else {
|
else {
|
||||||
BOOST_FOREACH(const gtsam::Key& key, keys)
|
BOOST_FOREACH(const Key& key, keys)
|
||||||
std::cout << keyFormatter(key) << " ";
|
std::cout << keyFormatter(key) << " ";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void printKeyList(const KeyList& keys, const std::string& s,
|
||||||
|
const KeyFormatter& keyFormatter) {
|
||||||
|
print(keys, s, keyFormatter);
|
||||||
|
}
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void printKeyVector(const KeyVector& keys, const std::string& s,
|
||||||
|
const KeyFormatter& keyFormatter) {
|
||||||
|
print(keys, s, keyFormatter);
|
||||||
|
}
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void printKeySet(const KeySet& keys, const std::string& s,
|
||||||
|
const KeyFormatter& keyFormatter) {
|
||||||
|
print(keys, s, keyFormatter);
|
||||||
|
}
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
||||||
} // \namespace gtsam
|
} // \namespace gtsam
|
||||||
|
|
|
@ -46,6 +46,14 @@ namespace gtsam {
|
||||||
typedef FastSet<Key> KeySet;
|
typedef FastSet<Key> KeySet;
|
||||||
typedef FastMap<Key,int> KeyGroupMap;
|
typedef FastMap<Key,int> KeyGroupMap;
|
||||||
|
|
||||||
|
/// Utility function to print sets of keys with optional prefix
|
||||||
|
GTSAM_EXPORT void printKeyList(const KeyList& keys, const std::string& s = "",
|
||||||
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter);
|
||||||
|
|
||||||
|
/// Utility function to print sets of keys with optional prefix
|
||||||
|
GTSAM_EXPORT void printKeyVector(const KeyVector& keys, const std::string& s = "",
|
||||||
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter);
|
||||||
|
|
||||||
/// Utility function to print sets of keys with optional prefix
|
/// Utility function to print sets of keys with optional prefix
|
||||||
GTSAM_EXPORT void printKeySet(const KeySet& keys, const std::string& s = "",
|
GTSAM_EXPORT void printKeySet(const KeySet& keys, const std::string& s = "",
|
||||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter);
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter);
|
||||||
|
|
Loading…
Reference in New Issue