Pose2SLAMExample.cpp 671 B

12345678910111213141516
  1. NonlinearFactorGraph graph;
  2. noiseModel::Diagonal::shared_ptr priorNoise =
  3. noiseModel::Diagonal::Sigmas(Vector3(0.3, 0.3, 0.1));
  4. graph.addPrior(1, Pose2(0, 0, 0), priorNoise);
  5. // Add odometry factors
  6. noiseModel::Diagonal::shared_ptr model =
  7. noiseModel::Diagonal::Sigmas(Vector3(0.2, 0.2, 0.1));
  8. graph.add(BetweenFactor<Pose2>(1, 2, Pose2(2, 0, 0 ), model));
  9. graph.add(BetweenFactor<Pose2>(2, 3, Pose2(2, 0, M_PI_2), model));
  10. graph.add(BetweenFactor<Pose2>(3, 4, Pose2(2, 0, M_PI_2), model));
  11. graph.add(BetweenFactor<Pose2>(4, 5, Pose2(2, 0, M_PI_2), model));
  12. // Add the loop closure constraint
  13. graph.add(BetweenFactor<Pose2>(5, 2, Pose2(2, 0, M_PI_2), model));