diff --git a/examples/Pose3SLAMExample_changeKeys.cpp b/examples/Pose3SLAMExample_changeKeys.cpp index 1e28c2097..ae4ee5a8c 100644 --- a/examples/Pose3SLAMExample_changeKeys.cpp +++ b/examples/Pose3SLAMExample_changeKeys.cpp @@ -12,7 +12,7 @@ /** * @file Pose3SLAMExample_initializePose3.cpp * @brief A 3D Pose SLAM example that reads input from g2o, and initializes the Pose3 using InitializePose3 - * Syntax for the script is ./Pose3SLAMExample_initializePose3 input.g2o output.g2o rewritted.g2o + * Syntax for the script is ./Pose3SLAMExample_changeKeys input.g2o rewritted.g2o * @date Aug 25, 2014 * @author Luca Carlone */ @@ -40,9 +40,15 @@ int main(const int argc, const char *argv[]) { bool is3D = true; boost::tie(graph, initial) = readG2o(g2oFile, is3D); + bool add = false; Key firstKey = 8646911284551352320; std::cout << "Using reference key: " << firstKey << std::endl; + if(add) + std::cout << "adding key " << std::endl; + else + std::cout << "subtracting key " << std::endl; + if (argc < 3) { std::cout << "Please provide output file to write " << std::endl; @@ -52,7 +58,12 @@ int main(const int argc, const char *argv[]) { // Additional: rewrite input with simplified keys 0,1,... Values simpleInitial; BOOST_FOREACH(const Values::ConstKeyValuePair& key_value, *initial) { - Key key = key_value.key + firstKey; + Key key; + if(add) + key = key_value.key + firstKey; + else + key = key_value.key - firstKey; + simpleInitial.insert(key, initial->at(key_value.key)); } NonlinearFactorGraph simpleGraph; @@ -60,8 +71,14 @@ int main(const int argc, const char *argv[]) { boost::shared_ptr > pose3Between = boost::dynamic_pointer_cast >(factor); if (pose3Between){ - Key key1 = pose3Between->key1() + firstKey; - Key key2 = pose3Between->key2() + firstKey; + Key key1, key2; + if(add){ + key1 = pose3Between->key1() + firstKey; + key2 = pose3Between->key2() + firstKey; + }else{ + key1 = pose3Between->key1() - firstKey; + key2 = pose3Between->key2() - firstKey; + } NonlinearFactor::shared_ptr simpleFactor( new BetweenFactor(key1, key2, pose3Between->measured(), pose3Between->get_noiseModel())); simpleGraph.add(simpleFactor); diff --git a/examples/Pose3SLAMExample_initializePose3Chordal.cpp b/examples/Pose3SLAMExample_initializePose3Chordal.cpp index e52534b93..afc66ea1e 100644 --- a/examples/Pose3SLAMExample_initializePose3Chordal.cpp +++ b/examples/Pose3SLAMExample_initializePose3Chordal.cpp @@ -63,31 +63,6 @@ int main(const int argc, const char *argv[]) { std::cout << "Writing results to file: " << outputFile << std::endl; writeG2o(*graph, initialization, outputFile); std::cout << "done! " << std::endl; - - // This should be deleted: only for debug - // if (argc == 4){ - // const string inputFileRewritten = argv[3]; - // std::cout << "Rewriting input to file: " << inputFileRewritten << std::endl; - // // Additional: rewrite input with simplified keys 0,1,... - // Values simpleInitial; - // BOOST_FOREACH(const Values::ConstKeyValuePair& key_value, *initial) { - // Key key = key_value.key - firstKey; - // simpleInitial.insert(key, initial->at(key_value.key)); - // } - // NonlinearFactorGraph simpleGraph; - // BOOST_FOREACH(const boost::shared_ptr& factor, *graph) { - // boost::shared_ptr > pose3Between = - // boost::dynamic_pointer_cast >(factor); - // if (pose3Between){ - // Key key1 = pose3Between->key1() - firstKey; - // Key key2 = pose3Between->key2() - firstKey; - // NonlinearFactor::shared_ptr simpleFactor( - // new BetweenFactor(key1, key2, pose3Between->measured(), pose3Between->get_noiseModel())); - // simpleGraph.add(simpleFactor); - // } - // } - // writeG2o(simpleGraph, simpleInitial, inputFileRewritten); - // } } return 0; } diff --git a/examples/Pose3SLAMExample_initializePose3Gradient.cpp b/examples/Pose3SLAMExample_initializePose3Gradient.cpp index 898986b0a..9dc410692 100644 --- a/examples/Pose3SLAMExample_initializePose3Gradient.cpp +++ b/examples/Pose3SLAMExample_initializePose3Gradient.cpp @@ -43,7 +43,7 @@ int main(const int argc, const char *argv[]) { // Add prior on the first key NonlinearFactorGraph graphWithPrior = *graph; noiseModel::Diagonal::shared_ptr priorModel = // - noiseModel::Diagonal::Variances((Vector(6) << 0.1, 0.1, 0.1, 0.01, 0.01, 0.01)); + noiseModel::Diagonal::Variances((Vector(6) << 1e-6, 1e-6, 1e-6, 1e-4, 1e-4, 1e-4)); Key firstKey = 0; BOOST_FOREACH(const Values::ConstKeyValuePair& key_value, *initial) { std::cout << "Adding prior to g2o file " << std::endl;