From 5e97efa81518f3ecc83d83d43e425edbe951ceed Mon Sep 17 00:00:00 2001 From: Jeremy Aguilon Date: Wed, 27 Feb 2019 13:04:38 -0500 Subject: [PATCH] Liner and update Cmakelists --- THANKS | 1 + cython/CMakeLists.txt | 3 +-- cython/gtsam_unstable/__init__.py.in | 1 + .../examples/FixedLagSmootherExample.py | 19 +++++++++++++++++++ .../tests/test_FixedLagSmootherExample.py | 12 +++++++++--- 5 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 cython/gtsam_unstable/__init__.py.in diff --git a/THANKS b/THANKS index f84cfa185..689074b6f 100644 --- a/THANKS +++ b/THANKS @@ -1,5 +1,6 @@ GTSAM was made possible by the efforts of many collaborators at Georgia Tech, listed below with their current afffiliation, if they left Tech: +* Jeremy Aguilon * Sungtae An * Doru Balcan, Bank of America * Chris Beall diff --git a/cython/CMakeLists.txt b/cython/CMakeLists.txt index bc21b91d1..b832a76a5 100644 --- a/cython/CMakeLists.txt +++ b/cython/CMakeLists.txt @@ -26,8 +26,7 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX) gtsam_unstable # library to link with "gtsam_unstable;gtsam_unstable_header;cythonize_gtsam" # dependencies to be built before wrapping ) - # for some reasons cython gtsam_unstable can't find gtsam/gtsam.pxd without doing this - file(WRITE ${PROJECT_BINARY_DIR}/cython/gtsam_unstable/__init__.py "") + configure_file(${PROJECT_SOURCE_DIR}/cython/gtsam_unstable/__init__.py.in ${PROJECT_BINARY_DIR}/cython/gtsam_unstable/__init__.py) endif() # Install the custom-generated __init__.py diff --git a/cython/gtsam_unstable/__init__.py.in b/cython/gtsam_unstable/__init__.py.in new file mode 100644 index 000000000..2b0a28321 --- /dev/null +++ b/cython/gtsam_unstable/__init__.py.in @@ -0,0 +1 @@ +from gtsam_unstable import * diff --git a/cython/gtsam_unstable/examples/FixedLagSmootherExample.py b/cython/gtsam_unstable/examples/FixedLagSmootherExample.py index b9777a07c..5fc3bc98d 100644 --- a/cython/gtsam_unstable/examples/FixedLagSmootherExample.py +++ b/cython/gtsam_unstable/examples/FixedLagSmootherExample.py @@ -1,4 +1,11 @@ """ +GTSAM Copyright 2010-2018, 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 + Demonstration of the fixed-lag smoothers using a planar robot example and multiple odometry-like sensors Author: Frank Dellaert (C++), Jeremy Aguilon (Python) @@ -11,12 +18,21 @@ import gtsam_unstable def _timestamp_key_value(key, value): + """ + + """ return gtsam_unstable.FixedLagSmootherKeyTimestampMapValue( key, value ) def BatchFixedLagSmootherExample(): + """ + Runs a batch fixed smoother on an agent with two odometry + sensors that is simply moving along the x axis in constant + speed. + """ + # Define a batch fixed lag smoother, which uses # Levenberg-Marquardt to perform the nonlinear optimization lag = 2.0 @@ -41,6 +57,9 @@ def BatchFixedLagSmootherExample(): delta_time = 0.25 time = 0.25 + # Iterates from 0.25s to 3.0s, adding 0.25s each loop + # In each iteration, the agent moves at a constant speed + # and its two odometers measure the change. while time <= 3.0: previous_key = 1000 * (time - delta_time) current_key = 1000 * time diff --git a/cython/gtsam_unstable/tests/test_FixedLagSmootherExample.py b/cython/gtsam_unstable/tests/test_FixedLagSmootherExample.py index 64895f4d3..8994913a2 100644 --- a/cython/gtsam_unstable/tests/test_FixedLagSmootherExample.py +++ b/cython/gtsam_unstable/tests/test_FixedLagSmootherExample.py @@ -8,9 +8,16 @@ def _timestamp_key_value(key, value): key, value ) class TestFixedLagSmootherExample(unittest.TestCase): - # Simple test that checks for equality between C++ example - # file and the Python implementation + ''' + Tests the fixed lag smoother wrapper + ''' + def test_FixedLagSmootherExample(self): + ''' + Simple test that checks for equality between C++ example + file and the Python implementation. See + gtsam_unstable/examples/FixedLagSmootherExample.cpp + ''' # Define a batch fixed lag smoother, which uses # Levenberg-Marquardt to perform the nonlinear optimization lag = 2.0 @@ -81,7 +88,6 @@ class TestFixedLagSmootherExample(unittest.TestCase): estimate = smoother_batch.calculateEstimatePose2(current_key) self.assertTrue(estimate.equals(ground_truth[i], 1e-4)) - print("PASS") new_timestamps.clear() new_values.clear()