gtsam/examples
Frank Dellaert 84afc94458
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 07:43:10 -04:00
..
Data Feature/shonan averaging (#473) 2020-08-17 07:43:10 -04:00
CMakeLists.txt Formatted and fixed discrete examples 2020-07-09 20:46:12 -04:00
CameraResectioning.cpp Fix all new gcc warnings/errors: make explicit virtual/override methods. 2020-07-26 11:20:42 +02:00
CreateSFMExampleData.cpp follow Google style guide naming convention for Sfm related data structs 2020-03-06 18:02:51 -05:00
DiscreteBayesNetExample.cpp Add BayesNet-inst.h at end of BayesNet.h 2020-07-14 08:50:20 -04:00
DiscreteBayesNet_FG.cpp New discrete example 2020-07-12 23:25:26 -04:00
FisheyeExample.cpp Reformatted and refactored 2020-05-09 19:08:17 -04:00
HMMExample.cpp Add BayesNet-inst.h at end of BayesNet.h 2020-07-14 08:50:20 -04:00
IMUKittiExampleGPS.cpp fix init issues with Vector3, use static matrices where possible 2020-07-10 21:45:01 -04:00
ISAM2Example_SmartFactor.cpp Replace addPrior<> with addPrior 2020-04-12 13:10:09 -04:00
ISAM2_SmartFactorStereo_IMU.cpp Replace addPrior<> with addPrior 2020-04-12 13:10:09 -04:00
ImuFactorExample2.cpp Replace addPrior<> with addPrior 2020-04-12 13:10:09 -04:00
ImuFactorsExample.cpp Merge branch 'develop' into isam2_imu_example 2020-07-13 21:06:24 -04:00
InverseKinematicsExampleExpressions.cpp Remove any unnecessary PriorFactor.h includes 2020-04-12 13:42:02 -04:00
LocalizationExample.cpp Fix all new gcc warnings/errors: make explicit virtual/override methods. 2020-07-26 11:20:42 +02:00
METISOrderingExample.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
OdometryExample.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
PlanarSLAMExample.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose2SLAMExample.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose2SLAMExampleExpressions.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose2SLAMExample_g2o.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose2SLAMExample_graph.cpp Replace addPrior<> with addPrior 2020-04-12 13:10:09 -04:00
Pose2SLAMExample_graphviz.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose2SLAMExample_lago.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose2SLAMStressTest.cpp Replace addPrior<> with addPrior 2020-04-12 13:10:09 -04:00
Pose2SLAMwSPCG.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose3Localization.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose3SLAMExampleExpressions_BearingRangeWithTransform.cpp remove trailing spaces 2019-02-11 10:58:34 -05:00
Pose3SLAMExample_changeKeys.cpp Remove any unnecessary PriorFactor.h includes 2020-04-12 13:42:02 -04:00
Pose3SLAMExample_g2o.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose3SLAMExample_initializePose3Chordal.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
Pose3SLAMExample_initializePose3Gradient.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
README.md Imroved ReadMe, now in markup 2016-06-05 18:58:35 -07:00
RangeISAMExample_plaza2.cpp Replace addPrior<> with addPrior 2020-04-12 13:10:09 -04:00
SFMExample.cpp Explicit type definition to handle warning 2020-07-10 23:01:18 -04:00
SFMExampleExpressions.cpp replaced/appended all calls to SimpleCamera with PinholeCameraCal3_S2 2020-02-21 19:42:55 -05:00
SFMExampleExpressions_bal.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
SFMExample_SmartFactor.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
SFMExample_SmartFactorPCG.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
SFMExample_bal.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
SFMExample_bal_COLAMD_METIS.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
SFMdata.h replaced/appended all calls to SimpleCamera with PinholeCameraCal3_S2 2020-02-21 19:42:55 -05:00
SelfCalibrationExample.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
SimpleRotation.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
SolverComparer.cpp replace boost random with std random 2020-07-23 14:05:23 -04:00
StereoVOExample.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
StereoVOExample_large.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
TimeTBB.cpp change to more efficient call of threaded functions 2020-05-06 16:47:16 -04:00
UGM_chain.cpp Formatted and fixed discrete examples 2020-07-09 20:46:12 -04:00
UGM_small.cpp Formatted and fixed discrete examples 2020-07-09 20:46:12 -04:00
VisualISAM2Example.cpp Replace addPrior<> with addPrior 2020-04-12 13:10:09 -04:00
VisualISAMExample.cpp Reformatted some and use of auto 2020-05-09 19:08:31 -04:00
easyPoint2KalmanFilter.cpp Change PriorFactor includes from gtsam/slam to gtsam/nonlinear 2020-04-10 22:26:22 -04:00
elaboratePoint2KalmanFilter.cpp Change PriorFactor includes from gtsam/slam to gtsam/nonlinear 2020-04-10 22:26:22 -04:00

README.md

GTSAM Examples

This directory contains all GTSAM C++ examples GTSAM pertaining to SFM

Basic Examples:

  • SimpleRotation: a simple example of optimizing a single rotation according to a single prior
  • CameraResectioning: resection camera from some known points
  • SFMExample: basic structure from motion
  • SFMExample_bal: same, but read data from read from BAL file
  • SelfCalibrationExample: Do SFM while also optimizing for calibration

Stereo Visual Odometry Examples

Visual odometry using a stereo rig:

  • StereoVOExample: basic example of stereo VO
  • StereoVOExample_large: larger, with a snippet of Kitti data

More Advanced Examples

The following examples illustrate some concepts from Georgia Tech's research papers, listed in the references section at the end:

  • VisualISAMExample: uses iSAM [TRO08]
  • VisualISAM2Example: uses iSAM2 [IJRR12]
  • SFMExample_SmartFactor: uses smartFactors [ICRA14]

Kalman Filter Examples

  • elaboratePoint2KalmanFilter: simple linear Kalman filter on a moving 2D point, but done using factor graphs
  • easyPoint2KalmanFilter: uses the generic templated Kalman filter class to do the same
  • fullStateKalmanFilter: simple 1D example with a full-state filter
  • errorStateKalmanFilter: simple 1D example of a moving target measured by a accelerometer, incl. drift-rate bias

2D Pose SLAM

  • LocalizationExample.cpp: modeling robot motion
  • LocalizationExample2.cpp: example with GPS like measurements
  • Pose2SLAMExample: A 2D Pose SLAM example using the predefined typedefs in gtsam/slam/pose2SLAM.h
  • Pose2SLAMExample_advanced: same, but uses an Optimizer object
  • Pose2SLAMwSPCG: solve a simple 3 by 3 grid of Pose2 SLAM problem by using easy SPCG interface

Planar SLAM with landmarks

  • PlanarSLAMExample: simple robotics example using the pre-built planar SLAM domain
  • PlanarSLAMExample_selfcontained: simple robotics example with all typedefs internal to this script.

Visual SLAM

The directory vSLAMexample includes 2 simple examples using GTSAM:

  • vSFMexample using visual SLAM for structure-from-motion (SFM)
  • vISAMexample using visual SLAM and ISAM for incremental SLAM updates

See the separate README file there.

##Undirected Graphical Models (UGM) The best representation for a Markov Random Field is a factor graph :-) This is illustrated with some discrete examples from the UGM MATLAB toolbox, which can be found at http://www.di.ens.fr/~mschmidt/Software/UGM

##Building and Running To build, cd into the directory and do:

mkdir build
cd build
cmake ..

For each .cpp file in this directory two make targets are created, one to build the executable, and one to build and run it. For example, the file CameraResectioning.cpp contains simple example to resection a camera from 4 known points. You can build it using

make CameraResectioning

or build and run it immediately with

make CameraResectioning.run

which should output:

Final result:
Values with 1 values:
Value x1: R:
[
           1,	         0.0,	         0.0,	
         0.0,	          -1,	         0.0,	
         0.0,	         0.0,	          -1,	
];
t: [0, 0, 2]';

References