26 using namespace gtsam;
28 int main(
const int argc,
const char* argv[]) {
39 std::tie(graph, initial) =
readG2o(g2oFile, is3D);
42 auto priorModel = noiseModel::Diagonal::Variances(
43 (
Vector(6) << 1
e-6, 1
e-6, 1
e-6, 1
e-4, 1
e-4, 1
e-4).finished());
45 for (
const auto key : initial->keys()) {
46 std::cout <<
"Adding prior to g2o file " << std::endl;
48 graph->addPrior(firstKey,
Pose3(), priorModel);
52 std::cout <<
"Initializing Pose3 - chordal relaxation" << std::endl;
54 std::cout <<
"done!" << std::endl;
57 initialization.
print(
"initialization");
60 std::cout <<
"Writing results to file: " << outputFile << std::endl;
63 std::tie(graphNoKernel, initial2) =
readG2o(g2oFile);
64 writeG2o(*graphNoKernel, initialization, outputFile);
65 std::cout <<
"done! " << std::endl;
Initialize Pose3 in a factor graph.
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
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
int main(const int argc, const char *argv[])
Array< double, 1, 3 > e(1./3., 0.5, 2.)
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
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Values initialize(const NonlinearFactorGraph &graph, bool useOdometricPath)
utility functions for loading datasets
std::uint64_t Key
Integer nonlinear key type.