testSimulated2D.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* ----------------------------------------------------------------------------
  2. * GTSAM Copyright 2010, Georgia Tech Research Corporation,
  3. * Atlanta, Georgia 30332-0415
  4. * All Rights Reserved
  5. * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
  6. * See LICENSE for the license information
  7. * -------------------------------------------------------------------------- */
  8. /**
  9. * @file testSimulated2D.cpp
  10. * @brief Unit tests for simulated 2D measurement functions
  11. * @author Christian Potthast
  12. * @author Carlos Nieto
  13. **/
  14. #include <iostream>
  15. #include <CppUnitLite/TestHarness.h>
  16. #include <gtsam/base/Testable.h>
  17. #include <gtsam/base/numericalDerivative.h>
  18. #include <tests/simulated2D.h>
  19. using namespace std;
  20. using namespace gtsam;
  21. using namespace simulated2D;
  22. /* ************************************************************************* */
  23. TEST( simulated2D, Simulated2DValues )
  24. {
  25. simulated2D::Values actual;
  26. actual.insert(1,Point2(1,1));
  27. actual.insert(2,Point2(2,2));
  28. EXPECT(assert_equal(actual,actual,1e-9));
  29. }
  30. /* ************************************************************************* */
  31. TEST( simulated2D, Dprior )
  32. {
  33. Point2 x(1,-9);
  34. Matrix numerical = numericalDerivative11(simulated2D::prior,x);
  35. Matrix computed;
  36. simulated2D::prior(x,computed);
  37. EXPECT(assert_equal(numerical,computed,1e-9));
  38. }
  39. /* ************************************************************************* */
  40. TEST( simulated2D, DOdo )
  41. {
  42. Point2 x1(1,-9),x2(-5,6);
  43. Matrix H1,H2;
  44. simulated2D::odo(x1,x2,H1,H2);
  45. Matrix A1 = numericalDerivative21(simulated2D::odo,x1,x2);
  46. EXPECT(assert_equal(A1,H1,1e-9));
  47. Matrix A2 = numericalDerivative22(simulated2D::odo,x1,x2);
  48. EXPECT(assert_equal(A2,H2,1e-9));
  49. }
  50. /* ************************************************************************* */
  51. int main() { TestResult tr; return TestRegistry::runAllTests(tr);}
  52. /* ************************************************************************* */