From 4e5a80aa56673705edf72373ddecf92aa8aa710b Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Fri, 9 Dec 2011 16:36:50 +0000 Subject: [PATCH] Removed extraneous headers that were previously needed for wrap, added start of simulated2D and simulated2DOriented domains to gtsam.h, more wrap documentation --- gtsam.h | 101 +++++++++++------- gtsam/slam/Makefile.am | 20 +--- gtsam/slam/Simulated2DMeasurement.h | 28 ----- gtsam/slam/Simulated2DOdometry.h | 28 ----- gtsam/slam/Simulated2DOrientedOdometry.h | 28 ----- gtsam/slam/Simulated2DOrientedPosePrior.h | 29 ----- gtsam/slam/Simulated2DOrientedValues.h | 59 ---------- gtsam/slam/Simulated2DPointPrior.h | 29 ----- gtsam/slam/Simulated2DPosePrior.h | 29 ----- gtsam/slam/Simulated2DValues.h | 58 ---------- gtsam/slam/simulated2D.h | 16 ++- gtsam/slam/simulated2DOriented.h | 30 +++++- .../slam/{Simulated3D.cpp => simulated3D.cpp} | 2 +- gtsam/slam/{Simulated3D.h => simulated3D.h} | 0 gtsam/slam/tests/testSimulated3D.cpp | 2 +- wrap/Makefile.am | 6 +- 16 files changed, 110 insertions(+), 355 deletions(-) delete mode 100644 gtsam/slam/Simulated2DMeasurement.h delete mode 100644 gtsam/slam/Simulated2DOdometry.h delete mode 100644 gtsam/slam/Simulated2DOrientedOdometry.h delete mode 100644 gtsam/slam/Simulated2DOrientedPosePrior.h delete mode 100644 gtsam/slam/Simulated2DOrientedValues.h delete mode 100644 gtsam/slam/Simulated2DPointPrior.h delete mode 100644 gtsam/slam/Simulated2DPosePrior.h delete mode 100644 gtsam/slam/Simulated2DValues.h rename gtsam/slam/{Simulated3D.cpp => simulated3D.cpp} (96%) rename gtsam/slam/{Simulated3D.h => simulated3D.h} (100%) diff --git a/gtsam.h b/gtsam.h index 4f9dd5e46..819d56c5b 100644 --- a/gtsam.h +++ b/gtsam.h @@ -13,6 +13,9 @@ * - void * - Any class with which be copied with boost::make_shared() * - boost::shared_ptr of any object type + * Limitations on methods + * - Parsing does not support overloading + * - There can only be one method with a given name * Arguments to functions any of * - Eigen types: Matrix, Vector * - Eigen types and classes as an optionally const reference @@ -31,6 +34,9 @@ * - In each case, the namespace must be fully specified, e.g., "namespace1::namespace2::ClassName" * Methods must start with a lowercase letter * Static methods must start with a letter (upper or lowercase) and use the "static" keyword + * Includes in C++ wrappers + * - By default, the include will be <[classname].h> + * - To override, add a full include statement inside the class definition */ /** @@ -181,6 +187,12 @@ class SharedDiagonal { Vector sample() const; }; +class SharedNoiseModel { +#include + SharedNoiseModel(const SharedDiagonal& model); + SharedNoiseModel(const SharedGaussian& model); +}; + class VectorValues { VectorValues(); VectorValues(int nVars, int varDim); @@ -245,6 +257,14 @@ class GaussianFactorGraph { Matrix sparseJacobian_() const; }; +class GaussianSequentialSolver { + GaussianSequentialSolver(const GaussianFactorGraph& graph, bool useQR); + GaussianBayesNet* eliminate() const; + VectorValues* optimize() const; + GaussianFactor* marginalFactor(int j) const; + Matrix marginalCovariance(int j) const; +}; + class KalmanFilter { KalmanFilter(Vector x, const SharedDiagonal& model); void print(string s) const; @@ -263,11 +283,6 @@ class Ordering { void push_back(string key); }; -class SharedNoiseModel { - SharedNoiseModel(); - // FIXME: this needs actual constructors -}; - // Planar SLAM example domain namespace planarSLAM { @@ -312,14 +327,51 @@ class Odometry { }///\namespace planarSLAM -class GaussianSequentialSolver { - GaussianSequentialSolver(const GaussianFactorGraph& graph, bool useQR); - GaussianBayesNet* eliminate() const; - VectorValues* optimize() const; - GaussianFactor* marginalFactor(int j) const; - Matrix marginalCovariance(int j) const; +// Simulated2D Example Domain +namespace simulated2D { + +class Values { +#include + Values(); + void insertPose(int i, const Point2& p); + void insertPoint(int j, const Point2& p); + int nrPoses() const; + int nrPoints() const; + Point2 pose(int i); + Point2 point(int j); }; +class Graph { +#include + Graph(); +}; + +// TODO: add factors, etc. + +}///\namespace simulated2D + +// Simulated2DOriented Example Domain +namespace simulated2DOriented { + +class Values { +#include + Values(); + void insertPose(int i, const Pose2& p); + void insertPoint(int j, const Point2& p); + int nrPoses() const; + int nrPoints() const; + Pose2 pose(int i); + Point2 point(int j); +}; + +class Graph { +#include + Graph(); +}; + +// TODO: add factors, etc. + +}///\namespace simulated2DOriented //// These are considered to be broken and will be added back as they start working //// It's assumed that there have been interface changes that might break this @@ -339,28 +391,6 @@ class GaussianSequentialSolver { // void push_back(GaussianFactor* factor); //}; // -//class Simulated2DValues { -// Simulated2DValues(); -// void print(string s) const; -// void insertPose(int i, const Point2& p); -// void insertPoint(int j, const Point2& p); -// int nrPoses() const; -// int nrPoints() const; -// Point2* pose(int i); -// Point2* point(int j); -//}; -// -//class Simulated2DOrientedValues { -// Simulated2DOrientedValues(); -// void print(string s) const; -// void insertPose(int i, const Pose2& p); -// void insertPoint(int j, const Point2& p); -// int nrPoses() const; -// int nrPoints() const; -// Pose2* pose(int i); -// Point2* point(int j); -//}; -// //class Simulated2DPosePrior { // Simulated2DPosePrior(Point2& mu, const SharedDiagonal& model, int i); // void print(string s) const; @@ -397,10 +427,6 @@ class GaussianSequentialSolver { // double error(const Simulated2DValues& c) const; //}; // -//// These are currently broken -//// Solve by parsing a namespace pose2SLAM::Values and making a Pose2SLAMValues class -//// We also have to solve the shared pointer mess to avoid duplicate methods -// //class GaussianFactor { // GaussianFactor(string key1, // Matrix A1, @@ -435,7 +461,6 @@ class GaussianSequentialSolver { // VectorValues* conjugateGradientDescent_(const VectorValues& x0) const; //}; // -// //class Pose2Values{ // Pose2Values(); // Pose2 get(string key) const; diff --git a/gtsam/slam/Makefile.am b/gtsam/slam/Makefile.am index d55d40666..fa51a9512 100644 --- a/gtsam/slam/Makefile.am +++ b/gtsam/slam/Makefile.am @@ -15,24 +15,12 @@ headers += simulated2DConstraints.h sources += simulated2D.cpp smallExample.cpp check_PROGRAMS += tests/testSimulated2D -# MATLAB Wrap headers for simulated2D -headers += Simulated2DMeasurement.h -headers += Simulated2DOdometry.h -headers += Simulated2DPointPrior.h -headers += Simulated2DPosePrior.h -headers += Simulated2DValues.h - # simulated2DOriented example sources += simulated2DOriented.cpp check_PROGRAMS += tests/testSimulated2DOriented -# MATLAB Wrap headers for simulated2DOriented -headers += Simulated2DOrientedOdometry.h -headers += Simulated2DOrientedPosePrior.h -headers += Simulated2DOrientedValues.h - # simulated3D example -sources += Simulated3D.cpp +sources += simulated3D.cpp check_PROGRAMS += tests/testSimulated3D # Generic SLAM headers @@ -50,12 +38,6 @@ check_PROGRAMS += tests/testPose2SLAM sources += planarSLAM.cpp check_PROGRAMS += tests/testPlanarSLAM -# MATLAB Wrap headers for planarSLAM -# headers += Landmark2.h -# headers += PlanarSLAMGraph.h -# headers += PlanarSLAMValues.h -# headers += PlanarSLAMOdometry.h - # 3D Pose constraints sources += pose3SLAM.cpp check_PROGRAMS += tests/testPose3SLAM diff --git a/gtsam/slam/Simulated2DMeasurement.h b/gtsam/slam/Simulated2DMeasurement.h deleted file mode 100644 index 0ab661086..000000000 --- a/gtsam/slam/Simulated2DMeasurement.h +++ /dev/null @@ -1,28 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file Simulated2DMeasurement.h - * @brief Re-created on Feb 22, 2010 for compatibility with MATLAB - * @author Frank Dellaert - */ - -#pragma once - -#include -#include - -namespace gtsam { - - typedef simulated2D::Measurement Simulated2DMeasurement; - -} - diff --git a/gtsam/slam/Simulated2DOdometry.h b/gtsam/slam/Simulated2DOdometry.h deleted file mode 100644 index 5bd3afc14..000000000 --- a/gtsam/slam/Simulated2DOdometry.h +++ /dev/null @@ -1,28 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file Simulated2DOdometry.h - * @brief Re-created on Feb 22, 2010 for compatibility with MATLAB - * @author Frank Dellaert - */ - -#pragma once - -#include -#include - -namespace gtsam { - - typedef simulated2D::Odometry Simulated2DOdometry; - -} - diff --git a/gtsam/slam/Simulated2DOrientedOdometry.h b/gtsam/slam/Simulated2DOrientedOdometry.h deleted file mode 100644 index 1a659c081..000000000 --- a/gtsam/slam/Simulated2DOrientedOdometry.h +++ /dev/null @@ -1,28 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file Simulated2DOrientedOdometry.h - * @brief Re-created on Feb 22, 2010 for compatibility with MATLAB - * @author Kai Ni - */ - -#pragma once - -#include -#include - -namespace gtsam { - - typedef simulated2DOriented::Odometry Simulated2DOrientedOdometry; - -} - diff --git a/gtsam/slam/Simulated2DOrientedPosePrior.h b/gtsam/slam/Simulated2DOrientedPosePrior.h deleted file mode 100644 index 54a83f1be..000000000 --- a/gtsam/slam/Simulated2DOrientedPosePrior.h +++ /dev/null @@ -1,29 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file Simulated2DOrientedPosePrior.h - * @brief Re-created on Feb 22, 2010 for compatibility with MATLAB - * @author Kai Ni - */ - -#pragma once - -#include -#include - -namespace gtsam { - - /** Create a prior on a pose Point2 with key 'x1' etc... */ - typedef simulated2DOriented::GenericPosePrior Simulated2DOrientedPosePrior; - -} - diff --git a/gtsam/slam/Simulated2DOrientedValues.h b/gtsam/slam/Simulated2DOrientedValues.h deleted file mode 100644 index b1fe098f8..000000000 --- a/gtsam/slam/Simulated2DOrientedValues.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file Simulated2DValues.h - * @brief Re-created on Feb 22, 2010 for compatibility with MATLAB - * @author Frank Dellaert - */ - -#pragma once - -#include - -namespace gtsam { - - class Simulated2DOrientedValues: public simulated2DOriented::Values { - public: - typedef boost::shared_ptr sharedPoint; - typedef boost::shared_ptr sharedPose; - - Simulated2DOrientedValues() { - } - - void insertPose(const simulated2DOriented::PoseKey& i, const Pose2& p) { - insert(i, p); - } - - void insertPoint(const simulated2DOriented::PointKey& j, const Point2& p) { - insert(j, p); - } - - int nrPoses() const { - return this->first_.size(); - } - - int nrPoints() const { - return this->second_.size(); - } - - sharedPose pose(const simulated2DOriented::PoseKey& i) { - return sharedPose(new Pose2((*this)[i])); - } - - sharedPoint point(const simulated2DOriented::PointKey& j) { - return sharedPoint(new Point2((*this)[j])); - } - - }; - -} // namespace gtsam - diff --git a/gtsam/slam/Simulated2DPointPrior.h b/gtsam/slam/Simulated2DPointPrior.h deleted file mode 100644 index 8fc896d92..000000000 --- a/gtsam/slam/Simulated2DPointPrior.h +++ /dev/null @@ -1,29 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file Simulated2DPointPrior.h - * @brief Re-created on Feb 22, 2010 for compatibility with MATLAB - * @author Frank Dellaert - */ - -#pragma once - -#include -#include - -namespace gtsam { - - /** Create a prior on a landmark Point2 with key 'l1' etc... */ - typedef simulated2D::GenericPrior Simulated2DPointPrior; - -} - diff --git a/gtsam/slam/Simulated2DPosePrior.h b/gtsam/slam/Simulated2DPosePrior.h deleted file mode 100644 index 1c85e4d5b..000000000 --- a/gtsam/slam/Simulated2DPosePrior.h +++ /dev/null @@ -1,29 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file Simulated2DPosePrior.h - * @brief Re-created on Feb 22, 2010 for compatibility with MATLAB - * @author Frank Dellaert - */ - -#pragma once - -#include -#include - -namespace gtsam { - - /** Create a prior on a pose Point2 with key 'x1' etc... */ - typedef simulated2D::GenericPrior Simulated2DPosePrior; - -} - diff --git a/gtsam/slam/Simulated2DValues.h b/gtsam/slam/Simulated2DValues.h deleted file mode 100644 index c4d1d1534..000000000 --- a/gtsam/slam/Simulated2DValues.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file Simulated2DValues.h - * @brief Re-created on Feb 22, 2010 for compatibility with MATLAB - * @author Frank Dellaert - */ - -#pragma once - -#include - -namespace gtsam { - - class Simulated2DValues: public simulated2D::Values { - public: - typedef boost::shared_ptr sharedPoint; - - Simulated2DValues() { - } - - void insertPose(const simulated2D::PoseKey& i, const Point2& p) { - insert(i, p); - } - - void insertPoint(const simulated2D::PointKey& j, const Point2& p) { - insert(j, p); - } - - int nrPoses() const { - return this->first_.size(); - } - - int nrPoints() const { - return this->second_.size(); - } - - sharedPoint pose(const simulated2D::PoseKey& i) { - return sharedPoint(new Point2((*this)[i])); - } - - sharedPoint point(const simulated2D::PointKey& j) { - return sharedPoint(new Point2((*this)[j])); - } - - }; - -} // namespace gtsam - diff --git a/gtsam/slam/simulated2D.h b/gtsam/slam/simulated2D.h index 3b63c9595..cae60bb80 100644 --- a/gtsam/slam/simulated2D.h +++ b/gtsam/slam/simulated2D.h @@ -21,6 +21,7 @@ #include #include #include +#include // \namespace @@ -72,13 +73,13 @@ namespace gtsam { } /// Return pose i - sharedPoint pose(const simulated2D::PoseKey& i) { - return sharedPoint(new Point2((*this)[i])); + Point2 pose(const simulated2D::PoseKey& i) const { + return (*this)[i]; } /// Return point j - sharedPoint point(const simulated2D::PointKey& j) { - return sharedPoint(new Point2((*this)[j])); + Point2 point(const simulated2D::PointKey& j) const { + return (*this)[j]; } }; @@ -232,5 +233,12 @@ namespace gtsam { typedef GenericOdometry Odometry; typedef GenericMeasurement Measurement; + // Specialization of a graph for this example domain + // TODO: add functions to add factor types + class Graph : public NonlinearFactorGraph { + public: + Graph() {} + }; + } // namespace simulated2D } // namespace gtsam diff --git a/gtsam/slam/simulated2DOriented.h b/gtsam/slam/simulated2DOriented.h index 3710f29ad..b9cf150ef 100644 --- a/gtsam/slam/simulated2DOriented.h +++ b/gtsam/slam/simulated2DOriented.h @@ -21,6 +21,7 @@ #include #include #include +#include // \namespace @@ -33,7 +34,27 @@ namespace gtsam { typedef TypedSymbol PoseKey; typedef Values PoseValues; typedef Values PointValues; - typedef TupleValues2 Values; + + /// Specialized Values structure with syntactic sugar for + /// compatibility with matlab + class Values: public TupleValues2 { + public: + Values() {} + + void insertPose(const PoseKey& i, const Pose2& p) { + insert(i, p); + } + + void insertPoint(const PointKey& j, const Point2& p) { + insert(j, p); + } + + int nrPoses() const { return this->first_.size(); } + int nrPoints() const { return this->second_.size(); } + + Pose2 pose(const PoseKey& i) const { return (*this)[i]; } + Point2 point(const PointKey& j) const { return (*this)[j]; } + }; //TODO:: point prior is not implemented right now @@ -100,5 +121,12 @@ namespace gtsam { typedef GenericOdometry Odometry; + /// Graph specialization for syntactic sugar use with matlab + class Graph : public NonlinearFactorGraph { + public: + Graph() {} + // TODO: add functions to add factors + }; + } // namespace simulated2DOriented } // namespace gtsam diff --git a/gtsam/slam/Simulated3D.cpp b/gtsam/slam/simulated3D.cpp similarity index 96% rename from gtsam/slam/Simulated3D.cpp rename to gtsam/slam/simulated3D.cpp index 76e65a8cf..e2f6211a5 100644 --- a/gtsam/slam/Simulated3D.cpp +++ b/gtsam/slam/simulated3D.cpp @@ -15,7 +15,7 @@ * @author Alex Cunningham **/ -#include +#include namespace gtsam { diff --git a/gtsam/slam/Simulated3D.h b/gtsam/slam/simulated3D.h similarity index 100% rename from gtsam/slam/Simulated3D.h rename to gtsam/slam/simulated3D.h diff --git a/gtsam/slam/tests/testSimulated3D.cpp b/gtsam/slam/tests/testSimulated3D.cpp index de2c534bb..30f41e2fd 100644 --- a/gtsam/slam/tests/testSimulated3D.cpp +++ b/gtsam/slam/tests/testSimulated3D.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include using namespace gtsam; diff --git a/wrap/Makefile.am b/wrap/Makefile.am index 7d0c980e1..3dd54942a 100644 --- a/wrap/Makefile.am +++ b/wrap/Makefile.am @@ -91,16 +91,16 @@ generate_toolbox: $(top_srcdir)/gtsam.h source_mode = -m 644 -wrap-install-matlab-toolbox: +wrap-install-matlab-toolbox: generate_toolbox install -d ${toolbox}/gtsam install ${source_mode} -c ../toolbox/*.m ${toolbox}/gtsam install ${source_mode} -c ../toolbox/*.cpp ${toolbox}/gtsam install ${source_mode} -c ../toolbox/Makefile ${toolbox}/gtsam cp -ru ../toolbox/@* ${toolbox}/gtsam -wrap-install-bin: +wrap-install-bin: wrap install -d ${wrap} - install ./wrap ${wrap} + install -c ./wrap ${wrap} wrap-install-matlab-tests: install -d ${toolbox}/gtsam/tests