31 using namespace gtsam;
40 const std::string &
name,
41 ShonanAveraging3::Parameters
parameters = ShonanAveraging3::Parameters()) {
82 Values random = ShonanAveraging3::LiftTo<Rot3>(4, randomRotations);
100 ShonanAveraging3::Measurements measurements;
112 auto result = subgraphShonan.run(initial, 3, 3);
119 Values initial = ShonanAveraging3::LiftTo<Rot3>(3, randomRotations);
134 Values random = ShonanAveraging3::LiftTo<Rot3>(4, randomRotations);
148 v << 1, 2, 3, 4, 5, 6, 7, 8, 9;
149 Vector expected0(10), expected1(10), expected2(10);
150 expected0 << 0, 3, -2, 1, 0, 0, 0, 0, 0, 0;
151 expected1 << 0, 6, -5, 4, 0, 0, 0, 0, 0, 0;
152 expected2 << 0, 9, -8, 7, 0, 0, 0, 0, 0, 0;
153 const VectorValues xi = ShonanAveraging3::TangentVectorValues(5, v);
170 static std::mt19937
rng(0);
171 Vector descentDirection = Vector::Random(15);
173 Values random = ShonanAveraging3::LiftTo<Rot3>(3, randomRotations);
182 const Matrix S = ShonanAveraging3::StiefelElementMatrix(Qstar3);
184 bool computeEigenvectors =
false;
187 double minEigenValue = lambdas(0);
188 for (
int i = 1;
i < lambdas.size();
i++)
189 minEigenValue =
min(lambdas(
i), minEigenValue);
205 ShonanAveraging3::LiftwithDescent(4, Qstar3, descentDirection);
221 Values random = ShonanAveraging3::LiftTo<Rot3>(3, randomRotations);
242 const Rot3 wR0(0.9992281076190063, -0.02676080288219576, -0.024497002638379624,
243 -0.015064701622500615);
244 const Rot3 wR1(0.998239108728862, -0.049543805396343954, -0.03232420352077356,
245 -0.004386230477751116);
246 const Rot3 wR2(0.9925378735259738, -0.07993768981394891, 0.0825062894866454,
247 -0.04088089479075661);
251 using namespace klaus;
255 parameters.setKarcherWeight(0);
266 static const Rot3 identity;
278 -0.01796327847857683, 0.010210006313668573),
309 using namespace klaus;
334 auto lmParams = LevenbergMarquardtParams::CeresDefaults();
338 auto measurements = parseMeasurements<Rot2>(g2oFile);
346 auto result = shonan.run(initial, 2);
354 auto lmParams = LevenbergMarquardtParams::CeresDefaults();
357 auto measurements = parseMeasurements<Rot2>(g2oFile);
358 parameters.setUseHuber(
true);
359 parameters.setCertifyOptimality(
false);
361 string parameters_print =
362 " ShonanAveragingParameters: \n alpha: 0\n beta: 1\n gamma: 0\n " 374 for (
size_t i=0;
i<=4;
i++) {
390 auto lmParams = LevenbergMarquardtParams::CeresDefaults();
395 double alpha = 100.0, beta = 200.0, gamma = 300.0;
396 params.setAnchorWeight(alpha);
397 params.setKarcherWeight(beta);
398 params.setGaugesWeight(gamma);
402 params.setKarcherWeight(0);
404 for (
auto i : {0,1,2}) {
408 CHECK(isotropic !=
nullptr);
Provides additional testing facilities for common data structures.
Values initializeRandomly(std::mt19937 &rng) const
Sparse Q() const
Sparse version of Q.
static int runAllTests(TestResult &result)
bool assert_print_equal(const std::string &expected, const V &actual, const std::string &s="")
const ValueType at(Key j) const
Sparse computeLambda(const Matrix &S) const
Version that takes pxdN Stiefel manifold elements.
std::pair< Values, double > run(const Values &initialEstimate, size_t pMin=d, size_t pMax=10) const
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
typename std::conditional< d==2, Rot2, Rot3 >::type Rot
double costAt(size_t p, const Values &values) const
Values roundSolution(const Values &values) const
TEST(ShonanAveraging3, checkConstructor)
Matrix denseL() const
Dense version of L.
double computeMinEigenValue(const Values &values, Vector *minEigenVector=nullptr) const
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Values tryOptimizingAt(size_t p, const Values &initial) const
static LevenbergMarquardtParams CeresDefaults()
NonlinearFactorGraph graph
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
double cost(const Values &values) const
bool checkOptimality(const Values &values) const
Sparse D() const
Sparse version of D.
static const SmartProjectionParams params
NonlinearFactorGraph buildGraphAt(size_t p) const
Rot3 inverse() const
inverse of a rotation
Sparse L() const
Sparse version of L.
static const ShonanAveraging3 kShonan
static std::mt19937 kRandomNumberGenerator(42)
const Rot3 wR0(0.9992281076190063, -0.02676080288219576, -0.024497002638379624, -0.015064701622500615)
const Rot3 wR1(0.998239108728862, -0.049543805396343954, -0.03232420352077356, -0.004386230477751116)
Matrix denseD() const
Dense version of D.
#define EXPECT(condition)
Array< int, Dynamic, 1 > v
LevenbergMarquardtParams lmParams
Array< double, 1, 3 > e(1./3., 0.5, 2.)
ShonanAveragingParameters< 3 > ShonanAveragingParameters3
Various factors that minimize some Frobenius norm.
static ConjugateGradientParameters parameters
cout<< "The eigenvalues of A are:"<< endl<< ces.eigenvalues()<< endl;cout<< "The matrix of eigenvectors, V, is:"<< endl<< ces.eigenvectors()<< endl<< endl;complex< float > lambda
const Rot & measured(size_t k) const
k^th measurement, as a Rot.
GenericValue< T > genericValue(const T &v)
GTSAM_EXPORT std::string findExampleDataFile(const std::string &name)
#define EXPECT_LONGS_EQUAL(expected, actual)
Sparse computeA(const Values &values) const
Compute A matrix whose Eigenvalues we will examine.
double computeMinEigenValueAP(const Values &values, Vector *minEigenVector=nullptr) const
The quaternion class used to represent 3D orientations and rotations.
Class between(const Class &g) const
size_t nrUnknowns() const
Return number of unknowns.
Annotation for function names.
const BinaryMeasurement< Rot > & measurement(size_t k) const
k^th binary measurement
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
const EigenvalueType & eigenvalues() const
Returns the eigenvalues of given matrix.
Computes eigenvalues and eigenvectors of general matrices.
Matrix denseQ() const
Dense version of Q.
const Rot3 wR2(0.9925378735259738, -0.07993768981394891, 0.0825062894866454, -0.04088089479075661)
Shonan Averaging algorithm.
ShonanAveraging3 fromExampleName(const std::string &name, ShonanAveraging3::Parameters parameters=ShonanAveraging3::Parameters())
Values initializeWithDescent(size_t p, const Values &values, const Vector &minEigenVector, double minEigenValue, double gradienTolerance=1e-2, double preconditionedGradNormTolerance=1e-4) const