25 using namespace gtsam;
27 int main(
const int argc,
const char *argv[]) {
39 std::tie(graph, initial) =
readG2o(g2oFile, is3D);
42 Key firstKey = 8646911284551352320;
44 std::cout <<
"Using reference key: " << firstKey << std::endl;
46 std::cout <<
"adding key " << std::endl;
48 std::cout <<
"subtracting key " << std::endl;
52 std::cout <<
"Please provide output file to write " << std::endl;
54 const string inputFileRewritten = argv[2];
55 std::cout <<
"Rewriting input to file: " << inputFileRewritten << std::endl;
58 for (
const auto k : initial->keys()) {
65 simpleInitial.
insert(key, initial->at(k));
68 for(
const std::shared_ptr<NonlinearFactor>& factor: *graph) {
69 std::shared_ptr<BetweenFactor<Pose3> > pose3Between =
74 key1 = pose3Between->
key<1>() + firstKey;
75 key2 = pose3Between->key<2>() + firstKey;
77 key1 = pose3Between->key<1>() - firstKey;
78 key2 = pose3Between->key<2>() - firstKey;
80 NonlinearFactor::shared_ptr simpleFactor(
82 simpleGraph.
add(simpleFactor);
85 writeG2o(simpleGraph, simpleInitial, inputFileRewritten);
const gtsam::Symbol key('X', 0)
void writeG2o(const NonlinearFactorGraph &graph, const Values &estimate, const std::string &filename)
This function writes a g2o file from NonlinearFactorGraph and a Values structure. ...
NonlinearFactorGraph graph
IsDerived< DERIVEDFACTOR > add(std::shared_ptr< DERIVEDFACTOR > factor)
add is a synonym for push_back.
int main(const int argc, const char *argv[])
const Symbol key1('v', 1)
GraphAndValues readG2o(const std::string &g2oFile, const bool is3D, KernelFunctionType kernelFunctionType)
This function parses a g2o file and stores the measurements into a NonlinearFactorGraph and the initi...
GTSAM_EXPORT std::string findExampleDataFile(const std::string &name)
std::shared_ptr< This > shared_ptr
graph add(PriorFactor< Pose2 >(1, priorMean, priorNoise))
void insert(Key j, const Value &val)
utility functions for loading datasets
std::uint64_t Key
Integer nonlinear key type.
const Symbol key2('v', 2)