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);
double computeMinEigenValueAP(const Values &values, Vector *minEigenVector=nullptr) const
Provides additional testing facilities for common data structures.
const BinaryMeasurement< Rot > & measurement(size_t k) const
k^th binary measurement
double computeMinEigenValue(const Values &values, Vector *minEigenVector=nullptr) const
Sparse L() const
Sparse version of L.
double cost(const Values &values) const
static int runAllTests(TestResult &result)
bool assert_print_equal(const std::string &expected, const V &actual, const std::string &s="")
typename std::conditional< d==2, Rot2, Rot3 >::type Rot
Sparse computeA(const Values &values) const
Compute A matrix whose Eigenvalues we will examine.
size_t nrUnknowns() const
Return number of unknowns.
double costAt(size_t p, const Values &values) const
TEST(ShonanAveraging3, checkConstructor)
static LevenbergMarquardtParams CeresDefaults()
NonlinearFactorGraph graph
Sparse computeLambda(const Matrix &S) const
Version that takes pxdN Stiefel manifold elements.
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
Rot3 inverse() const
inverse of a rotation
Sparse Q() const
Sparse version of Q.
std::pair< Values, double > run(const Values &initialEstimate, size_t pMin=d, size_t pMax=10) const
string findExampleDataFile(const string &name)
const Rot3 wR2(0.9925378735259738,-0.07993768981394891, 0.0825062894866454,-0.04088089479075661)
Values initializeRandomly(std::mt19937 &rng) const
static const ShonanAveraging3 kShonan
Matrix denseD() const
Dense version of D.
static std::mt19937 kRandomNumberGenerator(42)
const ValueType at(Key j) const
const mpreal gamma(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
friend const mpreal gamma(const mpreal &v, mp_rnd_t rnd_mode)
#define EXPECT(condition)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
const Rot3 wR1(0.998239108728862,-0.049543805396343954,-0.03232420352077356,-0.004386230477751116)
ShonanAveragingParameters< 3 > ShonanAveragingParameters3
static SmartStereoProjectionParams params
const Rot3 wR0(0.9992281076190063,-0.02676080288219576,-0.024497002638379624,-0.015064701622500615)
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)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Values roundSolution(const Values &values) const
#define EXPECT_LONGS_EQUAL(expected, actual)
LevenbergMarquardtParams lmParams
NonlinearFactorGraph buildGraphAt(size_t p) const
Values tryOptimizingAt(size_t p, const Values &initial) const
The quaternion class used to represent 3D orientations and rotations.
Sparse D() const
Sparse version of D.
Class between(const Class &g) const
const mpreal random(unsigned int seed=0)
Annotation for function names.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
Computes eigenvalues and eigenvectors of general matrices.
Matrix denseL() const
Dense version of L.
void run(Expr &expr, Dev &dev)
const EigenvalueType & eigenvalues() const
Returns the eigenvalues of given matrix.
Matrix denseQ() const
Dense version of Q.
bool checkOptimality(const Values &values) const
Shonan Averaging algorithm.
Values initializeWithDescent(size_t p, const Values &values, const Vector &minEigenVector, double minEigenValue, double gradienTolerance=1e-2, double preconditionedGradNormTolerance=1e-4) const
ShonanAveraging3 fromExampleName(const std::string &name, ShonanAveraging3::Parameters parameters=ShonanAveraging3::Parameters())