25 using namespace gtsam;
27 int main(
const int argc,
const char *argv[]) {
39 boost::tie(graph, initial) =
readG2o(g2oFile, is3D);
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 key_value: *initial) {
65 simpleInitial.
insert(key, initial->at(key_value.key));
68 for(
const boost::shared_ptr<NonlinearFactor>& factor: *graph) {
69 boost::shared_ptr<BetweenFactor<Pose3> > pose3Between =
74 key1 = pose3Between->key1() +
firstKey;
75 key2 = pose3Between->key2() +
firstKey;
77 key1 = pose3Between->key1() -
firstKey;
78 key2 = pose3Between->key2() -
firstKey;
82 simpleGraph.
add(simpleFactor);
85 writeG2o(simpleGraph, simpleInitial, inputFileRewritten);
void writeG2o(const NonlinearFactorGraph &graph, const Values &estimate, const string &filename)
This function writes a g2o file from NonlinearFactorGraph and a Values structure. ...
void insert(Key j, const Value &val)
IsDerived< DERIVEDFACTOR > add(boost::shared_ptr< DERIVEDFACTOR > factor)
add is a synonym for push_back.
NonlinearFactorGraph graph
graph add(boost::make_shared< UnaryFactor >(1, 0.0, 0.0, unaryNoise))
string findExampleDataFile(const string &name)
const Symbol key1('v', 1)
int main(const int argc, const char *argv[])
boost::shared_ptr< This > shared_ptr
boost::shared_ptr< This > shared_ptr
const Symbol key2('v', 2)
GraphAndValues readG2o(const string &g2oFile, const bool is3D, KernelFunctionType kernelFunctionType)
This function parses a g2o file and stores the measurements into a NonlinearFactorGraph and the initi...
utility functions for loading datasets
std::uint64_t Key
Integer nonlinear key type.