/* ---------------------------------------------------------------------------- * 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 * -------------------------------------------------------------------------- */ /** * @file VisualISAMExample.cpp * @brief An ISAM example for synthesis sequence, single camera * @author Duy-Nguyen Ta */ #include #include #include #include #include "VisualSLAMData.h" using namespace std; using namespace gtsam; // Convenience for named keys using symbol_shorthand::X; using symbol_shorthand::L; /* ************************************************************************* */ int main(int argc, char* argv[]) { VisualSLAMExampleData data = VisualSLAMExampleData::generate(); /* 1. Create a NonlinearISAM which will be relinearized and reordered after every "relinearizeInterval" updates */ int relinearizeInterval = 3; NonlinearISAM isam(relinearizeInterval); /* 2. At each frame (poseId) with new camera pose and set of associated measurements, * create a graph of new factors and update ISAM */ // Store the current best estimate from ISAM Values currentEstimate; // First two frames: // Add factors and initial values for the first two poses and landmarks then update ISAM. // Note: measurements from the first pose only are not enough to update ISAM: // the system is underconstrained. { visualSLAM::Graph newFactors; // First pose with prior factor newFactors.addPosePrior(X(0), data.poses[0], data.noiseX); // Second pose with odometry measurement newFactors.addRelativePose(X(0), X(1), data.odometry, data.noiseX); // Visual measurements at both poses for (size_t i=0; i<2; ++i) { for (size_t j=0; j(X(i-1))*data.odometry); // update ISAM isam.update(newFactors, initials); currentEstimate = isam.estimate(); cout << "****************************************************" << endl; cout << "Frame " << i << ": " << endl; currentEstimate.print("Current estimate: "); } return 0; } /* ************************************************************************* */