2 GTSAM Copyright 2010-2019, Georgia Tech Research Corporation, 3 Atlanta, Georgia 30332-0415 6 See LICENSE for the license information 8 Unit tests for Shonan Rotation Averaging. 16 from gtsam
import ShonanAveraging3, ShonanAveragingParameters3
29 """Tests for Shonan Rotation Averaging.""" 32 """Set up common variables.""" 36 self.assertEqual(5, self.shonan.nrUnknowns())
38 D = self.shonan.denseD()
39 self.assertEqual((15, 15), D.shape)
41 Q = self.shonan.denseQ()
42 self.assertEqual((15, 15), Q.shape)
44 L = self.shonan.denseL()
45 self.assertEqual((15, 15), L.shape)
48 graph = self.shonan.buildGraphAt(5)
49 self.assertEqual(7, graph.size())
52 random = self.shonan.initializeRandomlyAt(4)
53 lambdaMin = self.shonan.computeMinEigenValue(random)
54 self.assertAlmostEqual(-414.87376657555996,
56 self.assertFalse(self.shonan.checkOptimality(random))
59 initial = self.shonan.initializeRandomlyAt(3)
60 self.assertFalse(self.shonan.checkOptimality(initial))
61 result = self.shonan.tryOptimizingAt(3, initial)
62 self.assertTrue(self.shonan.checkOptimality(result))
63 lambdaMin = self.shonan.computeMinEigenValue(result)
64 self.assertAlmostEqual(-5.427688831332745e-07,
66 self.assertAlmostEqual(0, self.shonan.costAt(3, result), places=3)
67 SO3Values = self.shonan.roundSolution(result)
68 self.assertAlmostEqual(0, self.shonan.cost(SO3Values), places=3)
71 random = self.shonan.initializeRandomlyAt(4)
72 result = self.shonan.tryOptimizingAt(4, random)
73 self.assertTrue(self.shonan.checkOptimality(result))
74 self.assertAlmostEqual(0, self.shonan.costAt(4, result), places=2)
75 lambdaMin = self.shonan.computeMinEigenValue(result)
76 self.assertAlmostEqual(-5.427688831332745e-07,
78 SO3Values = self.shonan.roundSolution(result)
79 self.assertAlmostEqual(0, self.shonan.cost(SO3Values), places=3)
82 random = self.shonan.initializeRandomlyAt(3)
83 Qstar3 = self.shonan.tryOptimizingAt(3, random)
84 lambdaMin, minEigenVector = self.shonan.computeMinEigenVector(Qstar3)
85 initialQ4 = self.shonan.initializeWithDescent(
86 4, Qstar3, minEigenVector, lambdaMin)
87 self.assertAlmostEqual(5, initialQ4.size())
90 initial = self.shonan.initializeRandomly()
91 result, lambdaMin = self.shonan.run(initial, 5, 10)
92 self.assertAlmostEqual(0, self.shonan.cost(result), places=2)
93 self.assertAlmostEqual(-5.427688831332745e-07,
103 self.assertAlmostEqual(4, shonan.nrUnknowns())
106 graph = shonan.buildGraphAt(2)
107 self.assertAlmostEqual(6, graph.size())
108 initial = shonan.initializeRandomly()
109 result, lambdaMin = shonan.run(initial, 2, 10)
110 self.assertAlmostEqual(0.0008211, shonan.cost(result), places=5)
111 self.assertAlmostEqual(0, lambdaMin, places=9)
117 self.assertAlmostEqual(0, params.getAnchorWeight(), 1e-9)
118 self.assertAlmostEqual(1, params.getKarcherWeight(), 1e-9)
119 self.assertAlmostEqual(0, params.getGaugesWeight(), 1e-9)
120 alpha, beta, gamma = 100.0, 200.0, 300.0
121 params.setAnchorWeight(alpha)
122 params.setKarcherWeight(beta)
123 params.setGaugesWeight(gamma)
124 self.assertAlmostEqual(alpha, params.getAnchorWeight(), 1e-9)
125 self.assertAlmostEqual(beta, params.getKarcherWeight(), 1e-9)
126 self.assertAlmostEqual(gamma, params.getGaugesWeight(), 1e-9)
127 params.setKarcherWeight(0)
133 self.assertAlmostEqual(3.0756, shonan.cost(initial), places=3)
134 result, _lambdaMin = shonan.run(initial, 3, 3)
135 self.assertAlmostEqual(0.0015, shonan.cost(result), places=3)
138 if __name__ ==
'__main__':
def test_checkConstructor(self)
def test_tryOptimizingAt3(self)
def test_PriorWeights(self)
static LevenbergMarquardtParams CeresDefaults()
Parameters governing optimization etc.
def test_tryOptimizingAt4(self)
def test_initializeWithDescent(self)
ShonanAveragingParameters< 3 > ShonanAveragingParameters3
def test_checkOptimality(self)
def test_buildGraphAt(self)
def test_runKlausKarcher(self)
GTSAM_EXPORT std::string findExampleDataFile(const std::string &name)