| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * GTSAM Copyright 2010, Georgia Tech Research Corporation, | 
					
						
							|  |  |  |  * Atlanta, Georgia 30332-0415 | 
					
						
							|  |  |  |  * All Rights Reserved | 
					
						
							|  |  |  |  * Authors: Frank Dellaert, et al. (see THANKS for the full author list) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * See LICENSE for the license information | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
											  
											
												Feature/shonan averaging (#473)
Shonan Rotation Averaging.
199 commit messages below, many are obsolete as design has changed quite a bit over time, especially from the earlier period where I thought we only needed SO(4).
* prototyping weighted sampler
* Moved WeightedSampler into its own header
* Random now uses std header <random>.
* Removed boost/random usage from linear and discrete directories
* Made into class
* Now using new WeightedSampler class
* Inlined random direction generation
* eradicated last vestiges of boost/random in gtsam_unstable
* Added 3D example g2o file
* Added Frobenius norm factors
* Shonan averaging algorithm, using SOn class
* Wrapping Frobenius and Shonan
* Fixed issues with <<
* Use Builder parameters
* Refactored Shonan interface
* Fixed << issues as well as MATLAB segfault, using eval(), as discussed in issue #451
* ShonanAveragingParameters
* New factor FrobeniusWormholeFactorP computes |Rj*P - Ri*P*Rij|
* Fixed broken GetDimension for Lie groups with variable dimension.
* Removed all but Shonan averaging factor and made everything work with new SOn
* Just a single WormholeFactor, wrapped noise model
* Use std <random>
* comments/todos
* added timing script
* add script to process ShonanAveraging timing results
* Now producing a CSV file
* Parse csv file and make combined plot
* Fixed range
* change p value and set two flags on
* input file path, all the csv files proceeses at the same time
* add check convergence rate part
* csv file have name according to input  data name
* correct one mistake in initialization
* generate the convergence rate for each p value
* add yticks for the bar plot
* add noises to the measurements
* test add noise
* Basic structure for checkOptimalityAt
* change optimizer method to cholesky
* buildQ now working. Tests should be better but visually inspected.
* multiple test with cholesky
* back
* computeLambda now works
* make combined plots while make bar plot
* Calculate minimum eigenvalue - the very expensive version
* Exposed computeMinEigenValue
* make plots and bar  togenter
* method change to jacobi
* add time for check optimality, min_eigen_value, sub_bound
* updated plot min_eigen value and subounds
* Adding Spectra headers
* David's min eigenvalue code inserted and made to compile.
* Made it work
* Made "run" method work.
* add rim.g2o name
* Fixed bug in shifting eigenvalues
* roundSolution which replaces projectFrom
* removed extra arguments
* Added to wrapper
* Add SOn to template lists
* roundSolution delete the extra arguement p
* only calculate p=5 and change to the correct way computing f_R
* Fixed conflict and made Google-style name changes
* prototype descent code and unit test for initializeWithDescent
* add averaging cost/time part in processing data
* initializewithDescent success in test
* Formatting and find example rather than hardcode
* Removed accidentally checked in cmake files
* give value to xi by block
* correct gradient descent
* correct xi
* }
* Fix wrapper
* Make Hat/Vee have alternating signs
* MakeATangentVector helpder function
* Fixed cmake files
* changed sign
* add line search
* unit test for line search
* test real data with line search
* correct comment
* Fix boost::uniform_real
* add save .dat file
* correct test case
* add explanation
* delete redundant cout
* add name to .dat output file
* correct checkR
* add get poses_  in shonan
* add Vector Point type for savig data
* Remove cmake file which magically re-appeared??
* Switched to std random library.
* Prepare Klaus test
* Add klaus3.g2o data.
* fix comment
* Fix derivatives
* Fixed broken GetDimension for Lie groups with variable dimension.
* Fix SOn tests to report correct dimension
* Added tests for Klaus3 data
* Add runWithRandomKlaus test for shonan.
* Finish runWithRandomKlaus unittest.
* Correct datafile.
* Correct the format.
* Added measured and keys methods
* Shonan works on Klaus data
* Create dense versions for wrappers, for testing
* Now store D, Q, and L
* Remove another cmake file incorrectly checked in.
* Found and fixed the bug in ComputeLambda !
* Now using Q in Lambdas calculation, so Lambdas agree with Eriksson18cvpr.
* Make FrobeniusFactor not use deprecated methods
* FrobeniusWormholeFactor takes Rot3 as argument
* Wrapped some more methods.
* Wrapped more methods
* Allow creating and populating BetweenFactorPose3s in python
* New constructors for ShonanAveraging
* add function of get measurements number
* Remove option not to use noise model
* wrap Use nrMeasurements
* Made Logmap a bit more tolerant of slightly degenerate rotations (with trace < -1)
* Allow for Anchor index
* Fix anchor bug
* Change outside view to Rot3 rather than SO3
* Add Lift in SOn class
* Make comet working
* Small fixes
* Delete extra function
* Add SOn::Lift
* Removed hardcoded flag
* Moved Frobenius factor to gtsam from unstable
* Added new tests and made an old regression pass again
* Cleaned up formatting and some comments, added EXPORT directives
* Throw exception if wrongly dimensioned values are given
* static_cast and other throw
* Fixed run-time dimension
* Added gauge-constraining factor
* LM parameters now passed in, added Gauge fixing
* 2D test scaffold
* Comments
* Pre-allocated generators
* Document API
* Add optional weight
* New prior weeights infrastructure
* Made d a template parameter
* Recursive Hat and RetractJacobian test
* Added Spectra 0.9.0 to 3rdparty
* Enabling 2D averaging
* Templatized Wormhole factor
* ignore xcode folder
* Fixed vec and VectorizedGenerators templates for fixed N!=3 or 4
* Simplifying constructors
Moved file loading to tests (for now)
All unit tests pass for d==3!
* Templated some methods internally
* Very generic parseToVector
* refactored load2d
* Very much improved FrobeniusWormholeFactor (Shonan) Jacobians
* SO(2) averaging works !
* Templated parse methods
* Switched to new Dataset paradigm
* Moved Shonan to gtsam
* Checked noise model is correctly gotten from file
* Fixed covariance bug
* Making Shonan wrapper work
* Renamed FrobeniusWormholeFactor to ShonanFactor and moved into its own compilation unit in gtsam/sfm
* Fixed wrong include
* Simplified interface (removed irrelevant random inits) and fixed eigenvector test
* Removed stray boost::none
* Added citation as suggested by Jose
* Made descent test deterministic
* Fixed some comments, commented out flaky test
Co-authored-by: Jing Wu <jingwu@gatech.edu>
Co-authored-by: jingwuOUO <wujing2951@gmail.com>
Co-authored-by: swang <swang736@gatech.edu>
Co-authored-by: ss <ss>
Co-authored-by: Fan Jiang <prof.fan@foxmail.com>
											
										 
											2020-08-17 19:43:10 +08:00
										 |  |  |  * @file    timeShonanFactor.cpp | 
					
						
							|  |  |  |  * @brief   time ShonanFactor with BAL file | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |  * @author  Frank Dellaert | 
					
						
							| 
									
										
										
										
											2020-08-02 03:43:55 +08:00
										 |  |  |  * @date    2019 | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <gtsam/base/timing.h>
 | 
					
						
							|  |  |  | #include <gtsam/geometry/Pose3.h>
 | 
					
						
							|  |  |  | #include <gtsam/linear/NoiseModel.h>
 | 
					
						
							|  |  |  | #include <gtsam/linear/PCGSolver.h>
 | 
					
						
							|  |  |  | #include <gtsam/linear/SubgraphPreconditioner.h>
 | 
					
						
							|  |  |  | #include <gtsam/nonlinear/LevenbergMarquardtOptimizer.h>
 | 
					
						
							|  |  |  | #include <gtsam/nonlinear/NonlinearEquality.h>
 | 
					
						
							|  |  |  | #include <gtsam/nonlinear/NonlinearFactorGraph.h>
 | 
					
						
							|  |  |  | #include <gtsam/nonlinear/Values.h>
 | 
					
						
							|  |  |  | #include <gtsam/slam/PriorFactor.h>
 | 
					
						
							|  |  |  | #include <gtsam/slam/dataset.h>
 | 
					
						
							| 
									
										
											  
											
												Feature/shonan averaging (#473)
Shonan Rotation Averaging.
199 commit messages below, many are obsolete as design has changed quite a bit over time, especially from the earlier period where I thought we only needed SO(4).
* prototyping weighted sampler
* Moved WeightedSampler into its own header
* Random now uses std header <random>.
* Removed boost/random usage from linear and discrete directories
* Made into class
* Now using new WeightedSampler class
* Inlined random direction generation
* eradicated last vestiges of boost/random in gtsam_unstable
* Added 3D example g2o file
* Added Frobenius norm factors
* Shonan averaging algorithm, using SOn class
* Wrapping Frobenius and Shonan
* Fixed issues with <<
* Use Builder parameters
* Refactored Shonan interface
* Fixed << issues as well as MATLAB segfault, using eval(), as discussed in issue #451
* ShonanAveragingParameters
* New factor FrobeniusWormholeFactorP computes |Rj*P - Ri*P*Rij|
* Fixed broken GetDimension for Lie groups with variable dimension.
* Removed all but Shonan averaging factor and made everything work with new SOn
* Just a single WormholeFactor, wrapped noise model
* Use std <random>
* comments/todos
* added timing script
* add script to process ShonanAveraging timing results
* Now producing a CSV file
* Parse csv file and make combined plot
* Fixed range
* change p value and set two flags on
* input file path, all the csv files proceeses at the same time
* add check convergence rate part
* csv file have name according to input  data name
* correct one mistake in initialization
* generate the convergence rate for each p value
* add yticks for the bar plot
* add noises to the measurements
* test add noise
* Basic structure for checkOptimalityAt
* change optimizer method to cholesky
* buildQ now working. Tests should be better but visually inspected.
* multiple test with cholesky
* back
* computeLambda now works
* make combined plots while make bar plot
* Calculate minimum eigenvalue - the very expensive version
* Exposed computeMinEigenValue
* make plots and bar  togenter
* method change to jacobi
* add time for check optimality, min_eigen_value, sub_bound
* updated plot min_eigen value and subounds
* Adding Spectra headers
* David's min eigenvalue code inserted and made to compile.
* Made it work
* Made "run" method work.
* add rim.g2o name
* Fixed bug in shifting eigenvalues
* roundSolution which replaces projectFrom
* removed extra arguments
* Added to wrapper
* Add SOn to template lists
* roundSolution delete the extra arguement p
* only calculate p=5 and change to the correct way computing f_R
* Fixed conflict and made Google-style name changes
* prototype descent code and unit test for initializeWithDescent
* add averaging cost/time part in processing data
* initializewithDescent success in test
* Formatting and find example rather than hardcode
* Removed accidentally checked in cmake files
* give value to xi by block
* correct gradient descent
* correct xi
* }
* Fix wrapper
* Make Hat/Vee have alternating signs
* MakeATangentVector helpder function
* Fixed cmake files
* changed sign
* add line search
* unit test for line search
* test real data with line search
* correct comment
* Fix boost::uniform_real
* add save .dat file
* correct test case
* add explanation
* delete redundant cout
* add name to .dat output file
* correct checkR
* add get poses_  in shonan
* add Vector Point type for savig data
* Remove cmake file which magically re-appeared??
* Switched to std random library.
* Prepare Klaus test
* Add klaus3.g2o data.
* fix comment
* Fix derivatives
* Fixed broken GetDimension for Lie groups with variable dimension.
* Fix SOn tests to report correct dimension
* Added tests for Klaus3 data
* Add runWithRandomKlaus test for shonan.
* Finish runWithRandomKlaus unittest.
* Correct datafile.
* Correct the format.
* Added measured and keys methods
* Shonan works on Klaus data
* Create dense versions for wrappers, for testing
* Now store D, Q, and L
* Remove another cmake file incorrectly checked in.
* Found and fixed the bug in ComputeLambda !
* Now using Q in Lambdas calculation, so Lambdas agree with Eriksson18cvpr.
* Make FrobeniusFactor not use deprecated methods
* FrobeniusWormholeFactor takes Rot3 as argument
* Wrapped some more methods.
* Wrapped more methods
* Allow creating and populating BetweenFactorPose3s in python
* New constructors for ShonanAveraging
* add function of get measurements number
* Remove option not to use noise model
* wrap Use nrMeasurements
* Made Logmap a bit more tolerant of slightly degenerate rotations (with trace < -1)
* Allow for Anchor index
* Fix anchor bug
* Change outside view to Rot3 rather than SO3
* Add Lift in SOn class
* Make comet working
* Small fixes
* Delete extra function
* Add SOn::Lift
* Removed hardcoded flag
* Moved Frobenius factor to gtsam from unstable
* Added new tests and made an old regression pass again
* Cleaned up formatting and some comments, added EXPORT directives
* Throw exception if wrongly dimensioned values are given
* static_cast and other throw
* Fixed run-time dimension
* Added gauge-constraining factor
* LM parameters now passed in, added Gauge fixing
* 2D test scaffold
* Comments
* Pre-allocated generators
* Document API
* Add optional weight
* New prior weeights infrastructure
* Made d a template parameter
* Recursive Hat and RetractJacobian test
* Added Spectra 0.9.0 to 3rdparty
* Enabling 2D averaging
* Templatized Wormhole factor
* ignore xcode folder
* Fixed vec and VectorizedGenerators templates for fixed N!=3 or 4
* Simplifying constructors
Moved file loading to tests (for now)
All unit tests pass for d==3!
* Templated some methods internally
* Very generic parseToVector
* refactored load2d
* Very much improved FrobeniusWormholeFactor (Shonan) Jacobians
* SO(2) averaging works !
* Templated parse methods
* Switched to new Dataset paradigm
* Moved Shonan to gtsam
* Checked noise model is correctly gotten from file
* Fixed covariance bug
* Making Shonan wrapper work
* Renamed FrobeniusWormholeFactor to ShonanFactor and moved into its own compilation unit in gtsam/sfm
* Fixed wrong include
* Simplified interface (removed irrelevant random inits) and fixed eigenvector test
* Removed stray boost::none
* Added citation as suggested by Jose
* Made descent test deterministic
* Fixed some comments, commented out flaky test
Co-authored-by: Jing Wu <jingwu@gatech.edu>
Co-authored-by: jingwuOUO <wujing2951@gmail.com>
Co-authored-by: swang <swang736@gatech.edu>
Co-authored-by: ss <ss>
Co-authored-by: Fan Jiang <prof.fan@foxmail.com>
											
										 
											2020-08-17 19:43:10 +08:00
										 |  |  | #include <gtsam/sfm/ShonanFactor.h>
 | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <iostream>
 | 
					
						
							| 
									
										
										
										
											2020-07-24 02:05:23 +08:00
										 |  |  | #include <random>
 | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  | #include <string>
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace std; | 
					
						
							|  |  |  | using namespace gtsam; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static SharedNoiseModel gNoiseModel = noiseModel::Unit::Create(2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int main(int argc, char* argv[]) { | 
					
						
							|  |  |  |   // primitive argument parsing:
 | 
					
						
							|  |  |  |   if (argc > 3) { | 
					
						
							| 
									
										
											  
											
												Feature/shonan averaging (#473)
Shonan Rotation Averaging.
199 commit messages below, many are obsolete as design has changed quite a bit over time, especially from the earlier period where I thought we only needed SO(4).
* prototyping weighted sampler
* Moved WeightedSampler into its own header
* Random now uses std header <random>.
* Removed boost/random usage from linear and discrete directories
* Made into class
* Now using new WeightedSampler class
* Inlined random direction generation
* eradicated last vestiges of boost/random in gtsam_unstable
* Added 3D example g2o file
* Added Frobenius norm factors
* Shonan averaging algorithm, using SOn class
* Wrapping Frobenius and Shonan
* Fixed issues with <<
* Use Builder parameters
* Refactored Shonan interface
* Fixed << issues as well as MATLAB segfault, using eval(), as discussed in issue #451
* ShonanAveragingParameters
* New factor FrobeniusWormholeFactorP computes |Rj*P - Ri*P*Rij|
* Fixed broken GetDimension for Lie groups with variable dimension.
* Removed all but Shonan averaging factor and made everything work with new SOn
* Just a single WormholeFactor, wrapped noise model
* Use std <random>
* comments/todos
* added timing script
* add script to process ShonanAveraging timing results
* Now producing a CSV file
* Parse csv file and make combined plot
* Fixed range
* change p value and set two flags on
* input file path, all the csv files proceeses at the same time
* add check convergence rate part
* csv file have name according to input  data name
* correct one mistake in initialization
* generate the convergence rate for each p value
* add yticks for the bar plot
* add noises to the measurements
* test add noise
* Basic structure for checkOptimalityAt
* change optimizer method to cholesky
* buildQ now working. Tests should be better but visually inspected.
* multiple test with cholesky
* back
* computeLambda now works
* make combined plots while make bar plot
* Calculate minimum eigenvalue - the very expensive version
* Exposed computeMinEigenValue
* make plots and bar  togenter
* method change to jacobi
* add time for check optimality, min_eigen_value, sub_bound
* updated plot min_eigen value and subounds
* Adding Spectra headers
* David's min eigenvalue code inserted and made to compile.
* Made it work
* Made "run" method work.
* add rim.g2o name
* Fixed bug in shifting eigenvalues
* roundSolution which replaces projectFrom
* removed extra arguments
* Added to wrapper
* Add SOn to template lists
* roundSolution delete the extra arguement p
* only calculate p=5 and change to the correct way computing f_R
* Fixed conflict and made Google-style name changes
* prototype descent code and unit test for initializeWithDescent
* add averaging cost/time part in processing data
* initializewithDescent success in test
* Formatting and find example rather than hardcode
* Removed accidentally checked in cmake files
* give value to xi by block
* correct gradient descent
* correct xi
* }
* Fix wrapper
* Make Hat/Vee have alternating signs
* MakeATangentVector helpder function
* Fixed cmake files
* changed sign
* add line search
* unit test for line search
* test real data with line search
* correct comment
* Fix boost::uniform_real
* add save .dat file
* correct test case
* add explanation
* delete redundant cout
* add name to .dat output file
* correct checkR
* add get poses_  in shonan
* add Vector Point type for savig data
* Remove cmake file which magically re-appeared??
* Switched to std random library.
* Prepare Klaus test
* Add klaus3.g2o data.
* fix comment
* Fix derivatives
* Fixed broken GetDimension for Lie groups with variable dimension.
* Fix SOn tests to report correct dimension
* Added tests for Klaus3 data
* Add runWithRandomKlaus test for shonan.
* Finish runWithRandomKlaus unittest.
* Correct datafile.
* Correct the format.
* Added measured and keys methods
* Shonan works on Klaus data
* Create dense versions for wrappers, for testing
* Now store D, Q, and L
* Remove another cmake file incorrectly checked in.
* Found and fixed the bug in ComputeLambda !
* Now using Q in Lambdas calculation, so Lambdas agree with Eriksson18cvpr.
* Make FrobeniusFactor not use deprecated methods
* FrobeniusWormholeFactor takes Rot3 as argument
* Wrapped some more methods.
* Wrapped more methods
* Allow creating and populating BetweenFactorPose3s in python
* New constructors for ShonanAveraging
* add function of get measurements number
* Remove option not to use noise model
* wrap Use nrMeasurements
* Made Logmap a bit more tolerant of slightly degenerate rotations (with trace < -1)
* Allow for Anchor index
* Fix anchor bug
* Change outside view to Rot3 rather than SO3
* Add Lift in SOn class
* Make comet working
* Small fixes
* Delete extra function
* Add SOn::Lift
* Removed hardcoded flag
* Moved Frobenius factor to gtsam from unstable
* Added new tests and made an old regression pass again
* Cleaned up formatting and some comments, added EXPORT directives
* Throw exception if wrongly dimensioned values are given
* static_cast and other throw
* Fixed run-time dimension
* Added gauge-constraining factor
* LM parameters now passed in, added Gauge fixing
* 2D test scaffold
* Comments
* Pre-allocated generators
* Document API
* Add optional weight
* New prior weeights infrastructure
* Made d a template parameter
* Recursive Hat and RetractJacobian test
* Added Spectra 0.9.0 to 3rdparty
* Enabling 2D averaging
* Templatized Wormhole factor
* ignore xcode folder
* Fixed vec and VectorizedGenerators templates for fixed N!=3 or 4
* Simplifying constructors
Moved file loading to tests (for now)
All unit tests pass for d==3!
* Templated some methods internally
* Very generic parseToVector
* refactored load2d
* Very much improved FrobeniusWormholeFactor (Shonan) Jacobians
* SO(2) averaging works !
* Templated parse methods
* Switched to new Dataset paradigm
* Moved Shonan to gtsam
* Checked noise model is correctly gotten from file
* Fixed covariance bug
* Making Shonan wrapper work
* Renamed FrobeniusWormholeFactor to ShonanFactor and moved into its own compilation unit in gtsam/sfm
* Fixed wrong include
* Simplified interface (removed irrelevant random inits) and fixed eigenvector test
* Removed stray boost::none
* Added citation as suggested by Jose
* Made descent test deterministic
* Fixed some comments, commented out flaky test
Co-authored-by: Jing Wu <jingwu@gatech.edu>
Co-authored-by: jingwuOUO <wujing2951@gmail.com>
Co-authored-by: swang <swang736@gatech.edu>
Co-authored-by: ss <ss>
Co-authored-by: Fan Jiang <prof.fan@foxmail.com>
											
										 
											2020-08-17 19:43:10 +08:00
										 |  |  |     throw runtime_error("Usage: timeShonanFactor [g2oFile]"); | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   string g2oFile; | 
					
						
							|  |  |  |   try { | 
					
						
							|  |  |  |     if (argc > 1) | 
					
						
							|  |  |  |       g2oFile = argv[argc - 1]; | 
					
						
							|  |  |  |     else | 
					
						
							| 
									
										
										
										
											2020-08-02 03:43:55 +08:00
										 |  |  |       g2oFile = findExampleDataFile("sphere_smallnoise.graph"); | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |   } catch (const exception& e) { | 
					
						
							|  |  |  |     cerr << e.what() << '\n'; | 
					
						
							|  |  |  |     exit(1); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Read G2O file
 | 
					
						
							| 
									
										
										
										
											2020-08-15 20:06:37 +08:00
										 |  |  |   const auto measurements = parseMeasurements<Rot3>(g2oFile); | 
					
						
							| 
									
										
										
										
											2020-08-14 08:38:58 +08:00
										 |  |  |   const auto poses = parseVariables<Pose3>(g2oFile); | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Build graph
 | 
					
						
							|  |  |  |   NonlinearFactorGraph graph; | 
					
						
							| 
									
										
										
										
											2022-07-08 00:31:27 +08:00
										 |  |  |   // graph.add(NonlinearEquality<SOn>(0, SOn::Identity(4)));
 | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |   auto priorModel = noiseModel::Isotropic::Sigma(6, 10000); | 
					
						
							| 
									
										
										
										
											2022-07-08 00:31:27 +08:00
										 |  |  |   graph.add(PriorFactor<SOn>(0, SOn::Identity(4), priorModel)); | 
					
						
							| 
									
										
										
										
											2023-01-18 06:05:12 +08:00
										 |  |  |   auto G = std::make_shared<Matrix>(SOn::VectorizedGenerators(4)); | 
					
						
							| 
									
										
										
										
											2020-08-15 20:06:37 +08:00
										 |  |  |   for (const auto &m : measurements) { | 
					
						
							|  |  |  |     const auto &keys = m.keys(); | 
					
						
							| 
									
										
										
										
											2020-08-17 05:30:52 +08:00
										 |  |  |     const Rot3 &Rij = m.measured(); | 
					
						
							| 
									
										
										
										
											2020-08-15 20:06:37 +08:00
										 |  |  |     const auto &model = m.noiseModel(); | 
					
						
							| 
									
										
											  
											
												Feature/shonan averaging (#473)
Shonan Rotation Averaging.
199 commit messages below, many are obsolete as design has changed quite a bit over time, especially from the earlier period where I thought we only needed SO(4).
* prototyping weighted sampler
* Moved WeightedSampler into its own header
* Random now uses std header <random>.
* Removed boost/random usage from linear and discrete directories
* Made into class
* Now using new WeightedSampler class
* Inlined random direction generation
* eradicated last vestiges of boost/random in gtsam_unstable
* Added 3D example g2o file
* Added Frobenius norm factors
* Shonan averaging algorithm, using SOn class
* Wrapping Frobenius and Shonan
* Fixed issues with <<
* Use Builder parameters
* Refactored Shonan interface
* Fixed << issues as well as MATLAB segfault, using eval(), as discussed in issue #451
* ShonanAveragingParameters
* New factor FrobeniusWormholeFactorP computes |Rj*P - Ri*P*Rij|
* Fixed broken GetDimension for Lie groups with variable dimension.
* Removed all but Shonan averaging factor and made everything work with new SOn
* Just a single WormholeFactor, wrapped noise model
* Use std <random>
* comments/todos
* added timing script
* add script to process ShonanAveraging timing results
* Now producing a CSV file
* Parse csv file and make combined plot
* Fixed range
* change p value and set two flags on
* input file path, all the csv files proceeses at the same time
* add check convergence rate part
* csv file have name according to input  data name
* correct one mistake in initialization
* generate the convergence rate for each p value
* add yticks for the bar plot
* add noises to the measurements
* test add noise
* Basic structure for checkOptimalityAt
* change optimizer method to cholesky
* buildQ now working. Tests should be better but visually inspected.
* multiple test with cholesky
* back
* computeLambda now works
* make combined plots while make bar plot
* Calculate minimum eigenvalue - the very expensive version
* Exposed computeMinEigenValue
* make plots and bar  togenter
* method change to jacobi
* add time for check optimality, min_eigen_value, sub_bound
* updated plot min_eigen value and subounds
* Adding Spectra headers
* David's min eigenvalue code inserted and made to compile.
* Made it work
* Made "run" method work.
* add rim.g2o name
* Fixed bug in shifting eigenvalues
* roundSolution which replaces projectFrom
* removed extra arguments
* Added to wrapper
* Add SOn to template lists
* roundSolution delete the extra arguement p
* only calculate p=5 and change to the correct way computing f_R
* Fixed conflict and made Google-style name changes
* prototype descent code and unit test for initializeWithDescent
* add averaging cost/time part in processing data
* initializewithDescent success in test
* Formatting and find example rather than hardcode
* Removed accidentally checked in cmake files
* give value to xi by block
* correct gradient descent
* correct xi
* }
* Fix wrapper
* Make Hat/Vee have alternating signs
* MakeATangentVector helpder function
* Fixed cmake files
* changed sign
* add line search
* unit test for line search
* test real data with line search
* correct comment
* Fix boost::uniform_real
* add save .dat file
* correct test case
* add explanation
* delete redundant cout
* add name to .dat output file
* correct checkR
* add get poses_  in shonan
* add Vector Point type for savig data
* Remove cmake file which magically re-appeared??
* Switched to std random library.
* Prepare Klaus test
* Add klaus3.g2o data.
* fix comment
* Fix derivatives
* Fixed broken GetDimension for Lie groups with variable dimension.
* Fix SOn tests to report correct dimension
* Added tests for Klaus3 data
* Add runWithRandomKlaus test for shonan.
* Finish runWithRandomKlaus unittest.
* Correct datafile.
* Correct the format.
* Added measured and keys methods
* Shonan works on Klaus data
* Create dense versions for wrappers, for testing
* Now store D, Q, and L
* Remove another cmake file incorrectly checked in.
* Found and fixed the bug in ComputeLambda !
* Now using Q in Lambdas calculation, so Lambdas agree with Eriksson18cvpr.
* Make FrobeniusFactor not use deprecated methods
* FrobeniusWormholeFactor takes Rot3 as argument
* Wrapped some more methods.
* Wrapped more methods
* Allow creating and populating BetweenFactorPose3s in python
* New constructors for ShonanAveraging
* add function of get measurements number
* Remove option not to use noise model
* wrap Use nrMeasurements
* Made Logmap a bit more tolerant of slightly degenerate rotations (with trace < -1)
* Allow for Anchor index
* Fix anchor bug
* Change outside view to Rot3 rather than SO3
* Add Lift in SOn class
* Make comet working
* Small fixes
* Delete extra function
* Add SOn::Lift
* Removed hardcoded flag
* Moved Frobenius factor to gtsam from unstable
* Added new tests and made an old regression pass again
* Cleaned up formatting and some comments, added EXPORT directives
* Throw exception if wrongly dimensioned values are given
* static_cast and other throw
* Fixed run-time dimension
* Added gauge-constraining factor
* LM parameters now passed in, added Gauge fixing
* 2D test scaffold
* Comments
* Pre-allocated generators
* Document API
* Add optional weight
* New prior weeights infrastructure
* Made d a template parameter
* Recursive Hat and RetractJacobian test
* Added Spectra 0.9.0 to 3rdparty
* Enabling 2D averaging
* Templatized Wormhole factor
* ignore xcode folder
* Fixed vec and VectorizedGenerators templates for fixed N!=3 or 4
* Simplifying constructors
Moved file loading to tests (for now)
All unit tests pass for d==3!
* Templated some methods internally
* Very generic parseToVector
* refactored load2d
* Very much improved FrobeniusWormholeFactor (Shonan) Jacobians
* SO(2) averaging works !
* Templated parse methods
* Switched to new Dataset paradigm
* Moved Shonan to gtsam
* Checked noise model is correctly gotten from file
* Fixed covariance bug
* Making Shonan wrapper work
* Renamed FrobeniusWormholeFactor to ShonanFactor and moved into its own compilation unit in gtsam/sfm
* Fixed wrong include
* Simplified interface (removed irrelevant random inits) and fixed eigenvector test
* Removed stray boost::none
* Added citation as suggested by Jose
* Made descent test deterministic
* Fixed some comments, commented out flaky test
Co-authored-by: Jing Wu <jingwu@gatech.edu>
Co-authored-by: jingwuOUO <wujing2951@gmail.com>
Co-authored-by: swang <swang736@gatech.edu>
Co-authored-by: ss <ss>
Co-authored-by: Fan Jiang <prof.fan@foxmail.com>
											
										 
											2020-08-17 19:43:10 +08:00
										 |  |  |     graph.emplace_shared<ShonanFactor3>( | 
					
						
							| 
									
										
										
										
											2020-08-17 05:30:52 +08:00
										 |  |  |         keys[0], keys[1], Rij, 4, model, G); | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-24 02:05:23 +08:00
										 |  |  |   std::mt19937 rng(42); | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Set parameters to be similar to ceres
 | 
					
						
							|  |  |  |   LevenbergMarquardtParams params; | 
					
						
							|  |  |  |   LevenbergMarquardtParams::SetCeresDefaults(¶ms); | 
					
						
							|  |  |  |   params.setLinearSolverType("MULTIFRONTAL_QR"); | 
					
						
							|  |  |  |   // params.setVerbosityLM("SUMMARY");
 | 
					
						
							|  |  |  |   // params.linearSolverType = LevenbergMarquardtParams::Iterative;
 | 
					
						
							| 
									
										
										
										
											2023-01-18 06:05:12 +08:00
										 |  |  |   // auto pcg = std::make_shared<PCGSolverParameters>();
 | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |   // pcg->preconditioner_ =
 | 
					
						
							| 
									
										
										
										
											2023-01-18 06:05:12 +08:00
										 |  |  |   // std::make_shared<SubgraphPreconditionerParameters>();
 | 
					
						
							|  |  |  |   // std::make_shared<BlockJacobiPreconditionerParameters>();
 | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |   // params.iterativeParams = pcg;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Optimize
 | 
					
						
							|  |  |  |   for (size_t i = 0; i < 100; i++) { | 
					
						
							|  |  |  |     gttic_(optimize); | 
					
						
							|  |  |  |     Values initial; | 
					
						
							| 
									
										
										
										
											2022-07-08 00:31:27 +08:00
										 |  |  |     initial.insert(0, SOn::Identity(4)); | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |     for (size_t j = 1; j < poses.size(); j++) { | 
					
						
							| 
									
										
										
										
											2020-08-02 03:43:55 +08:00
										 |  |  |       initial.insert(j, SOn::Random(rng, 4)); | 
					
						
							| 
									
										
										
										
											2020-06-20 11:33:29 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |     LevenbergMarquardtOptimizer lm(graph, initial, params); | 
					
						
							|  |  |  |     Values result = lm.optimize(); | 
					
						
							|  |  |  |     cout << "cost = " << graph.error(result) << endl; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   tictoc_finishedIteration_(); | 
					
						
							|  |  |  |   tictoc_print_(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return 0; | 
					
						
							|  |  |  | } |