| 
									
										
										
										
											2010-10-14 12:54:38 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * 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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  *  @file  testNonlinearFactor.cpp | 
					
						
							|  |  |  |  *  @brief Unit tests for Non-Linear Factor,  | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  |  *  create a non linear factor graph and a values structure for it and | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  |  *  calculate the error for the factor. | 
					
						
							|  |  |  |  *  @author Christian Potthast | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*STL/C++*/ | 
					
						
							|  |  |  | #include <iostream>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-26 04:10:33 +08:00
										 |  |  | #include <CppUnitLite/TestHarness.h>
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-18 13:38:53 +08:00
										 |  |  | // TODO: DANGEROUS, create shared pointers
 | 
					
						
							|  |  |  | #define GTSAM_MAGIC_GAUSSIAN 2
 | 
					
						
							| 
									
										
										
										
											2010-01-18 03:34:57 +08:00
										 |  |  | #define GTSAM_MAGIC_KEY
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-20 01:23:19 +08:00
										 |  |  | #include <gtsam/base/Matrix.h>
 | 
					
						
							|  |  |  | #include <gtsam/slam/smallExample.h>
 | 
					
						
							|  |  |  | #include <gtsam/slam/simulated2D.h>
 | 
					
						
							|  |  |  | #include <gtsam/linear/GaussianFactor.h>
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | #include <gtsam/nonlinear/NonlinearFactorGraph-inl.h>
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | using namespace std; | 
					
						
							|  |  |  | using namespace gtsam; | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  | using namespace example; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  | typedef boost::shared_ptr<NonlinearFactor<VectorValues> > shared_nlf; | 
					
						
							| 
									
										
										
										
											2009-10-07 02:25:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-25 04:01:47 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-11-13 00:47:12 +08:00
										 |  |  | TEST( NonlinearFactor, equals ) | 
					
						
							| 
									
										
										
										
											2009-10-25 04:01:47 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-01-23 01:36:57 +08:00
										 |  |  | 	SharedGaussian sigma(noiseModel::Isotropic::Sigma(2,1.0)); | 
					
						
							| 
									
										
										
										
											2009-10-25 04:01:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// create two nonlinear2 factors
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  | 	Point2 z3(0.,-1.); | 
					
						
							|  |  |  | 	simulated2D::Measurement f0(z3, sigma, 1,1); | 
					
						
							| 
									
										
										
										
											2009-10-25 04:01:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// measurement between x2 and l1
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  | 	Point2 z4(-1.5, -1.); | 
					
						
							|  |  |  | 	simulated2D::Measurement f1(z4, sigma, 2,1); | 
					
						
							| 
									
										
										
										
											2009-10-25 04:01:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	CHECK(assert_equal(f0,f0)); | 
					
						
							|  |  |  | 	CHECK(f0.equals(f0)); | 
					
						
							|  |  |  | 	CHECK(!f0.equals(f1)); | 
					
						
							|  |  |  | 	CHECK(!f1.equals(f0)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-11-13 00:47:12 +08:00
										 |  |  | TEST( NonlinearFactor, equals2 ) | 
					
						
							| 
									
										
										
										
											2009-10-25 04:01:47 +08:00
										 |  |  | { | 
					
						
							|  |  |  |   // create a non linear factor graph
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  |   Graph fg = createNonlinearFactorGraph(); | 
					
						
							| 
									
										
										
										
											2009-10-25 04:01:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // get two factors
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  |   Graph::sharedFactor f0 = fg[0], f1 = fg[1]; | 
					
						
							| 
									
										
										
										
											2009-10-25 04:01:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   CHECK(f0->equals(*f0)); | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | // SL-FIX  CHECK(!f0->equals(*f1));
 | 
					
						
							|  |  |  | // SL-FIX  CHECK(!f1->equals(*f0));
 | 
					
						
							| 
									
										
										
										
											2009-10-25 04:01:47 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-11-13 00:47:12 +08:00
										 |  |  | TEST( NonlinearFactor, NonlinearFactor ) | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | { | 
					
						
							|  |  |  |   // create a non linear factor graph
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  |   Graph fg = createNonlinearFactorGraph(); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  |   // create a values structure for the non linear factor graph
 | 
					
						
							|  |  |  |   Values cfg = createNoisyValues(); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // get the factor "f1" from the factor graph
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  |   Graph::sharedFactor factor = fg[0]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // calculate the error_vector from the factor "f1"
 | 
					
						
							| 
									
										
										
										
											2010-01-18 13:38:53 +08:00
										 |  |  |   // the expected value for the whitened error from the factor
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  |   // error_vector / sigma = [0.1 0.1]/0.1 = [1;1]
 | 
					
						
							| 
									
										
										
										
											2010-01-18 13:38:53 +08:00
										 |  |  |   Vector actual_e = factor->whitenedError(cfg); | 
					
						
							|  |  |  |   CHECK(assert_equal(ones(2),actual_e)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  |   // error = 0.5 * [1 1] * [1;1] = 1
 | 
					
						
							|  |  |  |   double expected = 1.0;  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // calculate the error from the factor "f1"
 | 
					
						
							|  |  |  |   double actual = factor->error(cfg); | 
					
						
							|  |  |  |   DOUBLES_EQUAL(expected,actual,0.00000001); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-11-13 00:47:12 +08:00
										 |  |  | TEST( NonlinearFactor, linearize_f1 ) | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  |   Values c = createNoisyValues(); | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  |   // Grab a non-linear factor
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  |   Graph nfg = createNonlinearFactorGraph(); | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  |   Graph::sharedFactor nlf = nfg[0]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // We linearize at noisy config from SmallExample
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |   GaussianFactor::shared_ptr actual = nlf->linearize(c, *c.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |   GaussianFactorGraph lfg = createGaussianFactorGraph(*c.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2009-11-13 00:16:32 +08:00
										 |  |  |   GaussianFactor::shared_ptr expected = lfg[0]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-10 21:54:34 +08:00
										 |  |  |   CHECK(assert_equal(*expected,*actual)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // The error |A*dx-b| approximates (h(x0+dx)-z) = -error_vector
 | 
					
						
							|  |  |  |   // Hence i.e., b = approximates z-h(x0) = error_vector(x0)
 | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  | 	//CHECK(assert_equal(nlf->error_vector(c),actual->get_b()));
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-11-13 00:47:12 +08:00
										 |  |  | TEST( NonlinearFactor, linearize_f2 ) | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  |   Values c = createNoisyValues(); | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  |   // Grab a non-linear factor
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  |   Graph nfg = createNonlinearFactorGraph(); | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  |   Graph::sharedFactor nlf = nfg[1]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // We linearize at noisy config from SmallExample
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |   GaussianFactor::shared_ptr actual = nlf->linearize(c, *c.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |   GaussianFactorGraph lfg = createGaussianFactorGraph(*c.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2009-11-13 00:16:32 +08:00
										 |  |  |   GaussianFactor::shared_ptr expected = lfg[1]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  |   CHECK(assert_equal(*expected,*actual)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-11-13 00:47:12 +08:00
										 |  |  | TEST( NonlinearFactor, linearize_f3 ) | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | { | 
					
						
							|  |  |  |   // Grab a non-linear factor
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  |   Graph nfg = createNonlinearFactorGraph(); | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  |   Graph::sharedFactor nlf = nfg[2]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // We linearize at noisy config from SmallExample
 | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  |   Values c = createNoisyValues(); | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |   GaussianFactor::shared_ptr actual = nlf->linearize(c, *c.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |   GaussianFactorGraph lfg = createGaussianFactorGraph(*c.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2009-11-13 00:16:32 +08:00
										 |  |  |   GaussianFactor::shared_ptr expected = lfg[2]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  |   CHECK(assert_equal(*expected,*actual)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-11-13 00:47:12 +08:00
										 |  |  | TEST( NonlinearFactor, linearize_f4 ) | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | { | 
					
						
							|  |  |  |   // Grab a non-linear factor
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  |   Graph nfg = createNonlinearFactorGraph(); | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  |   Graph::sharedFactor nlf = nfg[3]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // We linearize at noisy config from SmallExample
 | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  |   Values c = createNoisyValues(); | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |   GaussianFactor::shared_ptr actual = nlf->linearize(c, *c.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  |   GaussianFactorGraph lfg = createGaussianFactorGraph(*c.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2009-11-13 00:16:32 +08:00
										 |  |  |   GaussianFactor::shared_ptr expected = lfg[3]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-27 12:39:35 +08:00
										 |  |  |   CHECK(assert_equal(*expected,*actual)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-11-13 00:47:12 +08:00
										 |  |  | TEST( NonlinearFactor, size ) | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | { | 
					
						
							|  |  |  | 	// create a non linear factor graph
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  | 	Graph fg = createNonlinearFactorGraph(); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  | 	// create a values structure for the non linear factor graph
 | 
					
						
							|  |  |  | 	Values cfg = createNoisyValues(); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	// get some factors from the graph
 | 
					
						
							| 
									
										
										
										
											2010-01-19 13:33:44 +08:00
										 |  |  | 	Graph::sharedFactor factor1 = fg[0], factor2 = fg[1], | 
					
						
							|  |  |  | 			factor3 = fg[2]; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	CHECK(factor1->size() == 1); | 
					
						
							|  |  |  | 	CHECK(factor2->size() == 2); | 
					
						
							|  |  |  | 	CHECK(factor3->size() == 2); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-08 07:17:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-29 01:21:24 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( NonlinearFactor, linearize_constraint1 ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Vector sigmas = Vector_(2, 0.2, 0.0); | 
					
						
							|  |  |  | 	SharedDiagonal constraint = noiseModel::Constrained::MixedSigmas(sigmas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Point2 mu(1., -1.); | 
					
						
							|  |  |  | 	Graph::sharedFactor f0(new simulated2D::Prior(mu, constraint, 1)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  | 	Values config; | 
					
						
							| 
									
										
										
										
											2010-01-29 01:21:24 +08:00
										 |  |  | 	config.insert(simulated2D::PoseKey(1), Point2(1.0, 2.0)); | 
					
						
							| 
									
										
										
										
											2010-12-17 08:51:51 +08:00
										 |  |  | 	JacobianFactor::shared_ptr actual = f0->linearize(config, *config.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2010-01-29 01:21:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// create expected
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | 	Ordering ord(*config.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2010-01-29 01:21:24 +08:00
										 |  |  | 	Vector b = Vector_(2, 0., -3.); | 
					
						
							| 
									
										
										
										
											2010-12-17 08:51:51 +08:00
										 |  |  | 	JacobianFactor expected(ord["x1"], eye(2), b, constraint); | 
					
						
							| 
									
										
										
										
											2010-01-29 01:21:24 +08:00
										 |  |  | 	CHECK(assert_equal(expected, *actual)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( NonlinearFactor, linearize_constraint2 ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Vector sigmas = Vector_(2, 0.2, 0.0); | 
					
						
							|  |  |  | 	SharedDiagonal constraint = noiseModel::Constrained::MixedSigmas(sigmas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Point2 z3(1.,-1.); | 
					
						
							|  |  |  | 	simulated2D::Measurement f0(z3, constraint, 1,1); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-09 11:09:58 +08:00
										 |  |  | 	Values config; | 
					
						
							| 
									
										
										
										
											2010-01-29 01:21:24 +08:00
										 |  |  | 	config.insert(simulated2D::PoseKey(1), Point2(1.0, 2.0)); | 
					
						
							|  |  |  | 	config.insert(simulated2D::PointKey(1), Point2(5.0, 4.0)); | 
					
						
							| 
									
										
										
										
											2010-12-17 08:51:51 +08:00
										 |  |  | 	JacobianFactor::shared_ptr actual = f0.linearize(config, *config.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2010-01-29 01:21:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// create expected
 | 
					
						
							| 
									
										
										
										
											2010-10-09 06:04:47 +08:00
										 |  |  | 	Ordering ord(*config.orderingArbitrary()); | 
					
						
							| 
									
										
										
										
											2010-01-29 01:21:24 +08:00
										 |  |  | 	Vector b = Vector_(2, -3., -3.); | 
					
						
							| 
									
										
										
										
											2010-12-17 08:51:51 +08:00
										 |  |  | 	JacobianFactor expected(ord["x1"], -1*eye(2), ord["l1"], eye(2), b, constraint); | 
					
						
							| 
									
										
										
										
											2010-01-29 01:21:24 +08:00
										 |  |  | 	CHECK(assert_equal(expected, *actual)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | int main() { TestResult tr; return TestRegistry::runAllTests(tr);} | 
					
						
							|  |  |  | /* ************************************************************************* */ |