Added unit test for SmartFactorBase (which immediatly exposed dim bug!)
							parent
							
								
									7c1a795cb4
								
							
						
					
					
						commit
						a7370818fa
					
				| 
						 | 
					@ -1546,6 +1546,14 @@
 | 
				
			||||||
				<useDefaultCommand>true</useDefaultCommand>
 | 
									<useDefaultCommand>true</useDefaultCommand>
 | 
				
			||||||
				<runAllBuilders>true</runAllBuilders>
 | 
									<runAllBuilders>true</runAllBuilders>
 | 
				
			||||||
			</target>
 | 
								</target>
 | 
				
			||||||
 | 
								<target name="testSmartFactorBase.run" path="build/gtsam/slam/tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
 | 
				
			||||||
 | 
									<buildCommand>make</buildCommand>
 | 
				
			||||||
 | 
									<buildArguments>-j4</buildArguments>
 | 
				
			||||||
 | 
									<buildTarget>testSmartFactorBase.run</buildTarget>
 | 
				
			||||||
 | 
									<stopOnError>true</stopOnError>
 | 
				
			||||||
 | 
									<useDefaultCommand>true</useDefaultCommand>
 | 
				
			||||||
 | 
									<runAllBuilders>true</runAllBuilders>
 | 
				
			||||||
 | 
								</target>
 | 
				
			||||||
			<target name="install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
 | 
								<target name="install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
 | 
				
			||||||
				<buildCommand>make</buildCommand>
 | 
									<buildCommand>make</buildCommand>
 | 
				
			||||||
				<buildArguments>-j3</buildArguments>
 | 
									<buildArguments>-j3</buildArguments>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,72 @@
 | 
				
			||||||
 | 
					/* ----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 * 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   testSmartFactorBase.cpp
 | 
				
			||||||
 | 
					 *  @brief  Unit tests for testSmartFactorBase Class
 | 
				
			||||||
 | 
					 *  @author Frank Dellaert
 | 
				
			||||||
 | 
					 *  @date   Feb 2015
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "../SmartFactorBase.h"
 | 
				
			||||||
 | 
					#include <gtsam/geometry/Pose3.h>
 | 
				
			||||||
 | 
					#include <CppUnitLite/TestHarness.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using namespace std;
 | 
				
			||||||
 | 
					using namespace gtsam;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ************************************************************************* */
 | 
				
			||||||
 | 
					#include <gtsam/geometry/PinholeCamera.h>
 | 
				
			||||||
 | 
					#include <gtsam/geometry/Cal3Bundler.h>
 | 
				
			||||||
 | 
					class PinholeFactor: public SmartFactorBase<Pose3, Point2,
 | 
				
			||||||
 | 
					    PinholeCamera<Cal3Bundler>, 9> {
 | 
				
			||||||
 | 
					  virtual double error(const Values& values) const {
 | 
				
			||||||
 | 
					    return 0.0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  virtual boost::shared_ptr<GaussianFactor> linearize(
 | 
				
			||||||
 | 
					      const Values& values) const {
 | 
				
			||||||
 | 
					    return boost::shared_ptr<GaussianFactor>(new JacobianFactor());
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TEST(SmartFactorBase, Pinhole) {
 | 
				
			||||||
 | 
					  PinholeFactor f;
 | 
				
			||||||
 | 
					  f.add(Point2(),1,SharedNoiseModel());
 | 
				
			||||||
 | 
					  f.add(Point2(),2,SharedNoiseModel());
 | 
				
			||||||
 | 
					  EXPECT_LONGS_EQUAL(2*2,f.dim());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ************************************************************************* */
 | 
				
			||||||
 | 
					#include <gtsam/geometry/StereoCamera.h>
 | 
				
			||||||
 | 
					class StereoFactor: public SmartFactorBase<Pose3, StereoPoint2, StereoCamera, 9> {
 | 
				
			||||||
 | 
					  virtual double error(const Values& values) const {
 | 
				
			||||||
 | 
					    return 0.0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  virtual boost::shared_ptr<GaussianFactor> linearize(
 | 
				
			||||||
 | 
					      const Values& values) const {
 | 
				
			||||||
 | 
					    return boost::shared_ptr<GaussianFactor>(new JacobianFactor());
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TEST(SmartFactorBase, Stereo) {
 | 
				
			||||||
 | 
					  StereoFactor f;
 | 
				
			||||||
 | 
					  f.add(StereoPoint2(),1,SharedNoiseModel());
 | 
				
			||||||
 | 
					  f.add(StereoPoint2(),2,SharedNoiseModel());
 | 
				
			||||||
 | 
					  EXPECT_LONGS_EQUAL(2*3,f.dim());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ************************************************************************* */
 | 
				
			||||||
 | 
					int main() {
 | 
				
			||||||
 | 
					  TestResult tr;
 | 
				
			||||||
 | 
					  return TestRegistry::runAllTests(tr);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					/* ************************************************************************* */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue