From f216e97a15fe692d85549c747997ca7aa138eb74 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Mon, 15 Apr 2013 17:53:33 +0000 Subject: [PATCH] Modified the getter method in the FixedLagSmoother base class to follow general GTSAM conventions --- ...ConcurrentFilteringAndSmoothingExample.cpp | 4 +- .../examples/FixedLagSmootherExample.cpp | 4 +- gtsam_unstable/nonlinear/FixedLagSmoother.h | 40 ++++++++++++------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/gtsam_unstable/examples/ConcurrentFilteringAndSmoothingExample.cpp b/gtsam_unstable/examples/ConcurrentFilteringAndSmoothingExample.cpp index 13062cf5d..bdbb3835f 100644 --- a/gtsam_unstable/examples/ConcurrentFilteringAndSmoothingExample.cpp +++ b/gtsam_unstable/examples/ConcurrentFilteringAndSmoothingExample.cpp @@ -314,11 +314,11 @@ int main(int argc, char** argv) { cout << setprecision(5) << " Key: " << key_value.key << endl; } cout << " Fixed-Lag Smoother Keys: " << endl; - BOOST_FOREACH(const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp, fixedlagSmoother.getTimestamps()) { + BOOST_FOREACH(const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp, fixedlagSmoother.timestamps()) { cout << setprecision(5) << " Key: " << key_timestamp.first << endl; } cout << " Batch Smoother Keys: " << endl; - BOOST_FOREACH(const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp, batchSmoother.getTimestamps()) { + BOOST_FOREACH(const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp, batchSmoother.timestamps()) { cout << setprecision(5) << " Key: " << key_timestamp.first << endl; } diff --git a/gtsam_unstable/examples/FixedLagSmootherExample.cpp b/gtsam_unstable/examples/FixedLagSmootherExample.cpp index 4ef20740c..4c2b9ba89 100644 --- a/gtsam_unstable/examples/FixedLagSmootherExample.cpp +++ b/gtsam_unstable/examples/FixedLagSmootherExample.cpp @@ -127,11 +127,11 @@ int main(int argc, char** argv) { // And to demonstrate the fixed-lag aspect, print the keys contained in each smoother after 3.0 seconds cout << "After 3.0 seconds, " << endl; cout << " Batch Smoother Keys: " << endl; - BOOST_FOREACH(const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp, smootherBatch.getTimestamps()) { + BOOST_FOREACH(const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp, smootherBatch.timestamps()) { cout << setprecision(5) << " Key: " << key_timestamp.first << " Time: " << key_timestamp.second << endl; } cout << " iSAM2 Smoother Keys: " << endl; - BOOST_FOREACH(const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp, smootherISAM2.getTimestamps()) { + BOOST_FOREACH(const FixedLagSmoother::KeyTimestampMap::value_type& key_timestamp, smootherISAM2.timestamps()) { cout << setprecision(5) << " Key: " << key_timestamp.first << " Time: " << key_timestamp.second << endl; } diff --git a/gtsam_unstable/nonlinear/FixedLagSmoother.h b/gtsam_unstable/nonlinear/FixedLagSmoother.h index 1f58e43d2..521bd8b3b 100644 --- a/gtsam_unstable/nonlinear/FixedLagSmoother.h +++ b/gtsam_unstable/nonlinear/FixedLagSmoother.h @@ -49,6 +49,12 @@ public: size_t linearVariables; ///< The number of variables that must keep a constant linearization point double error; ///< The final factor graph error Result() : iterations(0), nonlinearVariables(0), linearVariables(0), error(0) {}; + + /// Getter methods + size_t getIterations() const { return iterations; } + size_t getNonlinearVariables() const { return nonlinearVariables; } + size_t getLinearVariables() const { return linearVariables; } + double getError() const { return error; } }; @@ -64,21 +70,6 @@ public: /** Check if two IncrementalFixedLagSmoother Objects are equal */ virtual bool equals(const FixedLagSmoother& rhs, double tol = 1e-9) const; - /** Add new factors, updating the solution and relinearizing as needed. */ - virtual Result update(const NonlinearFactorGraph& newFactors = NonlinearFactorGraph(), const Values& newTheta = Values(), - const KeyTimestampMap& timestamps = KeyTimestampMap()) = 0; - - /** Access the current set of timestamps associated with each variable */ - const KeyTimestampMap& getTimestamps() const { - return keyTimestampMap_; - } - - /** Compute an estimate from the incomplete linear delta computed during the last update. - * This delta is incomplete because it was not updated below wildfire_threshold. If only - * a single variable is needed, it is faster to call calculateEstimate(const KEY&). - */ - virtual Values calculateEstimate() const = 0; - /** read the current smoother lag */ double smootherLag() const { return smootherLag_; @@ -89,6 +80,21 @@ public: return smootherLag_; } + /** Access the current set of timestamps associated with each variable */ + const KeyTimestampMap& timestamps() const { + return keyTimestampMap_; + } + + /** Add new factors, updating the solution and relinearizing as needed. */ + virtual Result update(const NonlinearFactorGraph& newFactors = NonlinearFactorGraph(), const Values& newTheta = Values(), + const KeyTimestampMap& timestamps = KeyTimestampMap()) = 0; + + /** Compute an estimate from the incomplete linear delta computed during the last update. + * This delta is incomplete because it was not updated below wildfire_threshold. If only + * a single variable is needed, it is faster to call calculateEstimate(const KEY&). + */ + virtual Values calculateEstimate() const = 0; + protected: @@ -116,4 +122,8 @@ protected: }; // FixedLagSmoother +/// Typedef for matlab wrapping +typedef FixedLagSmoother::KeyTimestampMap FixedLagSmootherKeyTimestampMap; +typedef FixedLagSmoother::Result FixedLagSmootherResult; + } /// namespace gtsam