From 3a1653dd231d7983cd357761d4a785f6db5cd844 Mon Sep 17 00:00:00 2001 From: Binit Shah Date: Sun, 17 May 2020 15:44:11 -0400 Subject: [PATCH 1/7] Include corrupting noise param to parse3DFactors --- gtsam/slam/dataset.cpp | 17 +++++++++++++++-- gtsam/slam/dataset.h | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gtsam/slam/dataset.cpp b/gtsam/slam/dataset.cpp index 052bb3343..83636eb1d 100644 --- a/gtsam/slam/dataset.cpp +++ b/gtsam/slam/dataset.cpp @@ -541,10 +541,18 @@ std::map parse3DPoses(const string& filename) { } /* ************************************************************************* */ -BetweenFactorPose3s parse3DFactors(const string& filename) { +BetweenFactorPose3s parse3DFactors(const string& filename, + const noiseModel::Diagonal::shared_ptr& corruptingNoise) { ifstream is(filename.c_str()); if (!is) throw invalid_argument("parse3DFactors: can not find file " + filename); + // If asked, create a sampler with random number generator + Sampler sampler; + if (corruptingNoise) { + sampler = Sampler(corruptingNoise); + } + + std::vector::shared_ptr> factors; while (!is.eof()) { char buf[LINESIZE]; @@ -585,8 +593,13 @@ BetweenFactorPose3s parse3DFactors(const string& filename) { mgtsam.block<3, 3>(3, 0) = m.block<3, 3>(3, 0); // off diagonal SharedNoiseModel model = noiseModel::Gaussian::Information(mgtsam); + auto R12 = Rot3::Quaternion(qw, qx, qy, qz); + if (corruptingNoise) { + R12 = R12.retract(sampler.sample()); + } + factors.emplace_back(new BetweenFactor( - id1, id2, Pose3(Rot3::Quaternion(qw, qx, qy, qz), {x, y, z}), model)); + id1, id2, Pose3(R12, {x, y, z}), model)); } } return factors; diff --git a/gtsam/slam/dataset.h b/gtsam/slam/dataset.h index 3ab199bab..032799429 100644 --- a/gtsam/slam/dataset.h +++ b/gtsam/slam/dataset.h @@ -159,7 +159,8 @@ GTSAM_EXPORT void writeG2o(const NonlinearFactorGraph& graph, /// Parse edges in 3D TORO graph file into a set of BetweenFactors. using BetweenFactorPose3s = std::vector::shared_ptr>; -GTSAM_EXPORT BetweenFactorPose3s parse3DFactors(const std::string& filename); +GTSAM_EXPORT BetweenFactorPose3s parse3DFactors(const std::string& filename, + const noiseModel::Diagonal::shared_ptr& corruptingNoise=nullptr); /// Parse vertices in 3D TORO graph file into a map of Pose3s. GTSAM_EXPORT std::map parse3DPoses(const std::string& filename); From 9fc090165524f094ba93393440ecbc9dbdc8c483 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Mon, 18 May 2020 08:30:00 +0200 Subject: [PATCH 2/7] more precise use of setZero() and add comments --- gtsam/base/SymmetricBlockMatrix.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtsam/base/SymmetricBlockMatrix.h b/gtsam/base/SymmetricBlockMatrix.h index 1ec9a5ad3..c2996109f 100644 --- a/gtsam/base/SymmetricBlockMatrix.h +++ b/gtsam/base/SymmetricBlockMatrix.h @@ -71,6 +71,7 @@ namespace gtsam { } /// Construct from a container of the sizes of each block. + /// Uninitialized blocks are filled with zeros. template SymmetricBlockMatrix(const CONTAINER& dimensions, bool appendOneDimension = false) : blockStart_(0) @@ -81,6 +82,7 @@ namespace gtsam { } /// Construct from iterator over the sizes of each vertical block. + /// Uninitialized blocks are filled with zeros. template SymmetricBlockMatrix(ITERATOR firstBlockDim, ITERATOR lastBlockDim, bool appendOneDimension = false) : blockStart_(0) @@ -95,7 +97,7 @@ namespace gtsam { SymmetricBlockMatrix(const CONTAINER& dimensions, const Matrix& matrix, bool appendOneDimension = false) : blockStart_(0) { - matrix_.setZero(matrix.rows(), matrix.cols()); + matrix_.resize(matrix.rows(), matrix.cols()); matrix_.triangularView() = matrix.triangularView(); fillOffsets(dimensions.begin(), dimensions.end(), appendOneDimension); if(matrix_.rows() != matrix_.cols()) From 537155dd05a0e21d095212084227438447514992 Mon Sep 17 00:00:00 2001 From: Binit Shah Date: Thu, 28 May 2020 04:36:35 -0400 Subject: [PATCH 3/7] Sampler initialized with noise argument --- gtsam/slam/dataset.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/gtsam/slam/dataset.cpp b/gtsam/slam/dataset.cpp index 83636eb1d..0ed958869 100644 --- a/gtsam/slam/dataset.cpp +++ b/gtsam/slam/dataset.cpp @@ -546,13 +546,6 @@ BetweenFactorPose3s parse3DFactors(const string& filename, ifstream is(filename.c_str()); if (!is) throw invalid_argument("parse3DFactors: can not find file " + filename); - // If asked, create a sampler with random number generator - Sampler sampler; - if (corruptingNoise) { - sampler = Sampler(corruptingNoise); - } - - std::vector::shared_ptr> factors; while (!is.eof()) { char buf[LINESIZE]; @@ -595,6 +588,7 @@ BetweenFactorPose3s parse3DFactors(const string& filename, SharedNoiseModel model = noiseModel::Gaussian::Information(mgtsam); auto R12 = Rot3::Quaternion(qw, qx, qy, qz); if (corruptingNoise) { + Sampler sampler(corruptingNoise); R12 = R12.retract(sampler.sample()); } From 5556db54200d19e453b87b7ba2eea1da106f3b78 Mon Sep 17 00:00:00 2001 From: Binit Shah Date: Sat, 30 May 2020 17:35:22 -0400 Subject: [PATCH 4/7] Using optional sampler outside loop --- gtsam/slam/dataset.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gtsam/slam/dataset.cpp b/gtsam/slam/dataset.cpp index 0ed958869..66e8fc4c0 100644 --- a/gtsam/slam/dataset.cpp +++ b/gtsam/slam/dataset.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -546,6 +547,11 @@ BetweenFactorPose3s parse3DFactors(const string& filename, ifstream is(filename.c_str()); if (!is) throw invalid_argument("parse3DFactors: can not find file " + filename); + boost::optional sampler; + if (corruptingNoise) { + sampler = Sampler(corruptingNoise); + } + std::vector::shared_ptr> factors; while (!is.eof()) { char buf[LINESIZE]; @@ -587,9 +593,8 @@ BetweenFactorPose3s parse3DFactors(const string& filename, SharedNoiseModel model = noiseModel::Gaussian::Information(mgtsam); auto R12 = Rot3::Quaternion(qw, qx, qy, qz); - if (corruptingNoise) { - Sampler sampler(corruptingNoise); - R12 = R12.retract(sampler.sample()); + if (sampler) { + R12 = R12.retract(sampler->sample()); } factors.emplace_back(new BetweenFactor( From bd040c8b2287d08ffb07ace0a01ba2a789ce7cac Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 17 Jun 2020 15:02:24 -0500 Subject: [PATCH 5/7] set CMAKE_VERBOSE_MAKEFILE flag to OFF --- .travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.sh b/.travis.sh index 9fc09a3f8..535a72f4b 100755 --- a/.travis.sh +++ b/.travis.sh @@ -63,7 +63,7 @@ function configure() -DGTSAM_BUILD_EXAMPLES_ALWAYS=${GTSAM_BUILD_EXAMPLES_ALWAYS:-ON} \ -DGTSAM_ALLOW_DEPRECATED_SINCE_V4=${GTSAM_ALLOW_DEPRECATED_SINCE_V4:-OFF} \ -DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF \ - -DCMAKE_VERBOSE_MAKEFILE=ON + -DCMAKE_VERBOSE_MAKEFILE=OFF } From 741df283d098536857bdacfb9140828a0dc3aca2 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco-Claraco Date: Fri, 19 Jun 2020 09:00:15 +0200 Subject: [PATCH 6/7] Finish undo of #310 fill with zeros (not actually needed) --- gtsam/base/SymmetricBlockMatrix.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gtsam/base/SymmetricBlockMatrix.h b/gtsam/base/SymmetricBlockMatrix.h index c2996109f..4e030606d 100644 --- a/gtsam/base/SymmetricBlockMatrix.h +++ b/gtsam/base/SymmetricBlockMatrix.h @@ -71,24 +71,22 @@ namespace gtsam { } /// Construct from a container of the sizes of each block. - /// Uninitialized blocks are filled with zeros. template SymmetricBlockMatrix(const CONTAINER& dimensions, bool appendOneDimension = false) : blockStart_(0) { fillOffsets(dimensions.begin(), dimensions.end(), appendOneDimension); - matrix_.setZero(variableColOffsets_.back(), variableColOffsets_.back()); + matrix_.resize(variableColOffsets_.back(), variableColOffsets_.back()); assertInvariants(); } /// Construct from iterator over the sizes of each vertical block. - /// Uninitialized blocks are filled with zeros. template SymmetricBlockMatrix(ITERATOR firstBlockDim, ITERATOR lastBlockDim, bool appendOneDimension = false) : blockStart_(0) { fillOffsets(firstBlockDim, lastBlockDim, appendOneDimension); - matrix_.setZero(variableColOffsets_.back(), variableColOffsets_.back()); + matrix_.resize(variableColOffsets_.back(), variableColOffsets_.back()); assertInvariants(); } @@ -418,4 +416,3 @@ namespace gtsam { class CholeskyFailed; } - From 9daeb39267f80bef157c0d11e60f371e57a179bb Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Tue, 23 Jun 2020 16:08:44 -0500 Subject: [PATCH 7/7] Set minimum supported numpy version to 1.11.0 (#366) * add deadsnakes ppa to install python3.6 on Ubuntu Xenial * updated travis distro to Ubuntu 18.04 bionic * Revert "updated travis distro to Ubuntu 18.04 bionic" This reverts commit 323264a924e8554da49c27a374e9a6278c5a659e. * restrict numpy version to be less than 1.19.0 * use ubuntu packaged numpy as baseline version to test against * downgrade minimum required version of numpy to version supported by Ubuntu Xenial * undo explicit pip install --- .travis.yml | 3 ++- cython/requirements.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ca6a426ea..d8094ef4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,8 @@ addons: - clang-9 - build-essential pkg-config - cmake - - libpython-dev python-numpy + - python3-dev libpython-dev + - python3-numpy - libboost-all-dev # before_install: diff --git a/cython/requirements.txt b/cython/requirements.txt index cd77b097d..8d3c7aeb4 100644 --- a/cython/requirements.txt +++ b/cython/requirements.txt @@ -1,3 +1,3 @@ Cython>=0.25.2 backports_abc>=0.5 -numpy>=1.12.0 +numpy>=1.11.0