diff --git a/gtsam.h b/gtsam.h index 9c6f76527..88efe7618 100644 --- a/gtsam.h +++ b/gtsam.h @@ -82,8 +82,38 @@ * - TODO: Handle gtsam::Rot3M conversions to quaternions */ +/*namespace std { + template + //Module.cpp needs to be changed to allow lowercase classnames + class vector + { + //Capcaity + size_t size() const; + size_t max_size() const; + void resize(size_t sz, T c = T()); + size_t capacity() const; + bool empty() const; + void reserve(size_t n); + + //Element acces + T& at(size_t n); + const T& at(size_t n) const; + T& front(); + const T& front() const; + T& back(); + const T& back() const; + + //Modifiers + void assign(size_t n, const T& u); + void push_back(const T& x); + void pop_back(); + }; +}*/ + namespace gtsam { +//typedef std::vector IndexVector; + //************************************************************************* // base //************************************************************************* @@ -664,14 +694,12 @@ virtual class SimpleCamera : gtsam::Value { //************************************************************************* // inference //************************************************************************* +#include class Permutation { // Standard Constructors and Named Constructors Permutation(); Permutation(size_t nVars); static gtsam::Permutation Identity(size_t nVars); - // FIXME: Cannot currently wrap std::vector - //static gtsam::Permutation PullToFront(const vector& toFront, size_t size, bool filterDuplicates); - //static gtsam::Permutation PushToBack(const vector& toBack, size_t size, bool filterDuplicates = false); // Testable void print(string s) const; @@ -684,10 +712,16 @@ class Permutation { void resize(size_t newSize); gtsam::Permutation* permute(const gtsam::Permutation& permutation) const; gtsam::Permutation* inverse() const; + // FIXME: Cannot currently wrap std::vector + //static gtsam::Permutation PullToFront(const vector& toFront, size_t size, bool filterDuplicates); + //static gtsam::Permutation PushToBack(const vector& toBack, size_t size, bool filterDuplicates = false); + gtsam::Permutation* partialPermutation(const gtsam::Permutation& selector, const gtsam::Permutation& partialPermutation) const; }; class IndexFactor { // Standard Constructors and Named Constructors + IndexFactor(const gtsam::IndexFactor& f); + IndexFactor(const gtsam::IndexConditional& c); IndexFactor(); IndexFactor(size_t j); IndexFactor(size_t j1, size_t j2); @@ -697,6 +731,7 @@ class IndexFactor { IndexFactor(size_t j1, size_t j2, size_t j3, size_t j4, size_t j5, size_t j6); // FIXME: Must wrap std::set for this to work //IndexFactor(const std::set& js); + void permuteWithInverse(const gtsam::Permutation& inversePermutation); // From Factor size_t size() const; @@ -726,6 +761,10 @@ class IndexConditional { size_t nrFrontals() const; size_t nrParents() const; gtsam::IndexFactor* toFactor() const; + + //Advanced interface + bool permuteSeparatorWithInverse(const gtsam::Permutation& inversePermutation); + void permuteWithInverse(const gtsam::Permutation& inversePermutation); }; #include @@ -742,11 +781,15 @@ class SymbolicBayesNet { // Standard interface size_t size() const; void push_back(const gtsam::IndexConditional* conditional); - // FIXME: cannot overload functions - //void push_back(const SymbolicBayesNet bn); + //TODO:Throws parse error + //void push_back(const gtsam::SymbolicBayesNet bn); void push_front(const gtsam::IndexConditional* conditional); - // FIXME: cannot overload functions - //void push_front(const SymbolicBayesNet bn); + //TODO:Throws parse error + //void push_front(const gtsam::SymbolicBayesNet bn); + + //Advanced Interface + gtsam::IndexConditional* front() const; + gtsam::IndexConditional* back() const; void pop_front(); void permuteWithInverse(const gtsam::Permutation& inversePermutation); bool permuteSeparatorWithInverse(const gtsam::Permutation& inversePermutation); @@ -766,6 +809,7 @@ class SymbolicBayesTree { bool equals(const gtsam::SymbolicBayesTree& other, double tol) const; // Standard interface + size_t findParentClique(const gtsam::IndexConditional& parents) const; size_t size() const; void saveGraph(string s) const; void clear(); @@ -788,7 +832,13 @@ class SymbolicFactorGraph { // FIXME: Must wrap FastSet for this to work //FastSet keys() const; - pair eliminateFrontals(size_t nFrontals) const; + //Advanced Interface + void push_factor(size_t key); + void push_factor(size_t key1, size_t key2); + void push_factor(size_t key1, size_t key2, size_t key3); + void push_factor(size_t key1, size_t key2, size_t key3, size_t key4); + + pair eliminateFrontals(size_t nFrontals) const; }; #include @@ -803,6 +853,7 @@ class SymbolicSequentialSolver { // Standard interface gtsam::SymbolicBayesNet* eliminate() const; + gtsam::IndexFactor* marginalFactor(size_t j) const; }; #include @@ -817,21 +868,23 @@ class SymbolicMultifrontalSolver { // Standard interface gtsam::SymbolicBayesTree* eliminate() const; + gtsam::IndexFactor* marginalFactor(size_t j) const; }; #include class VariableIndex { // Standard Constructors and Named Constructors VariableIndex(); - // FIXME: Handle templates somehow - //template VariableIndex(const FactorGraph& factorGraph, size_t nVariables); - //template VariableIndex(const FactorGraph& factorGraph); + // TODO: Templetize constructor when wrap supports it + //template + //VariableIndex(const T& factorGraph, size_t nVariables); + //VariableIndex(const T& factorGraph); VariableIndex(const gtsam::SymbolicFactorGraph& factorGraph); VariableIndex(const gtsam::SymbolicFactorGraph& factorGraph, size_t nVariables); -// VariableIndex(const gtsam::GaussianFactorGraph& factorGraph); -// VariableIndex(const gtsam::GaussianFactorGraph& factorGraph, size_t nVariables); -// VariableIndex(const gtsam::NonlinearFactorGraph& factorGraph); -// VariableIndex(const gtsam::NonlinearFactorGraph& factorGraph, size_t nVariables); + VariableIndex(const gtsam::GaussianFactorGraph& factorGraph); + VariableIndex(const gtsam::GaussianFactorGraph& factorGraph, size_t nVariables); + VariableIndex(const gtsam::NonlinearFactorGraph& factorGraph); + VariableIndex(const gtsam::NonlinearFactorGraph& factorGraph, size_t nVariables); VariableIndex(const gtsam::VariableIndex& other); // Testable @@ -845,6 +898,25 @@ class VariableIndex { void permuteInPlace(const gtsam::Permutation& permutation); }; +#include +template +virtual class BayesTree { + + //Constructors + BayesTree(); + + //Standard Interface + bool equals(const This& other, double tol) const; + void print(string s); + //size_t findParentClique(const gtsam::IndexVector& parents) const; + size_t size(); + CLIQUE* root() const; + void clear(); + void insert(const CLIQUE* subtree); +}; + +typedef gtsam::BayesTree ISAM2BayesTree; + //************************************************************************* // linear //************************************************************************* @@ -857,7 +929,8 @@ virtual class Base { virtual class Gaussian : gtsam::noiseModel::Base { static gtsam::noiseModel::Gaussian* SqrtInformation(Matrix R); static gtsam::noiseModel::Gaussian* Covariance(Matrix R); -// Matrix R() const; // FIXME: cannot parse!!! + //Matrix R() const; // FIXME: cannot parse!!! + bool equals(gtsam::noiseModel::Base& expected, double tol); void print(string s) const; }; @@ -869,6 +942,20 @@ virtual class Diagonal : gtsam::noiseModel::Gaussian { void print(string s) const; }; +virtual class Constrained : gtsam::noiseModel::Diagonal { + static gtsam::noiseModel::Constrained* MixedSigmas(const Vector& mu, const Vector& sigmas); + static gtsam::noiseModel::Constrained* MixedSigmas(double m, const Vector& sigmas); + static gtsam::noiseModel::Constrained* MixedVariances(const Vector& mu, const Vector& variances); + static gtsam::noiseModel::Constrained* MixedVariances(const Vector& variances); + static gtsam::noiseModel::Constrained* MixedPrecisions(const Vector& mu, const Vector& precisions); + static gtsam::noiseModel::Constrained* MixedPrecisions(const Vector& precisions); + + static gtsam::noiseModel::Constrained* All(size_t dim); + static gtsam::noiseModel::Constrained* All(size_t dim, double m); + + gtsam::noiseModel::Constrained* unit() const; +}; + virtual class Isotropic : gtsam::noiseModel::Diagonal { static gtsam::noiseModel::Isotropic* Sigma(size_t dim, double sigma); static gtsam::noiseModel::Isotropic* Variance(size_t dim, double varianace); @@ -884,44 +971,80 @@ virtual class Unit : gtsam::noiseModel::Isotropic { #include class Sampler { + //Constructors Sampler(gtsam::noiseModel::Diagonal* model, int seed); Sampler(Vector sigmas, int seed); Sampler(int seed); + //Standard Interface size_t dim() const; Vector sigmas() const; gtsam::noiseModel::Diagonal* model() const; - Vector sample(); Vector sampleNewModel(gtsam::noiseModel::Diagonal* model); }; class VectorValues { + //Constructors VectorValues(); + VectorValues(const gtsam::VectorValues& other); VectorValues(size_t nVars, size_t varDim); - void print(string s) const; - bool equals(const gtsam::VectorValues& expected, double tol) const; + + //Named Constructors + static gtsam::VectorValues Zero(const gtsam::VectorValues& model); + static gtsam::VectorValues Zero(size_t nVars, size_t varDim); + static gtsam::VectorValues SameStructure(const gtsam::VectorValues& other); + + //Standard Interface size_t size() const; size_t dim(size_t j) const; size_t dim() const; bool exists(size_t j) const; + void print(string s) const; + bool equals(const gtsam::VectorValues& expected, double tol) const; void insert(size_t j, Vector value); Vector vector() const; Vector at(size_t j) const; + + //Advanced Interface + void resizeLike(const gtsam::VectorValues& other); + void resize(size_t nVars, size_t varDim); + void setZero(); + + //FIXME: Parse errors with vector() + //const Vector& vector() const; + //Vector& vector(); + bool hasSameStructure(const gtsam::VectorValues& other) const; + double dot(const gtsam::VectorValues& V) const; + double norm() const; }; class GaussianConditional { + //Constructors GaussianConditional(size_t key, Vector d, Matrix R, Vector sigmas); GaussianConditional(size_t key, Vector d, Matrix R, size_t name1, Matrix S, Vector sigmas); GaussianConditional(size_t key, Vector d, Matrix R, size_t name1, Matrix S, size_t name2, Matrix T, Vector sigmas); + + //Standard Interface void print(string s) const; bool equals(const gtsam::GaussianConditional &cg, double tol) const; + size_t dim() const; + + //Advanced Interface + Matrix computeInformation() const; + gtsam::JacobianFactor* toFactor() const; + void solveInPlace(gtsam::VectorValues& x) const; + void solveTransposeInPlace(gtsam::VectorValues& gy) const; + void scaleFrontalsBySigma(gtsam::VectorValues& gy) const; }; class GaussianDensity { + //Constructors GaussianDensity(size_t key, Vector d, Matrix R, Vector sigmas); + + //Standard Interface void print(string s) const; Vector mean() const; Matrix information() const; @@ -929,13 +1052,34 @@ class GaussianDensity { }; class GaussianBayesNet { + //Constructors GaussianBayesNet(); + + //Standard Interface void print(string s) const; bool equals(const gtsam::GaussianBayesNet& cbn, double tol) const; void push_back(gtsam::GaussianConditional* conditional); void push_front(gtsam::GaussianConditional* conditional); }; +//Non-Class methods found in GaussianBayesNet.h +//FIXME: No MATLAB documentation for these functions! +/*gtsam::GaussianBayesNet scalarGaussian(size_t key, double mu, double sigma); +gtsam::GaussianBayesNet simpleGaussian(size_t key, const Vector& mu, double sigma); +void push_front(gtsam::GaussianBayesNet& bn, size_t key, Vector d, Matrix R, size_t name1, Matrix S, Vector sigmas); +void push_front(gtsam::GaussianBayesNet& bn, size_t key, Vector d, Matrix R, size_t name1, Matrix S, size_t name2, Matrix T, Vector sigmas); +gtsam::VectorValues* allocateVectorValues(const gtsam::GaussianBayesNet& bn); +gtsam::VectorValues optimize(const gtsam::GaussianBayesNet& bn); +void optimizeInPlace(const gtsam::GaussianBayesNet& bn, gtsam::VectorValues& x); +gtsam::VectorValues optimizeGradientSearch(const gtsam::GaussianBayesNet& bn); +void optimizeGradientSearchInPlace(const gtsam::GaussianBayesNet& bn, gtsam::VectorValues& grad); +gtsam::VectorValues backSubstitute(const gtsam::GaussianBayesNet& bn, const gtsam::VectorValues& gx); +gtsam::VectorValues backSubstituteTranspose(const gtsam::GaussianBayesNet& bn, const gtsam::VectorValues& gx); +pair matrix(const gtsam::GaussianBayesNet& bn); +double determinant(const gtsam::GaussianBayesNet& bayesNet); +gtsam::VectorValues gradient(const gtsam::GaussianBayesNet& bayesNet, const gtsam::VectorValues& x0); +void gradientAtZero(const gtsam::GaussianBayesNet& bayesNet, const gtsam::VectorValues& g);*/ + virtual class GaussianFactor { void print(string s) const; bool equals(const gtsam::GaussianFactor& lf, double tol) const; @@ -945,6 +1089,7 @@ virtual class GaussianFactor { }; virtual class JacobianFactor : gtsam::GaussianFactor { + //Constructors JacobianFactor(); JacobianFactor(Vector b_in); JacobianFactor(size_t i1, Matrix A1, Vector b, @@ -954,21 +1099,46 @@ virtual class JacobianFactor : gtsam::GaussianFactor { JacobianFactor(size_t i1, Matrix A1, size_t i2, Matrix A2, size_t i3, Matrix A3, Vector b, const gtsam::noiseModel::Diagonal* model); JacobianFactor(const gtsam::GaussianFactor& factor); + + //Testable void print(string s) const; void printKeys(string s) const; bool equals(const gtsam::GaussianFactor& lf, double tol) const; size_t size() const; + Vector unweighted_error(const gtsam::VectorValues& c) const; + Vector error_vector(const gtsam::VectorValues& c) const; double error(const gtsam::VectorValues& c) const; - gtsam::GaussianFactor* negate() const; - bool empty() const; - Vector getb() const; - pair matrix() const; - Matrix matrix_augmented() const; - gtsam::GaussianConditional* eliminateFirst(); - gtsam::GaussianConditional* eliminate(size_t nrFrontals); + + //Standard Interface + gtsam::GaussianFactor* negate() const; + bool empty() const; + Matrix getA() const; + Vector getb() const; + size_t rows() const; + size_t cols() const; + size_t numberOfRows() const; + bool isConstrained() const; + pair matrix() const; + Matrix matrix_augmented() const; + + gtsam::GaussianConditional* eliminateFirst(); + gtsam::GaussianConditional* eliminate(size_t nrFrontals); + gtsam::GaussianFactor* negate() const; + Matrix computeInformation() const; + void transposeMultiplyAdd(double alpha, const Vector& e, gtsam::VectorValues& x) const; + gtsam::JacobianFactor whiten() const; + gtsam::GaussianConditional* eliminateFirst(); + gtsam::GaussianConditional* eliminate(size_t nFrontals); + gtsam::GaussianConditional* splitConditional(size_t nFrontals); + + void setModel(bool anyConstrained, const Vector& sigmas); + void assertInvariants() const; + + //gtsam::SharedDiagonal& get_model(); }; virtual class HessianFactor : gtsam::GaussianFactor { + //Constructors HessianFactor(const gtsam::HessianFactor& gf); HessianFactor(); HessianFactor(size_t j, Matrix G, Vector g, double f); @@ -980,12 +1150,26 @@ virtual class HessianFactor : gtsam::GaussianFactor { double f); HessianFactor(const gtsam::GaussianConditional& cg); HessianFactor(const gtsam::GaussianFactor& factor); + + //Testable size_t size() const; void print(string s) const; void printKeys(string s) const; bool equals(const gtsam::GaussianFactor& lf, double tol) const; double error(const gtsam::VectorValues& c) const; + + //Standard Interface + size_t rows() const; gtsam::GaussianFactor* negate() const; + Matrix info() const; + double constantTerm() const; + Vector linearTerm() const; + Matrix computeInformation() const; + + //Advanced Interface + void partialCholesky(size_t nrFrontals); + gtsam::GaussianConditional* splitEliminatedFactor(size_t nrFrontals); + void assertInvariants() const; }; class GaussianFactorGraph { @@ -1003,6 +1187,7 @@ class GaussianFactorGraph { // Building the graph void push_back(gtsam::GaussianFactor* factor); + void add(const gtsam::GaussianFactor& factor); void add(Vector b); void add(size_t key1, Matrix A1, Vector b, const gtsam::noiseModel::Diagonal* model); void add(size_t key1, Matrix A1, size_t key2, Matrix A2, Vector b, @@ -1010,6 +1195,9 @@ class GaussianFactorGraph { void add(size_t key1, Matrix A1, size_t key2, Matrix A2, size_t key3, Matrix A3, Vector b, const gtsam::noiseModel::Diagonal* model); + //Permutations + void permuteWithInverse(const gtsam::Permutation& inversePermutation); + // error and probability double error(const gtsam::VectorValues& c) const; double probPrime(const gtsam::VectorValues& c) const; @@ -1028,19 +1216,48 @@ class GaussianFactorGraph { pair hessian() const; }; +//Non-Class functions in GaussianFactorGraph.h +/*void multiplyInPlace(const gtsam::GaussianFactorGraph& fg, const gtsam::VectorValues& x, gtsam::Errors& e); +gtsam::VectorValues gradient(const gtsam::GaussianFactorGraph& fg, const gtsam::VectorValues& x0); +void gradientAtZero(const gtsam::GaussianFactorGraph& fg, gtsam::VectorValues& g); +void residual(const gtsam::GaussianFactorGraph& fg, const gtsam::VectorValues& x, gtsam::VectorValues& r); +void multiply(const gtsam::GaussianFactorGraph& fg, const gtsam::VectorValues& x, gtsam::VectorValues& r); +void transposeMultiply(const gtsam::GaussianFactorGraph& fg, const gtsam::VectorValues& x, gtsam::VectorValues& r);*/ + +class Errors { + //Constructors + Errors(); + Errors(const gtsam::VectorValues& V); + + //Testable + void print(string s); + bool equals(const gtsam::Errors& expected, double tol) const; +}; + +//Non-Class functions for Errors +//double dot(const gtsam::Errors& A, const gtsam::Errors& b); + class GaussianISAM { + //Constructor GaussianISAM(); + + //Standard Interface void saveGraph(string s) const; gtsam::GaussianFactor* marginalFactor(size_t j) const; gtsam::GaussianBayesNet* marginalBayesNet(size_t key) const; Matrix marginalCovariance(size_t key) const; gtsam::GaussianBayesNet* jointBayesNet(size_t key1, size_t key2) const; + void clear(); }; #include class GaussianSequentialSolver { + //Constructors GaussianSequentialSolver(const gtsam::GaussianFactorGraph& graph, bool useQR); + + //Standard Interface + void replaceFactors(const gtsam::GaussianFactorGraph* factorGraph); gtsam::GaussianBayesNet* eliminate() const; gtsam::VectorValues* optimize() const; gtsam::GaussianFactor* marginalFactor(size_t j) const; @@ -1053,6 +1270,7 @@ virtual class IterativeOptimizationParameters { string getVerbosity() const; void setKernel(string s) ; void setVerbosity(string s) ; + void print() const; }; //virtual class IterativeSolver { @@ -1074,6 +1292,7 @@ virtual class ConjugateGradientParameters : gtsam::IterativeOptimizationParamete void setReset(size_t value); void setEpsilon_rel(double value); void setEpsilon_abs(double value); + void print(string s); }; #include @@ -1084,6 +1303,7 @@ virtual class SubgraphSolverParameters : gtsam::ConjugateGradientParameters { class SubgraphSolver { SubgraphSolver(const gtsam::GaussianFactorGraph &A, const gtsam::SubgraphSolverParameters ¶meters); + SubgraphSolver(const gtsam::GaussianFactorGraph &Ab1, const gtsam::GaussianFactorGraph &Ab2, const gtsam::SubgraphSolverParameters ¶meters); gtsam::VectorValues optimize() const; }; @@ -1194,27 +1414,29 @@ class Values { size_t size() const; bool empty() const; - void clear(); - size_t dim() const; + void clear(); + size_t dim() const; void print(string s) const; bool equals(const gtsam::Values& other, double tol) const; void insert(size_t j, const gtsam::Value& value); - void insert(const gtsam::Values& values); - void update(size_t j, const gtsam::Value& val); - void update(const gtsam::Values& values); - void erase(size_t j); + void insert(const gtsam::Values& values); + void update(size_t j, const gtsam::Value& val); + void update(const gtsam::Values& values); + void erase(size_t j); + void swap(gtsam::Values& values); bool exists(size_t j) const; gtsam::Value at(size_t j) const; gtsam::KeyList keys() const; - gtsam::VectorValues zeroVectors(const gtsam::Ordering& ordering) const; + gtsam::VectorValues zeroVectors(const gtsam::Ordering& ordering) const; + gtsam::Ordering* orderingArbitrary(size_t firstVar) const; - gtsam::Values retract(const gtsam::VectorValues& delta, const gtsam::Ordering& ordering) const; - gtsam::VectorValues localCoordinates(const gtsam::Values& cp, const gtsam::Ordering& ordering) const; - void localCoordinates(const gtsam::Values& cp, const gtsam::Ordering& ordering, gtsam::VectorValues& delta) const; + gtsam::Values retract(const gtsam::VectorValues& delta, const gtsam::Ordering& ordering) const; + gtsam::VectorValues localCoordinates(const gtsam::Values& cp, const gtsam::Ordering& ordering) const; + void localCoordinates(const gtsam::Values& cp, const gtsam::Ordering& ordering, gtsam::VectorValues& delta) const; }; // Actually a FastList @@ -1469,6 +1691,20 @@ class ISAM2Params { void setEnablePartialRelinearizationCheck(bool enablePartialRelinearizationCheck); }; +virtual class ISAM2Clique { + + //Constructors + ISAM2Clique(const gtsam::GaussianConditional* conditional); + + //Standard Interface + Vector gradientContribution() const; + gtsam::ISAM2Clique* clone() const; + void print(string s); + + void permuteWithInverse(const gtsam::Permutation& inversePermutation); + bool permuteSeparatorWithInverse(const gtsam::Permutation& inversePermutation); +}; + class ISAM2Result { ISAM2Result(); @@ -1480,7 +1716,7 @@ class ISAM2Result { size_t getCliques() const; }; -class ISAM2 { +virtual class ISAM2 : gtsam::ISAM2BayesTree { ISAM2(); ISAM2(const gtsam::ISAM2Params& params); @@ -1493,7 +1729,7 @@ class ISAM2 { gtsam::ISAM2Result update(const gtsam::NonlinearFactorGraph& newFactors, const gtsam::Values& newTheta); gtsam::ISAM2Result update(const gtsam::NonlinearFactorGraph& newFactors, const gtsam::Values& newTheta, const gtsam::KeyVector& removeFactorIndices); // TODO: wrap the full version of update - //void update(const gtsam::NonlinearFactorGraph& newFactors, const gtsam::Values& newTheta, const gtsam::KeyVector& removeFactorIndices, FastMap& constrainedKeys); + //void update(const gtsam::NonlinearFactorGraph& newFactors, const gtsam::Values& newTheta, const gtsam::KeyVector& removeFactorIndices, FastMap& constrainedKeys); //void update(const gtsam::NonlinearFactorGraph& newFactors, const gtsam::Values& newTheta, const gtsam::KeyVector& removeFactorIndices, FastMap& constrainedKeys, bool force_relinearize); gtsam::Values getLinearizationPoint() const; diff --git a/gtsam/geometry/CalibratedCamera.h b/gtsam/geometry/CalibratedCamera.h index a83a41827..6a52f7cb5 100644 --- a/gtsam/geometry/CalibratedCamera.h +++ b/gtsam/geometry/CalibratedCamera.h @@ -94,6 +94,7 @@ namespace gtsam { /** * Create a level camera at the given 2D pose and height * @param pose2 specifies the location and viewing direction + * @param height specifies the height of the camera (along the positive Z-axis) * (theta 0 = looking in direction of positive X axis) */ static CalibratedCamera Level(const Pose2& pose2, double height); @@ -126,8 +127,9 @@ namespace gtsam { /** * This function receives the camera pose and the landmark location and * returns the location the point is supposed to appear in the image - * @param camera the CalibratedCamera * @param point a 3D point to be projected + * @param D_intrinsic_pose the optionally computed Jacobian with respect to pose + * @param D_intrinsic_point the optionally computed Jacobian with respect to the 3D point * @return the intrinsic coordinates of the projected point */ Point2 project(const Point3& point, @@ -150,6 +152,8 @@ namespace gtsam { /** * Calculate range to a landmark * @param point 3D location of landmark + * @param H1 optionally computed Jacobian with respect to pose + * @param H2 optionally computed Jacobian with respect to the 3D point * @return range (double) */ double range(const Point3& point, @@ -160,6 +164,8 @@ namespace gtsam { /** * Calculate range to another pose * @param pose Other SO(3) pose + * @param H1 optionally computed Jacobian with respect to pose + * @param H2 optionally computed Jacobian with respect to the 3D point * @return range (double) */ double range(const Pose3& pose, @@ -170,6 +176,8 @@ namespace gtsam { /** * Calculate range to another camera * @param camera Other camera + * @param H1 optionally computed Jacobian with respect to pose + * @param H2 optionally computed Jacobian with respect to the 3D point * @return range (double) */ double range(const CalibratedCamera& camera, diff --git a/gtsam/geometry/PinholeCamera.h b/gtsam/geometry/PinholeCamera.h index 79cbd8a87..8ec300ac6 100644 --- a/gtsam/geometry/PinholeCamera.h +++ b/gtsam/geometry/PinholeCamera.h @@ -62,6 +62,7 @@ namespace gtsam { /** * Create a level camera at the given 2D pose and height + * @param K the calibration * @param pose2 specifies the location and viewing direction * (theta 0 = looking in direction of positive X axis) * @param height camera height @@ -290,6 +291,8 @@ namespace gtsam { /** * Calculate range to a landmark * @param point 3D location of landmark + * @param H1 the optionally computed Jacobian with respect to pose + * @param H2 the optionally computed Jacobian with respect to the landmark * @return range (double) */ double range(const Point3& point, @@ -308,6 +311,8 @@ namespace gtsam { /** * Calculate range to another pose * @param pose Other SO(3) pose + * @param H1 the optionally computed Jacobian with respect to pose + * @param H2 the optionally computed Jacobian with respect to the landmark * @return range (double) */ double range(const Pose3& pose, @@ -326,6 +331,8 @@ namespace gtsam { /** * Calculate range to another camera * @param camera Other camera + * @param H1 the optionally computed Jacobian with respect to pose + * @param H2 the optionally computed Jacobian with respect to the landmark * @return range (double) */ template @@ -351,6 +358,8 @@ namespace gtsam { /** * Calculate range to another camera * @param camera Other camera + * @param H1 the optionally computed Jacobian with respect to pose + * @param H2 the optionally computed Jacobian with respect to the landmark * @return range (double) */ double range(const CalibratedCamera& camera, diff --git a/gtsam/inference/BayesTree-inl.h b/gtsam/inference/BayesTree-inl.h index 501a8aabd..3d5276be8 100644 --- a/gtsam/inference/BayesTree-inl.h +++ b/gtsam/inference/BayesTree-inl.h @@ -167,8 +167,8 @@ namespace gtsam { template void BayesTree::addClique(const sharedClique& clique, const sharedClique& parent_clique) { nodes_.resize(std::max((*clique)->lastFrontalKey()+1, nodes_.size())); - BOOST_FOREACH(Index key, (*clique)->frontals()) - nodes_[key] = clique; + BOOST_FOREACH(Index j, (*clique)->frontals()) + nodes_[j] = clique; if (parent_clique != NULL) { clique->parent_ = parent_clique; parent_clique->children_.push_back(clique); @@ -185,8 +185,8 @@ namespace gtsam { const sharedConditional& conditional, std::list& child_cliques) { sharedClique new_clique(new Clique(conditional)); nodes_.resize(std::max(conditional->lastFrontalKey()+1, nodes_.size())); - BOOST_FOREACH(Index key, conditional->frontals()) - nodes_[key] = new_clique; + BOOST_FOREACH(Index j, conditional->frontals()) + nodes_[j] = new_clique; new_clique->children_ = child_cliques; BOOST_FOREACH(sharedClique& child, child_cliques) child->parent_ = new_clique; @@ -210,13 +210,13 @@ namespace gtsam { #endif if(debug) conditional->print("Adding conditional "); if(debug) clique->print("To clique "); - Index key = conditional->lastFrontalKey(); - bayesTree.nodes_.resize(std::max(key+1, bayesTree.nodes_.size())); - bayesTree.nodes_[key] = clique; - FastVector newKeys((*clique)->size() + 1); - newKeys[0] = key; - std::copy((*clique)->begin(), (*clique)->end(), newKeys.begin()+1); - clique->conditional_ = CONDITIONAL::FromKeys(newKeys, (*clique)->nrFrontals() + 1); + Index j = conditional->lastFrontalKey(); + bayesTree.nodes_.resize(std::max(j+1, bayesTree.nodes_.size())); + bayesTree.nodes_[j] = clique; + FastVector newIndices((*clique)->size() + 1); + newIndices[0] = j; + std::copy((*clique)->begin(), (*clique)->end(), newIndices.begin()+1); + clique->conditional_ = CONDITIONAL::FromKeys(newIndices, (*clique)->nrFrontals() + 1); if(debug) clique->print("Expanded clique is "); clique->assertInvariants(); } @@ -234,8 +234,8 @@ namespace gtsam { BOOST_FOREACH(sharedClique child, clique->children_) child->parent_ = typename Clique::weak_ptr(); - BOOST_FOREACH(Index key, (*clique->conditional())) { - nodes_[key].reset(); + BOOST_FOREACH(Index j, (*clique->conditional())) { + nodes_[j].reset(); } } @@ -338,7 +338,7 @@ namespace gtsam { template void BayesTree::print(const std::string& s, const IndexFormatter& indexFormatter) const { if (root_.use_count() == 0) { - printf("WARNING: BayesTree.print encountered a forest...\n"); + std::cout << "WARNING: BayesTree.print encountered a forest..." << std::endl; return; } std::cout << s << ": clique size == " << size() << ", node size == " << nodes_.size() << std::endl; @@ -379,7 +379,7 @@ namespace gtsam { { static const bool debug = false; - // get key and parents + // get indices and parents const typename CONDITIONAL::Parents& parents = conditional->parents(); if(debug) conditional->print("Adding conditional "); @@ -402,7 +402,7 @@ namespace gtsam { if ((*parent_clique)->size() == size_t(parents.size())) { if(debug) std::cout << "Adding to parent clique" << std::endl; #ifndef NDEBUG - // Debug check that the parent keys of the new conditional match the keys + // Debug check that the parent indices of the new conditional match the indices // currently in the clique. // list::const_iterator parent = parents.begin(); // typename Clique::const_iterator cond = parent_clique->begin(); @@ -441,7 +441,7 @@ namespace gtsam { template void BayesTree::fillNodesIndex(const sharedClique& subtree) { // Add each frontal variable of this root node - BOOST_FOREACH(const Index& key, subtree->conditional()->frontals()) { nodes_[key] = subtree; } + BOOST_FOREACH(const Index& j, subtree->conditional()->frontals()) { nodes_[j] = subtree; } // Fill index for each child typedef typename BayesTree::sharedClique sharedClique; BOOST_FOREACH(const sharedClique& child, subtree->children_) { @@ -480,26 +480,26 @@ namespace gtsam { /* ************************************************************************* */ template typename CONDITIONAL::FactorType::shared_ptr BayesTree::marginalFactor( - Index key, Eliminate function) const { + Index j, Eliminate function) const { - // get clique containing key - sharedClique clique = (*this)[key]; + // get clique containing Index j + sharedClique clique = (*this)[j]; // calculate or retrieve its marginal FactorGraph cliqueMarginal = clique->marginal(root_,function); return GenericSequentialSolver(cliqueMarginal).marginalFactor( - key, function); + j, function); } /* ************************************************************************* */ template typename BayesNet::shared_ptr BayesTree::marginalBayesNet( - Index key, Eliminate function) const { + Index j, Eliminate function) const { // calculate marginal as a factor graph FactorGraph fg; - fg.push_back(this->marginalFactor(key,function)); + fg.push_back(this->marginalFactor(j,function)); // eliminate factor graph marginal to a Bayes net return GenericSequentialSolver(fg).eliminate(function); @@ -510,28 +510,28 @@ namespace gtsam { /* ************************************************************************* */ template typename FactorGraph::shared_ptr - BayesTree::joint(Index key1, Index key2, Eliminate function) const { + BayesTree::joint(Index j1, Index j2, Eliminate function) const { // get clique C1 and C2 - sharedClique C1 = (*this)[key1], C2 = (*this)[key2]; + sharedClique C1 = (*this)[j1], C2 = (*this)[j2]; // calculate joint FactorGraph p_C1C2(C1->joint(C2, root_, function)); // eliminate remaining factor graph to get requested joint - std::vector key12(2); key12[0] = key1; key12[1] = key2; + std::vector j12(2); j12[0] = j1; j12[1] = j2; GenericSequentialSolver solver(p_C1C2); - return solver.jointFactorGraph(key12,function); + return solver.jointFactorGraph(j12,function); } /* ************************************************************************* */ template typename BayesNet::shared_ptr BayesTree::jointBayesNet( - Index key1, Index key2, Eliminate function) const { + Index j1, Index j2, Eliminate function) const { // eliminate factor graph marginal to a Bayes net return GenericSequentialSolver ( - *this->joint(key1, key2, function)).eliminate(function); + *this->joint(j1, j2, function)).eliminate(function); } /* ************************************************************************* */ @@ -574,11 +574,11 @@ namespace gtsam { BayesNet& bn, typename BayesTree::Cliques& orphans) { // process each key of the new factor - BOOST_FOREACH(const Index& key, keys) { + BOOST_FOREACH(const Index& j, keys) { // get the clique - if(key < nodes_.size()) { - const sharedClique& clique(nodes_[key]); + if(j < nodes_.size()) { + const sharedClique& clique(nodes_[j]); if(clique) { // remove path from clique to root this->removePath(clique, bn, orphans); diff --git a/gtsam/inference/BayesTree.h b/gtsam/inference/BayesTree.h index 6cd7c67f1..1e87ca141 100644 --- a/gtsam/inference/BayesTree.h +++ b/gtsam/inference/BayesTree.h @@ -91,10 +91,18 @@ namespace gtsam { CliqueStats getStats() const; }; - /** Map from keys to Clique */ + /** Map from indices to Clique */ typedef std::deque Nodes; - public: + protected: + + /** Map from indices to Clique */ + Nodes nodes_; + + /** Root clique */ + sharedClique root_; + + public: /// @name Standard Constructors /// @{ @@ -160,29 +168,29 @@ namespace gtsam { /** return root clique */ const sharedClique& root() const { return root_; } - /** find the clique to which key belongs */ - sharedClique operator[](Index key) const { - return nodes_.at(key); + /** find the clique that contains the variable with Index j */ + sharedClique operator[](Index j) const { + return nodes_.at(j); } /** Gather data on all cliques */ CliqueData getCliqueData() const; /** return marginal on any variable */ - typename FactorType::shared_ptr marginalFactor(Index key, Eliminate function) const; + typename FactorType::shared_ptr marginalFactor(Index j, Eliminate function) const; /** * return marginal on any variable, as a Bayes Net * NOTE: this function calls marginal, and then eliminates it into a Bayes Net * This is more expensive than the above function */ - typename BayesNet::shared_ptr marginalBayesNet(Index key, Eliminate function) const; + typename BayesNet::shared_ptr marginalBayesNet(Index j, Eliminate function) const; /** return joint on two variables */ - typename FactorGraph::shared_ptr joint(Index key1, Index key2, Eliminate function) const; + typename FactorGraph::shared_ptr joint(Index j1, Index j2, Eliminate function) const; /** return joint on two variables as a BayesNet */ - typename BayesNet::shared_ptr jointBayesNet(Index key1, Index key2, Eliminate function) const; + typename BayesNet::shared_ptr jointBayesNet(Index j1, Index j2, Eliminate function) const; /** * Read only with side effects @@ -211,11 +219,11 @@ namespace gtsam { void removePath(sharedClique clique, BayesNet& bn, Cliques& orphans); /** - * Given a list of keys, turn "contaminated" part of the tree back into a factor graph. + * Given a list of indices, turn "contaminated" part of the tree back into a factor graph. * Factors and orphans are added to the in/out arguments. */ template - void removeTop(const CONTAINER& keys, BayesNet& bn, Cliques& orphans); + void removeTop(const CONTAINER& indices, BayesNet& bn, Cliques& orphans); /** * Hang a new subtree off of the existing tree. This finds the appropriate @@ -243,9 +251,6 @@ namespace gtsam { protected: - /** Map from keys to Clique */ - Nodes nodes_; - /** private helper method for saving the Tree to a text file in GraphViz format */ void saveGraph(std::ostream &s, sharedClique clique, const IndexFormatter& indexFormatter, int parentnum = 0) const; @@ -253,9 +258,6 @@ namespace gtsam { /** Gather data on a single clique */ void getCliqueData(CliqueData& stats, sharedClique clique) const; - /** Root clique */ - sharedClique root_; - /** remove a clique: warning, can result in a forest */ void removeClique(sharedClique clique); diff --git a/gtsam/linear/NoiseModel.h b/gtsam/linear/NoiseModel.h index 2bb63c382..8588c738b 100644 --- a/gtsam/linear/NoiseModel.h +++ b/gtsam/linear/NoiseModel.h @@ -156,6 +156,7 @@ namespace gtsam { /** * A Gaussian noise model created by specifying a covariance matrix. + * @param covariance The square covariance Matrix * @param smart check if can be simplified to derived class */ static shared_ptr Covariance(const Matrix& covariance, bool smart = true); @@ -263,6 +264,7 @@ namespace gtsam { /** * A diagonal noise model created by specifying a Vector of variances, i.e. * i.e. the diagonal of the covariance matrix. + * @param variances A vector containing the variances of this noise model * @param smart check if can be simplified to derived class */ static shared_ptr Variances(const Vector& variances, bool smart = true); @@ -492,6 +494,8 @@ namespace gtsam { /** * An isotropic noise model created by specifying a variance = sigma^2. + * @param dim The dimension of this noise model + * @param variance The variance of this noise model * @param smart check if can be simplified to derived class */ static shared_ptr Variance(size_t dim, double variance, bool smart = true); diff --git a/gtsam/linear/SubgraphSolver.h b/gtsam/linear/SubgraphSolver.h index 7c60c0588..fe968d486 100644 --- a/gtsam/linear/SubgraphSolver.h +++ b/gtsam/linear/SubgraphSolver.h @@ -17,8 +17,6 @@ #include #include -#include - namespace gtsam { class SubgraphSolverParameters : public ConjugateGradientParameters { diff --git a/gtsam/slam/AntiFactor.h b/gtsam/slam/AntiFactor.h index 19f73c8b9..b5e77b578 100644 --- a/gtsam/slam/AntiFactor.h +++ b/gtsam/slam/AntiFactor.h @@ -26,6 +26,7 @@ namespace gtsam { * A class for downdating an existing factor from a graph. The AntiFactor returns the same * linearized Hessian matrices of the original factor, but with the opposite sign. This effectively * cancels out any affects of the original factor during optimization." + * @addtogroup SLAM */ class AntiFactor: public NonlinearFactor { diff --git a/gtsam/slam/BearingFactor.h b/gtsam/slam/BearingFactor.h index 326491e8c..86a6e159c 100644 --- a/gtsam/slam/BearingFactor.h +++ b/gtsam/slam/BearingFactor.h @@ -24,6 +24,7 @@ namespace gtsam { /** * Binary factor for a bearing measurement + * @addtogroup SLAM */ template class BearingFactor: public NoiseModelFactor2 { diff --git a/gtsam/slam/BearingRangeFactor.h b/gtsam/slam/BearingRangeFactor.h index 52f301b3c..d701054f9 100644 --- a/gtsam/slam/BearingRangeFactor.h +++ b/gtsam/slam/BearingRangeFactor.h @@ -26,6 +26,7 @@ namespace gtsam { /** * Binary factor for a bearing measurement + * @addtogroup SLAM */ template class BearingRangeFactor: public NoiseModelFactor2 { diff --git a/gtsam/slam/BetweenFactor.h b/gtsam/slam/BetweenFactor.h index d93e5fe81..14314ceb7 100644 --- a/gtsam/slam/BetweenFactor.h +++ b/gtsam/slam/BetweenFactor.h @@ -27,6 +27,7 @@ namespace gtsam { /** * A class for a measurement predicted by "between(config[key1],config[key2])" * @tparam VALUE the Value type + * @addtogroup SLAM */ template class BetweenFactor: public NoiseModelFactor2 { diff --git a/gtsam/slam/BoundingConstraint.h b/gtsam/slam/BoundingConstraint.h index 0032d9a05..43d3802c0 100644 --- a/gtsam/slam/BoundingConstraint.h +++ b/gtsam/slam/BoundingConstraint.h @@ -27,6 +27,7 @@ namespace gtsam { * greater/less than a fixed threshold. The function * will need to have its value function implemented to return * a scalar for comparison. + * @addtogroup SLAM */ template struct BoundingConstraint1: public NoiseModelFactor1 { diff --git a/gtsam/slam/GeneralSFMFactor.h b/gtsam/slam/GeneralSFMFactor.h index a9db7dcbe..3f3ae5a52 100644 --- a/gtsam/slam/GeneralSFMFactor.h +++ b/gtsam/slam/GeneralSFMFactor.h @@ -29,7 +29,9 @@ namespace gtsam { /** - * Non-linear factor for a constraint derived from a 2D measurement. The calibration is unknown here compared to GenericProjectionFactor + * Non-linear factor for a constraint derived from a 2D measurement. + * The calibration is unknown here compared to GenericProjectionFactor + * @addtogroup SLAM */ template class GeneralSFMFactor: public NoiseModelFactor2 { @@ -48,10 +50,10 @@ namespace gtsam { /** * Constructor - * @param z is the 2 dimensional location of point in image (the measurement) + * @param measured is the 2 dimensional location of point in image (the measurement) * @param model is the standard deviation of the measurements - * @param i is basically the frame number - * @param j is the index of the landmark + * @param cameraKey is the index of the camera + * @param landmarkKey is the index of the landmark */ GeneralSFMFactor(const Point2& measured, const SharedNoiseModel& model, Key cameraKey, Key landmarkKey) : Base(model, cameraKey, landmarkKey), measured_(measured) {} @@ -70,6 +72,7 @@ namespace gtsam { /** * print * @param s optional string naming the factor + * @param keyFormatter optional formatter for printing out Symbols */ void print(const std::string& s = "SFMFactor", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const { Base::print(s, keyFormatter); @@ -138,10 +141,11 @@ namespace gtsam { /** * Constructor - * @param z is the 2 dimensional location of point in image (the measurement) + * @param measured is the 2 dimensional location of point in image (the measurement) * @param model is the standard deviation of the measurements - * @param i is basically the frame number - * @param j is the index of the landmark + * @param poseKey is the index of the camera + * @param landmarkKey is the index of the landmark + * @param calibKey is the index of the calibration */ GeneralSFMFactor2(const Point2& measured, const SharedNoiseModel& model, Key poseKey, Key landmarkKey, Key calibKey) : Base(model, poseKey, landmarkKey, calibKey), measured_(measured) {} @@ -157,6 +161,7 @@ namespace gtsam { /** * print * @param s optional string naming the factor + * @param keyFormatter optional formatter useful for printing Symbols */ void print(const std::string& s = "SFMFactor2", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const { Base::print(s, keyFormatter); diff --git a/gtsam/slam/PriorFactor.h b/gtsam/slam/PriorFactor.h index 79ea4c0ce..5bd0ee76f 100644 --- a/gtsam/slam/PriorFactor.h +++ b/gtsam/slam/PriorFactor.h @@ -22,6 +22,7 @@ namespace gtsam { /** * A class for a soft prior on any Value type + * @addtogroup SLAM */ template class PriorFactor: public NoiseModelFactor1 { diff --git a/gtsam/slam/ProjectionFactor.h b/gtsam/slam/ProjectionFactor.h index 048756435..79796e6c3 100644 --- a/gtsam/slam/ProjectionFactor.h +++ b/gtsam/slam/ProjectionFactor.h @@ -28,6 +28,7 @@ namespace gtsam { /** * Non-linear factor for a constraint derived from a 2D measurement. The calibration is known here. * i.e. the main building block for visual SLAM. + * @addtogroup SLAM */ template class GenericProjectionFactor: public NoiseModelFactor2 { @@ -55,10 +56,10 @@ namespace gtsam { /** * Constructor * TODO: Mark argument order standard (keys, measurement, parameters) - * @param z is the 2 dimensional location of point in image (the measurement) + * @param measured is the 2 dimensional location of point in image (the measurement) * @param model is the standard deviation - * @param j_pose is basically the frame number - * @param j_landmark is the index of the landmark + * @param poseKey is the index of the camera + * @param pointKey is the index of the landmark * @param K shared pointer to the constant calibration */ GenericProjectionFactor(const Point2& measured, const SharedNoiseModel& model, @@ -77,6 +78,7 @@ namespace gtsam { /** * print * @param s optional string naming the factor + * @param keyFormatter optional formatter useful for printing Symbols */ void print(const std::string& s = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const { std::cout << s << "GenericProjectionFactor, z = "; diff --git a/gtsam/slam/RangeFactor.h b/gtsam/slam/RangeFactor.h index 78727f08f..fa4ddb7f2 100644 --- a/gtsam/slam/RangeFactor.h +++ b/gtsam/slam/RangeFactor.h @@ -24,6 +24,7 @@ namespace gtsam { /** * Binary factor for a range measurement + * @addtogroup SLAM */ template class RangeFactor: public NoiseModelFactor2 { diff --git a/gtsam/slam/StereoFactor.h b/gtsam/slam/StereoFactor.h index 94af6e10e..87cb95d25 100644 --- a/gtsam/slam/StereoFactor.h +++ b/gtsam/slam/StereoFactor.h @@ -23,6 +23,10 @@ namespace gtsam { +/** + * A Generic Stereo Factor + * @addtogroup SLAM + */ template class GenericStereoFactor: public NoiseModelFactor2 { private: @@ -66,6 +70,7 @@ public: /** * print * @param s optional string naming the factor + * @param keyFormatter optional formatter useful for printing Symbols */ void print(const std::string& s = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const { Base::print(s, keyFormatter); diff --git a/gtsam_unstable/slam/InvDepthFactor3.h b/gtsam_unstable/slam/InvDepthFactor3.h index daaf64575..f5856f6c8 100644 --- a/gtsam_unstable/slam/InvDepthFactor3.h +++ b/gtsam_unstable/slam/InvDepthFactor3.h @@ -41,10 +41,11 @@ public: /** * Constructor * TODO: Mark argument order standard (keys, measurement, parameters) - * @param z is the 2 dimensional location of point in image (the measurement) + * @param measured is the 2 dimensional location of point in image (the measurement) * @param model is the standard deviation - * @param j_pose is basically the frame number - * @param j_landmark is the index of the landmark + * @param poseKey is the index of the camera pose + * @param pointKey is the index of the landmark + * @param invDepthKey is the index of inverse depth * @param K shared pointer to the constant calibration */ InvDepthFactor3(const gtsam::Point2& measured, const gtsam::SharedNoiseModel& model, @@ -57,6 +58,7 @@ public: /** * print * @param s optional string naming the factor + * @param keyFormatter optional formatter useful for printing Symbols */ void print(const std::string& s = "InvDepthFactor3", const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter) const { diff --git a/matlab/+gtsam/Contents.m b/matlab/+gtsam/Contents.m new file mode 100644 index 000000000..0af19e1c8 --- /dev/null +++ b/matlab/+gtsam/Contents.m @@ -0,0 +1,161 @@ +% GTSAM MATLAB toolbox interface to the Georgia Tech Smoothing and Mapping C++ library +% Version 2.1 08-Sep-2012 +% +%% Basic Utilities +% linear_independent - check whether the rows of two matrices are linear independent +% Permutation - class Permutation, see Doxygen page for details +% +%% General Inference Classes +% IndexConditional - class IndexConditional, see Doxygen page for details +% IndexFactor - class IndexFactor, see Doxygen page for details +% SymbolicBayesNet - class SymbolicBayesNet, see Doxygen page for details +% SymbolicBayesTree - class SymbolicBayesTree, see Doxygen page for details +% SymbolicFactorGraph - class SymbolicFactorGraph, see Doxygen page for details +% SymbolicMultifrontalSolver - class SymbolicMultifrontalSolver, see Doxygen page for details +% SymbolicSequentialSolver - class SymbolicSequentialSolver, see Doxygen page for details +% VariableIndex - class VariableIndex, see Doxygen page for details +% +%% Linear-Gaussian Factor Graphs +% Errors - class Errors, see Doxygen page for details +% GaussianBayesNet - class GaussianBayesNet, see Doxygen page for details +% GaussianConditional - class GaussianConditional, see Doxygen page for details +% GaussianDensity - class GaussianDensity, see Doxygen page for details +% GaussianFactor - class GaussianFactor, see Doxygen page for details +% GaussianFactorGraph - class GaussianFactorGraph, see Doxygen page for details +% GaussianISAM - class GaussianISAM, see Doxygen page for details +% HessianFactor - class HessianFactor, see Doxygen page for details +% JacobianFactor - class JacobianFactor, see Doxygen page for details +% VectorValues - class VectorValues, see Doxygen page for details +% +%% Linear Inference +% GaussianSequentialSolver - class GaussianSequentialSolver, see Doxygen page for details +% IterativeOptimizationParameters - class IterativeOptimizationParameters, see Doxygen page for details +% KalmanFilter - class KalmanFilter, see Doxygen page for details +% SubgraphSolver - class SubgraphSolver, see Doxygen page for details +% SubgraphSolverParameters - class SubgraphSolverParameters, see Doxygen page for details +% SuccessiveLinearizationParams - class SuccessiveLinearizationParams, see Doxygen page for details +% Sampler - class Sampler, see Doxygen page for details +% +%% Nonlinear Factor Graphs +% NonlinearFactor - class NonlinearFactor, see Doxygen page for details +% NonlinearFactorGraph - class NonlinearFactorGraph, see Doxygen page for details +% Ordering - class Ordering, see Doxygen page for details +% Value - class Value, see Doxygen page for details +% Values - class Values, see Doxygen page for details +% +%% Nonlinear Optimization +% ConjugateGradientParameters - class ConjugateGradientParameters, see Doxygen page for details +% DoglegOptimizer - class DoglegOptimizer, see Doxygen page for details +% DoglegParams - class DoglegParams, see Doxygen page for details +% GaussNewtonOptimizer - class GaussNewtonOptimizer, see Doxygen page for details +% GaussNewtonParams - class GaussNewtonParams, see Doxygen page for details +% ISAM2 - class ISAM2, see Doxygen page for details +% ISAM2DoglegParams - class ISAM2DoglegParams, see Doxygen page for details +% ISAM2GaussNewtonParams - class ISAM2GaussNewtonParams, see Doxygen page for details +% ISAM2Params - class ISAM2Params, see Doxygen page for details +% ISAM2Result - class ISAM2Result, see Doxygen page for details +% ISAM2ThresholdMap - class ISAM2ThresholdMap, see Doxygen page for details +% ISAM2ThresholdMapValue - class ISAM2ThresholdMapValue, see Doxygen page for details +% InvertedOrdering - class InvertedOrdering, see Doxygen page for details +% JointMarginal - class JointMarginal, see Doxygen page for details +% KeyList - class KeyList, see Doxygen page for details +% KeySet - class KeySet, see Doxygen page for details +% KeyVector - class KeyVector, see Doxygen page for details +% LevenbergMarquardtOptimizer - class LevenbergMarquardtOptimizer, see Doxygen page for details +% LevenbergMarquardtParams - class LevenbergMarquardtParams, see Doxygen page for details +% Marginals - class Marginals, see Doxygen page for details +% NonlinearISAM - class NonlinearISAM, see Doxygen page for details +% NonlinearOptimizer - class NonlinearOptimizer, see Doxygen page for details +% NonlinearOptimizerParams - class NonlinearOptimizerParams, see Doxygen page for details +% +%% Geometry +% Cal3_S2 - class Cal3_S2, see Doxygen page for details +% Cal3_S2Stereo - class Cal3_S2Stereo, see Doxygen page for details +% Cal3DS2 - class Cal3DS2, see Doxygen page for details +% CalibratedCamera - class CalibratedCamera, see Doxygen page for details +% Point2 - class Point2, see Doxygen page for details +% Point3 - class Point3, see Doxygen page for details +% Pose2 - class Pose2, see Doxygen page for details +% Pose3 - class Pose3, see Doxygen page for details +% Rot2 - class Rot2, see Doxygen page for details +% Rot3 - class Rot3, see Doxygen page for details +% SimpleCamera - class SimpleCamera, see Doxygen page for details +% StereoPoint2 - class StereoPoint2, see Doxygen page for details +% +%% SLAM and SFM +% BearingFactor2D - class BearingFactor2D, see Doxygen page for details +% BearingRangeFactor2D - class BearingRangeFactor2D, see Doxygen page for details +% BetweenFactorLieMatrix - class BetweenFactorLieMatrix, see Doxygen page for details +% BetweenFactorLieScalar - class BetweenFactorLieScalar, see Doxygen page for details +% BetweenFactorLieVector - class BetweenFactorLieVector, see Doxygen page for details +% BetweenFactorPoint2 - class BetweenFactorPoint2, see Doxygen page for details +% BetweenFactorPoint3 - class BetweenFactorPoint3, see Doxygen page for details +% BetweenFactorPose2 - class BetweenFactorPose2, see Doxygen page for details +% BetweenFactorPose3 - class BetweenFactorPose3, see Doxygen page for details +% BetweenFactorRot2 - class BetweenFactorRot2, see Doxygen page for details +% BetweenFactorRot3 - class BetweenFactorRot3, see Doxygen page for details +% GeneralSFMFactor2Cal3_S2 - class GeneralSFMFactor2Cal3_S2, see Doxygen page for details +% GeneralSFMFactorCal3_S2 - class GeneralSFMFactorCal3_S2, see Doxygen page for details +% GenericProjectionFactorCal3_S2 - class GenericProjectionFactorCal3_S2, see Doxygen page for details +% GenericStereoFactor3D - class GenericStereoFactor3D, see Doxygen page for details +% NonlinearEqualityCal3_S2 - class NonlinearEqualityCal3_S2, see Doxygen page for details +% NonlinearEqualityCalibratedCamera - class NonlinearEqualityCalibratedCamera, see Doxygen page for details +% NonlinearEqualityLieMatrix - class NonlinearEqualityLieMatrix, see Doxygen page for details +% NonlinearEqualityLieScalar - class NonlinearEqualityLieScalar, see Doxygen page for details +% NonlinearEqualityLieVector - class NonlinearEqualityLieVector, see Doxygen page for details +% NonlinearEqualityPoint2 - class NonlinearEqualityPoint2, see Doxygen page for details +% NonlinearEqualityPoint3 - class NonlinearEqualityPoint3, see Doxygen page for details +% NonlinearEqualityPose2 - class NonlinearEqualityPose2, see Doxygen page for details +% NonlinearEqualityPose3 - class NonlinearEqualityPose3, see Doxygen page for details +% NonlinearEqualityRot2 - class NonlinearEqualityRot2, see Doxygen page for details +% NonlinearEqualityRot3 - class NonlinearEqualityRot3, see Doxygen page for details +% NonlinearEqualitySimpleCamera - class NonlinearEqualitySimpleCamera, see Doxygen page for details +% NonlinearEqualityStereoPoint2 - class NonlinearEqualityStereoPoint2, see Doxygen page for details +% PriorFactorCal3_S2 - class PriorFactorCal3_S2, see Doxygen page for details +% PriorFactorCalibratedCamera - class PriorFactorCalibratedCamera, see Doxygen page for details +% PriorFactorLieMatrix - class PriorFactorLieMatrix, see Doxygen page for details +% PriorFactorLieScalar - class PriorFactorLieScalar, see Doxygen page for details +% PriorFactorLieVector - class PriorFactorLieVector, see Doxygen page for details +% PriorFactorPoint2 - class PriorFactorPoint2, see Doxygen page for details +% PriorFactorPoint3 - class PriorFactorPoint3, see Doxygen page for details +% PriorFactorPose2 - class PriorFactorPose2, see Doxygen page for details +% PriorFactorPose3 - class PriorFactorPose3, see Doxygen page for details +% PriorFactorRot2 - class PriorFactorRot2, see Doxygen page for details +% PriorFactorRot3 - class PriorFactorRot3, see Doxygen page for details +% PriorFactorSimpleCamera - class PriorFactorSimpleCamera, see Doxygen page for details +% PriorFactorStereoPoint2 - class PriorFactorStereoPoint2, see Doxygen page for details +% RangeFactorCalibratedCamera - class RangeFactorCalibratedCamera, see Doxygen page for details +% RangeFactorCalibratedCameraPoint - class RangeFactorCalibratedCameraPoint, see Doxygen page for details +% RangeFactorPose2 - class RangeFactorPose2, see Doxygen page for details +% RangeFactorPose3 - class RangeFactorPose3, see Doxygen page for details +% RangeFactorPosePoint2 - class RangeFactorPosePoint2, see Doxygen page for details +% RangeFactorPosePoint3 - class RangeFactorPosePoint3, see Doxygen page for details +% RangeFactorSimpleCamera - class RangeFactorSimpleCamera, see Doxygen page for details +% RangeFactorSimpleCameraPoint - class RangeFactorSimpleCameraPoint, see Doxygen page for details +% VisualISAMGenerateData - VisualISAMGenerateData creates data for viusalSLAM::iSAM examples +% VisualISAMInitialize - VisualISAMInitialize initializes visualSLAM::iSAM object and noise parameters +% VisualISAMPlot - VisualISAMPlot plots current state of ISAM2 object +% VisualISAMStep - VisualISAMStep executes one update step of visualSLAM::iSAM object +% +%% MATLAB-only Utilities +% CHECK - throw an error if an assertion fails +% circlePose2 - circlePose2 generates a set of poses in a circle. This function +% circlePose3 - circlePose3 generates a set of poses in a circle. This function +% covarianceEllipse - covarianceEllipse plots a Gaussian as an uncertainty ellipse +% covarianceEllipse3D - covarianceEllipse3D plots a Gaussian as an uncertainty ellipse +% EQUALITY - test equality of two vectors/matrices up to tolerance +% findExampleDataFile - Find a dataset in the examples folder +% load2D - load2D reads a TORO-style 2D pose graph +% load3D - load3D reads a TORO-style 3D pose graph +% plot2DPoints - Plots the Point2's in a values, with optional covariances +% plot2DTrajectory - Plots the Pose2's in a values, with optional covariances +% plot3DPoints - Plots the Point3's in a values, with optional covariances +% plot3DTrajectory - plot3DTrajectory plots a 3D trajectory +% plotCamera - +% plotPoint2 - plotPoint2 shows a Point2, possibly with covariance matrix +% plotPoint3 - Plot a Point3 with an optional covariance matrix +% plotPose2 - plotPose2 shows a Pose2, possibly with covariance matrix +% plotPose3 - plotPose3 shows a Pose, possibly with covariance matrix +% symbol - create a Symbol key +% symbolChr - get character from a symbol key +% symbolIndex - get index from a symbol key diff --git a/matlab/+gtsam/VisualISAMGenerateData.m b/matlab/+gtsam/VisualISAMGenerateData.m index 2e972d9af..b3b602afe 100644 --- a/matlab/+gtsam/VisualISAMGenerateData.m +++ b/matlab/+gtsam/VisualISAMGenerateData.m @@ -1,5 +1,5 @@ function [data,truth] = VisualISAMGenerateData(options) -% VisualISAMGenerateData: create data for viusalSLAM::iSAM examples +% VisualISAMGenerateData creates data for viusalSLAM::iSAM examples % Authors: Duy Nguyen Ta and Frank Dellaert %% Generate simulated data diff --git a/matlab/+gtsam/VisualISAMInitialize.m b/matlab/+gtsam/VisualISAMInitialize.m index b29288fdf..8da23a1ec 100644 --- a/matlab/+gtsam/VisualISAMInitialize.m +++ b/matlab/+gtsam/VisualISAMInitialize.m @@ -1,5 +1,5 @@ function [noiseModels,isam,result,nextPoseIndex] = VisualISAMInitialize(data,truth,options) -% VisualInitialize: initialize visualSLAM::iSAM object and noise parameters +% VisualISAMInitialize initializes visualSLAM::iSAM object and noise parameters % Authors: Duy Nguyen Ta, Frank Dellaert and Alex Cunningham %% Initialize iSAM diff --git a/matlab/+gtsam/VisualISAMPlot.m b/matlab/+gtsam/VisualISAMPlot.m index cd7ab188e..a6a677723 100644 --- a/matlab/+gtsam/VisualISAMPlot.m +++ b/matlab/+gtsam/VisualISAMPlot.m @@ -1,5 +1,5 @@ function VisualISAMPlot(truth, data, isam, result, options) -% VisualISAMPlot: plot current state of ISAM2 object +% VisualISAMPlot plots current state of ISAM2 object % Authors: Duy Nguyen Ta and Frank Dellaert h=gca; diff --git a/matlab/+gtsam/VisualISAMStep.m b/matlab/+gtsam/VisualISAMStep.m index 71b1c849c..25b4c1027 100644 --- a/matlab/+gtsam/VisualISAMStep.m +++ b/matlab/+gtsam/VisualISAMStep.m @@ -1,5 +1,5 @@ function [isam,result,nextPoseIndex] = VisualISAMStep(data,noiseModels,isam,result,truth,nextPoseIndex) -% VisualISAMStep: execute one update step of visualSLAM::iSAM object +% VisualISAMStep executes one update step of visualSLAM::iSAM object % Authors: Duy Nguyen Ta and Frank Dellaert % iSAM expects us to give it a new set of factors diff --git a/matlab/+gtsam/circlePose2.m b/matlab/+gtsam/circlePose2.m index 0679c16b3..a2606ec06 100644 --- a/matlab/+gtsam/circlePose2.m +++ b/matlab/+gtsam/circlePose2.m @@ -1,5 +1,5 @@ function values = circlePose2(numPoses, radius, symbolChar) -% circlePose3: generate a set of poses in a circle. This function +% circlePose2 generates a set of poses in a circle. This function % returns those poses inside a gtsam.Values object, with sequential % keys starting from 0. An optional character may be provided, which % will be stored in the msb of each key (i.e. gtsam.Symbol). diff --git a/matlab/+gtsam/circlePose3.m b/matlab/+gtsam/circlePose3.m index 9085ab0d0..686bce7cf 100644 --- a/matlab/+gtsam/circlePose3.m +++ b/matlab/+gtsam/circlePose3.m @@ -1,5 +1,5 @@ function values = circlePose3(numPoses, radius, symbolChar) -% circlePose3: generate a set of poses in a circle. This function +% circlePose3 generates a set of poses in a circle. This function % returns those poses inside a gtsam.Values object, with sequential % keys starting from 0. An optional character may be provided, which % will be stored in the msb of each key (i.e. gtsam.Symbol). diff --git a/matlab/+gtsam/covarianceEllipse.m b/matlab/+gtsam/covarianceEllipse.m index b4579862e..7728fc866 100644 --- a/matlab/+gtsam/covarianceEllipse.m +++ b/matlab/+gtsam/covarianceEllipse.m @@ -1,5 +1,5 @@ function covarianceEllipse(x,P,color) -% covarianceEllipse: plot a Gaussian as an uncertainty ellipse +% covarianceEllipse plots a Gaussian as an uncertainty ellipse % Based on Maybeck Vol 1, page 366 % k=2.296 corresponds to 1 std, 68.26% of all probability % k=11.82 corresponds to 3 std, 99.74% of all probability diff --git a/matlab/+gtsam/covarianceEllipse3D.m b/matlab/+gtsam/covarianceEllipse3D.m index d3ef1f8a7..9682a9fc1 100644 --- a/matlab/+gtsam/covarianceEllipse3D.m +++ b/matlab/+gtsam/covarianceEllipse3D.m @@ -1,5 +1,5 @@ function covarianceEllipse3D(c,P) -% covarianceEllipse3D: plot a Gaussian as an uncertainty ellipse +% covarianceEllipse3D plots a Gaussian as an uncertainty ellipse % Based on Maybeck Vol 1, page 366 % k=2.296 corresponds to 1 std, 68.26% of all probability % k=11.82 corresponds to 3 std, 99.74% of all probability diff --git a/matlab/+gtsam/load3D.m b/matlab/+gtsam/load3D.m index c0ccd545f..94202e0c8 100644 --- a/matlab/+gtsam/load3D.m +++ b/matlab/+gtsam/load3D.m @@ -1,5 +1,5 @@ function [graph,initial] = load3D(filename,model,successive,N) -% load3D: read TORO 3D pose graph +% load3D reads a TORO-style 3D pose graph % cannot read noise model from file yet, uses specified model % if [successive] is tru, constructs initial estimate from odometry diff --git a/matlab/+gtsam/plot3DTrajectory.m b/matlab/+gtsam/plot3DTrajectory.m index 1cd35c22f..d24e21297 100644 --- a/matlab/+gtsam/plot3DTrajectory.m +++ b/matlab/+gtsam/plot3DTrajectory.m @@ -1,5 +1,7 @@ function plot3DTrajectory(values,linespec,frames,scale,marginals) -% plot3DTrajectory +% plot3DTrajectory plots a 3D trajectory +% plot3DTrajectory(values,linespec,frames,scale,marginals) + if ~exist('scale','var') || isempty(scale), scale=1; end if ~exist('frames','var'), scale=[]; end diff --git a/matlab/+gtsam/plotPoint2.m b/matlab/+gtsam/plotPoint2.m index e62804ce3..55e476118 100644 --- a/matlab/+gtsam/plotPoint2.m +++ b/matlab/+gtsam/plotPoint2.m @@ -1,5 +1,5 @@ function plotPoint2(p,color,P) -% plotPoint2: show a Point2, possibly with covariance matrix +% plotPoint2 shows a Point2, possibly with covariance matrix if size(color,2)==1 plot(p.x,p.y,[color '*']); else diff --git a/matlab/+gtsam/plotPose2.m b/matlab/+gtsam/plotPose2.m index c7fba28ed..799bad48e 100644 --- a/matlab/+gtsam/plotPose2.m +++ b/matlab/+gtsam/plotPose2.m @@ -1,5 +1,5 @@ function plotPose2(pose,color,P,axisLength) -% plotPose2: show a Pose2, possibly with covariance matrix +% plotPose2 shows a Pose2, possibly with covariance matrix if nargin<4,axisLength=0.1;end plot(pose.x,pose.y,[color '*']); diff --git a/matlab/+gtsam/plotPose3.m b/matlab/+gtsam/plotPose3.m index e2c254e39..8c3c7dd76 100644 --- a/matlab/+gtsam/plotPose3.m +++ b/matlab/+gtsam/plotPose3.m @@ -1,5 +1,5 @@ function plotPose3(pose, P, axisLength) -% plotPose3: show a Pose, possibly with covariance matrix +% plotPose3 shows a Pose, possibly with covariance matrix if nargin<3,axisLength=0.1;end % get rotation and translation (center) diff --git a/wrap/Class.cpp b/wrap/Class.cpp index 374324558..48fbeb6bf 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -58,13 +58,13 @@ void Class::matlab_proxy(const string& toolboxPath, const string& wrapperName, const string parent = qualifiedParent.empty() ? "handle" : matlabBaseName; comment_fragment(proxyFile); proxyFile.oss << "classdef " << name << " < " << parent << endl; - proxyFile.oss << " properties" << endl; - proxyFile.oss << " ptr_" << matlabUniqueName << " = 0" << endl; - proxyFile.oss << " end" << endl; - proxyFile.oss << " methods" << endl; + proxyFile.oss << " properties\n"; + proxyFile.oss << " ptr_" << matlabUniqueName << " = 0\n"; + proxyFile.oss << " end\n"; + proxyFile.oss << " methods\n"; // Constructor - proxyFile.oss << " function obj = " << name << "(varargin)" << endl; + proxyFile.oss << " function obj = " << name << "(varargin)\n"; // Special pointer constructors - one in MATLAB to create an object and // assign a pointer returned from a C++ function. In turn this MATLAB // constructor calls a special C++ function that just adds the object to @@ -85,7 +85,7 @@ void Class::matlab_proxy(const string& toolboxPath, const string& wrapperName, functionNames.push_back(wrapFunctionName); } proxyFile.oss << " else\n"; - proxyFile.oss << " error('Arguments do not match any overload of " << matlabQualName << " constructor');" << endl; + proxyFile.oss << " error('Arguments do not match any overload of " << matlabQualName << " constructor');\n"; proxyFile.oss << " end\n"; if(!qualifiedParent.empty()) proxyFile.oss << " obj = obj@" << matlabBaseName << "(uint64(" << ptr_constructor_key << "), base_ptr);\n"; @@ -124,8 +124,8 @@ void Class::matlab_proxy(const string& toolboxPath, const string& wrapperName, wrapperFile.oss << "\n"; } - proxyFile.oss << " end" << endl; - proxyFile.oss << "end" << endl; + proxyFile.oss << " end\n"; + proxyFile.oss << "end\n"; // Close file proxyFile.emit(true); @@ -181,7 +181,7 @@ void Class::pointer_constructor_fragments(FileWriter& proxyFile, FileWriter& wra // comes from a C++ return value; this mechanism allows the object to be added // to a collector in a different wrap module. If this class has a base class, // a new pointer to the base class is allocated and returned. - wrapperFile.oss << "void " << collectorInsertFunctionName << "(int nargout, mxArray *out[], int nargin, const mxArray *in[])" << endl; + wrapperFile.oss << "void " << collectorInsertFunctionName << "(int nargout, mxArray *out[], int nargin, const mxArray *in[])\n"; wrapperFile.oss << "{\n"; wrapperFile.oss << " mexAtExit(&_deleteAllObjects);\n"; // Typedef boost::shared_ptr @@ -325,70 +325,69 @@ std::string Class::getTypedef() const { /* ************************************************************************* */ -void Class::comment_fragment(FileWriter& proxyFile) const -{ - proxyFile.oss << "%" << "-------Constructors-------" << endl; - BOOST_FOREACH(ArgumentList argList, constructor.args_list) - { +void Class::comment_fragment(FileWriter& proxyFile) const { + proxyFile.oss << "%class " << name + << ", see Doxygen page for details\n"; + proxyFile.oss + << "%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html\n"; - string up_name = boost::to_upper_copy(name); - proxyFile.oss << "%" << name << "("; - unsigned int i = 0; - BOOST_FOREACH(const Argument& arg, argList) - { - if(i != argList.size()-1) - proxyFile.oss << arg.type << " " << arg.name << ", "; - else - proxyFile.oss << arg.type << " " << arg.name; - i++; - } - proxyFile.oss << ")" << endl; + if (!constructor.args_list.empty()) + proxyFile.oss << "%\n%-------Constructors-------\n"; + BOOST_FOREACH(ArgumentList argList, constructor.args_list) { + string up_name = boost::to_upper_copy(name); + proxyFile.oss << "%" << name << "("; + unsigned int i = 0; + BOOST_FOREACH(const Argument& arg, argList) { + if (i != argList.size() - 1) + proxyFile.oss << arg.type << " " << arg.name << ", "; + else + proxyFile.oss << arg.type << " " << arg.name; + i++; } + proxyFile.oss << ")\n"; + } - proxyFile.oss << "% " << "" << endl; - proxyFile.oss << "%" << "-------Methods-------" << endl; - BOOST_FOREACH(const Methods::value_type& name_m, methods) { - const Method& m = name_m.second; - BOOST_FOREACH(ArgumentList argList, m.argLists) - { - string up_name = boost::to_upper_copy(m.name); - proxyFile.oss << "%" << m.name << "("; - unsigned int i = 0; - BOOST_FOREACH(const Argument& arg, argList) - { - if(i != argList.size()-1) - proxyFile.oss << arg.type << " " << arg.name << ", "; - else - proxyFile.oss << arg.type << " " << arg.name; - i++; - } - proxyFile.oss << ") : returns " << m.returnVals[0].return_type(false, m.returnVals[0].pair) << endl; - } + if (!methods.empty()) + proxyFile.oss << "%\n%-------Methods-------\n"; + BOOST_FOREACH(const Methods::value_type& name_m, methods) { + const Method& m = name_m.second; + BOOST_FOREACH(ArgumentList argList, m.argLists) { + string up_name = boost::to_upper_copy(m.name); + proxyFile.oss << "%" << m.name << "("; + unsigned int i = 0; + BOOST_FOREACH(const Argument& arg, argList) { + if (i != argList.size() - 1) + proxyFile.oss << arg.type << " " << arg.name << ", "; + else + proxyFile.oss << arg.type << " " << arg.name; + i++; + } + proxyFile.oss << ") : returns " + << m.returnVals[0].return_type(false, m.returnVals[0].pair) << endl; } + } - proxyFile.oss << "% " << "" << endl; - proxyFile.oss << "%" << "-------Static Methods-------" << endl; - BOOST_FOREACH(const StaticMethods::value_type& name_m, static_methods) { - const StaticMethod& m = name_m.second; - BOOST_FOREACH(ArgumentList argList, m.argLists) - { - string up_name = boost::to_upper_copy(m.name); - proxyFile.oss << "%" << m.name << "("; - unsigned int i = 0; - BOOST_FOREACH(const Argument& arg, argList) - { - if(i != argList.size()-1) - proxyFile.oss << arg.type << " " << arg.name << ", "; - else - proxyFile.oss << arg.type << " " << arg.name; - i++; - } + if (!static_methods.empty()) + proxyFile.oss << "%\n%-------Static Methods-------\n"; + BOOST_FOREACH(const StaticMethods::value_type& name_m, static_methods) { + const StaticMethod& m = name_m.second; + BOOST_FOREACH(ArgumentList argList, m.argLists) { + string up_name = boost::to_upper_copy(m.name); + proxyFile.oss << "%" << m.name << "("; + unsigned int i = 0; + BOOST_FOREACH(const Argument& arg, argList) { + if (i != argList.size() - 1) + proxyFile.oss << arg.type << " " << arg.name << ", "; + else + proxyFile.oss << arg.type << " " << arg.name; + i++; + } - proxyFile.oss << ") : returns " << m.returnVals[0].return_type(false, m.returnVals[0].pair) << endl; - } + proxyFile.oss << ") : returns " + << m.returnVals[0].return_type(false, m.returnVals[0].pair) << endl; } + } - proxyFile.oss << "%" << "" << endl; - proxyFile.oss << "%" << "For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html" << endl; + proxyFile.oss << "%\n"; } /* ************************************************************************* */ diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 46b31f3e6..aad533a9a 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -342,6 +342,15 @@ Module::Module(const string& interfacePath, printf("parsing stopped at \n%.20s\n",info.stop); throw ParseFailed((int)info.length); } + + //Explicitly add methods to the classes from parents so it shows in documentation + BOOST_FOREACH(Class& cls, classes) + { + map inhereted = appendInheretedMethods(cls, classes); + cls.methods.insert(inhereted.begin(), inhereted.end()); + } + + } /* ************************************************************************* */ @@ -432,6 +441,7 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co // verify parents if(!cls.qualifiedParent.empty() && std::find(validTypes.begin(), validTypes.end(), wrap::qualifiedName("::", cls.qualifiedParent)) == validTypes.end()) throw DependencyMissing(wrap::qualifiedName("::", cls.qualifiedParent), cls.qualifiedName("::")); + } // Create type attributes table and check validity @@ -472,6 +482,33 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co wrapperFile.emit(true); } +/* ************************************************************************* */ +map Module::appendInheretedMethods(const Class& cls, const vector& classes) +{ + map methods; + if(!cls.qualifiedParent.empty()) + { + cout << "Class: " << cls.name << " Parent Name: " << cls.qualifiedParent.back() << endl; + //Find Class + BOOST_FOREACH(const Class& parent, classes) + { + //We found the class for our parent + if(parent.name == cls.qualifiedParent.back()) + { + cout << "Inner class: " << cls.qualifiedParent.back() << endl; + Methods inhereted = appendInheretedMethods(parent, classes); + methods.insert(inhereted.begin(), inhereted.end()); + } + } + } + else + { + cout << "Dead end: " << cls.name << endl; + methods.insert(cls.methods.begin(), cls.methods.end()); + } + + return methods; +} /* ************************************************************************* */ void Module::finish_wrapper(FileWriter& file, const std::vector& functionNames) const { diff --git a/wrap/Module.h b/wrap/Module.h index ca8b0bb1a..a1dfe88d8 100644 --- a/wrap/Module.h +++ b/wrap/Module.h @@ -35,6 +35,7 @@ namespace wrap { struct Module { typedef std::map GlobalFunctions; + typedef std::map Methods; std::string name; ///< module name std::vector classes; ///< list of classes @@ -49,6 +50,9 @@ struct Module { const std::string& moduleName, bool enable_verbose=true); + //Recursive method to append all methods inhereted from parent classes + std::map appendInheretedMethods(const Class& cls, const std::vector& classes); + /// MATLAB code generation: void matlab_code( const std::string& path, diff --git a/wrap/tests/expected/Point2.m b/wrap/tests/expected/Point2.m index d1c336c5f..22dec9641 100644 --- a/wrap/tests/expected/Point2.m +++ b/wrap/tests/expected/Point2.m @@ -1,7 +1,10 @@ +%class Point2, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% %-------Constructors------- %Point2() %Point2(double x, double y) -% +% %-------Methods------- %argChar(char a) : returns void %argUChar(unsigned char a) : returns void @@ -10,10 +13,7 @@ %vectorConfusion() : returns VectorNotEigen %x() : returns double %y() : returns double -% -%-------Static Methods------- % -%For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html classdef Point2 < handle properties ptr_Point2 = 0 diff --git a/wrap/tests/expected/Point3.m b/wrap/tests/expected/Point3.m index f73b740ac..3a90f1982 100644 --- a/wrap/tests/expected/Point3.m +++ b/wrap/tests/expected/Point3.m @@ -1,14 +1,16 @@ +%class Point3, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% %-------Constructors------- %Point3(double x, double y, double z) -% +% %-------Methods------- %norm() : returns double -% +% %-------Static Methods------- %StaticFunctionRet(double z) : returns Point3 %staticFunction() : returns double % -%For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html classdef Point3 < handle properties ptr_Point3 = 0 diff --git a/wrap/tests/expected/Test.m b/wrap/tests/expected/Test.m index 1e07974ee..e493b9a04 100644 --- a/wrap/tests/expected/Test.m +++ b/wrap/tests/expected/Test.m @@ -1,7 +1,10 @@ +%class Test, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% %-------Constructors------- %Test() %Test(double a, Matrix b) -% +% %-------Methods------- %arg_EigenConstRef(Matrix value) : returns void %create_MixedPtrs() : returns pair< Test, SharedTest > @@ -22,10 +25,7 @@ %return_string(string value) : returns string %return_vector1(Vector value) : returns Vector %return_vector2(Vector value) : returns Vector -% -%-------Static Methods------- % -%For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html classdef Test < handle properties ptr_Test = 0 diff --git a/wrap/tests/expected_namespaces/+ns1/ClassA.m b/wrap/tests/expected_namespaces/+ns1/ClassA.m index ee87c12d7..f7dce6031 100644 --- a/wrap/tests/expected_namespaces/+ns1/ClassA.m +++ b/wrap/tests/expected_namespaces/+ns1/ClassA.m @@ -1,11 +1,9 @@ +%class ClassA, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% %-------Constructors------- %ClassA() -% -%-------Methods------- -% -%-------Static Methods------- % -%For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html classdef ClassA < handle properties ptr_ns1ClassA = 0 diff --git a/wrap/tests/expected_namespaces/+ns1/ClassB.m b/wrap/tests/expected_namespaces/+ns1/ClassB.m index 7f393f03e..df956a179 100644 --- a/wrap/tests/expected_namespaces/+ns1/ClassB.m +++ b/wrap/tests/expected_namespaces/+ns1/ClassB.m @@ -1,11 +1,9 @@ +%class ClassB, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% %-------Constructors------- %ClassB() -% -%-------Methods------- -% -%-------Static Methods------- % -%For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html classdef ClassB < handle properties ptr_ns1ClassB = 0 diff --git a/wrap/tests/expected_namespaces/+ns2/+ns3/ClassB.m b/wrap/tests/expected_namespaces/+ns2/+ns3/ClassB.m index 4ad4a14f0..23c3dbacb 100644 --- a/wrap/tests/expected_namespaces/+ns2/+ns3/ClassB.m +++ b/wrap/tests/expected_namespaces/+ns2/+ns3/ClassB.m @@ -1,11 +1,9 @@ +%class ClassB, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% %-------Constructors------- %ClassB() -% -%-------Methods------- -% -%-------Static Methods------- % -%For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html classdef ClassB < handle properties ptr_ns2ns3ClassB = 0 diff --git a/wrap/tests/expected_namespaces/+ns2/ClassA.m b/wrap/tests/expected_namespaces/+ns2/ClassA.m index c56377c2a..c7ab901ae 100644 --- a/wrap/tests/expected_namespaces/+ns2/ClassA.m +++ b/wrap/tests/expected_namespaces/+ns2/ClassA.m @@ -1,15 +1,17 @@ +%class ClassA, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% %-------Constructors------- %ClassA() -% +% %-------Methods------- %memberFunction() : returns double %nsArg(ClassB arg) : returns int %nsReturn(double q) : returns ns2::ns3::ClassB -% +% %-------Static Methods------- %afunction() : returns double % -%For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html classdef ClassA < handle properties ptr_ns2ClassA = 0 diff --git a/wrap/tests/expected_namespaces/+ns2/ClassC.m b/wrap/tests/expected_namespaces/+ns2/ClassC.m index 050ef19f4..19b709f5c 100644 --- a/wrap/tests/expected_namespaces/+ns2/ClassC.m +++ b/wrap/tests/expected_namespaces/+ns2/ClassC.m @@ -1,11 +1,9 @@ +%class ClassC, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% %-------Constructors------- %ClassC() -% -%-------Methods------- -% -%-------Static Methods------- % -%For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html classdef ClassC < handle properties ptr_ns2ClassC = 0 diff --git a/wrap/tests/expected_namespaces/ClassD.m b/wrap/tests/expected_namespaces/ClassD.m index 41e9e63ec..453025961 100644 --- a/wrap/tests/expected_namespaces/ClassD.m +++ b/wrap/tests/expected_namespaces/ClassD.m @@ -1,11 +1,9 @@ +%class ClassD, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% %-------Constructors------- %ClassD() -% -%-------Methods------- -% -%-------Static Methods------- % -%For more detailed documentation on GTSAM go to our Doxygen page, which can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html classdef ClassD < handle properties ptr_ClassD = 0