| 
									
										
										
										
											2012-05-04 01:03:16 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file testVelocityConstraint | 
					
						
							|  |  |  |  * @author Alex Cunningham | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <CppUnitLite/TestHarness.h>
 | 
					
						
							| 
									
										
										
										
											2012-07-23 02:49:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <gtsam_unstable/dynamics/VelocityConstraint.h>
 | 
					
						
							| 
									
										
										
										
											2012-05-04 01:03:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | using namespace gtsam; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const double tol=1e-5; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-10 03:17:15 +08:00
										 |  |  | const Key x1 = 1, x2 = 2; | 
					
						
							| 
									
										
										
										
											2012-05-04 01:03:16 +08:00
										 |  |  | const double dt = 1.0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PoseRTV origin, | 
					
						
							| 
									
										
										
										
											2014-12-22 09:52:31 +08:00
										 |  |  |         pose1(Point3(0.5, 0.0, 0.0), Rot3::identity(), Point3(1.0, 0.0, 0.0)), | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |         pose1a(Point3(0.5, 0.0, 0.0)), | 
					
						
							| 
									
										
										
										
											2014-12-22 09:52:31 +08:00
										 |  |  |         pose2(Point3(1.5, 0.0, 0.0), Rot3::identity(), Point3(1.0, 0.0, 0.0)); | 
					
						
							| 
									
										
										
										
											2012-05-04 01:03:16 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( testVelocityConstraint, trapezoidal ) { | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // hard constraints don't need a noise model
 | 
					
						
							|  |  |  |   VelocityConstraint constraint(x1, x2, dynamics::TRAPEZOIDAL, dt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // verify error function
 | 
					
						
							|  |  |  |   EXPECT(assert_equal(zero(3), constraint.evaluateError(origin, pose1), tol)); | 
					
						
							|  |  |  |   EXPECT(assert_equal(zero(3), constraint.evaluateError(origin, origin), tol)); | 
					
						
							|  |  |  |   EXPECT(assert_equal(delta(3, 0,-1.0), constraint.evaluateError(pose1, pose1), tol)); | 
					
						
							|  |  |  |   EXPECT(assert_equal(delta(3, 0, 0.5), constraint.evaluateError(origin, pose1a), tol)); | 
					
						
							| 
									
										
										
										
											2012-05-04 01:03:16 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( testEulerVelocityConstraint, euler_start ) { | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // hard constraints create their own noise model
 | 
					
						
							|  |  |  |   VelocityConstraint constraint(x1, x2, dynamics::EULER_START, dt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // verify error function
 | 
					
						
							|  |  |  |   EXPECT(assert_equal(delta(3, 0, 0.5), constraint.evaluateError(origin, pose1), tol)); | 
					
						
							|  |  |  |   EXPECT(assert_equal(zero(3), constraint.evaluateError(origin, origin), tol)); | 
					
						
							|  |  |  |   EXPECT(assert_equal(zero(3), constraint.evaluateError(pose1, pose2), tol)); | 
					
						
							|  |  |  |   EXPECT(assert_equal(delta(3, 0, 0.5), constraint.evaluateError(origin, pose1a), tol)); | 
					
						
							| 
									
										
										
										
											2012-05-04 01:03:16 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( testEulerVelocityConstraint, euler_end ) { | 
					
						
							| 
									
										
										
										
											2012-10-02 22:40:07 +08:00
										 |  |  |   // hard constraints create their own noise model
 | 
					
						
							|  |  |  |   VelocityConstraint constraint(x1, x2, dynamics::EULER_END, dt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // verify error function
 | 
					
						
							|  |  |  |   EXPECT(assert_equal(delta(3, 0,-0.5), constraint.evaluateError(origin, pose1), tol)); | 
					
						
							|  |  |  |   EXPECT(assert_equal(zero(3), constraint.evaluateError(origin, origin), tol)); | 
					
						
							|  |  |  |   EXPECT(assert_equal(zero(3), constraint.evaluateError(pose1, pose2), tol)); | 
					
						
							|  |  |  |   EXPECT(assert_equal(delta(3, 0, 0.5), constraint.evaluateError(origin, pose1a), tol)); | 
					
						
							| 
									
										
										
										
											2012-05-04 01:03:16 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | int main() { TestResult tr; return TestRegistry::runAllTests(tr); } | 
					
						
							|  |  |  | /* ************************************************************************* */ |