VisualISAMExample.cpp 703 B

123456789101112131415161718192021222324
  1. int relinearizeInterval = 3;
  2. NonlinearISAM isam(relinearizeInterval);
  3. // ... first frame initialization omitted ...
  4. // Loop over the different poses, adding the observations to iSAM
  5. for (size_t i = 1; i < poses.size(); ++i) {
  6. // Add factors for each landmark observation
  7. NonlinearFactorGraph graph;
  8. for (size_t j = 0; j < points.size(); ++j) {
  9. graph.add(
  10. GenericProjectionFactor<Pose3, Point3, Cal3_S2>
  11. (z[i][j], noise,Symbol('x', i), Symbol('l', j), K)
  12. );
  13. }
  14. // Add an initial guess for the current pose
  15. Values initialEstimate;
  16. initialEstimate.insert(Symbol('x', i), initial_x[i]);
  17. // Update iSAM with the new factors
  18. isam.update(graph, initialEstimate);
  19. }