1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
12/**
13 * @file testSimulated3D.cpp
14 * @brief Unit tests for simulated 3D measurement functions
15 * @author Alex Cunningham
16 **/
17
18#include <tests/simulated3D.h>
19#include <gtsam/inference/Symbol.h>
20#include <gtsam/geometry/Pose3.h>
21#include <gtsam/base/Testable.h>
22#include <gtsam/base/numericalDerivative.h>
23
24#include <CppUnitLite/TestHarness.h>
25
26#include <iostream>
27
28using namespace std::placeholders;
29using namespace gtsam;
30
31// Convenience for named keys
32using symbol_shorthand::X;
33using symbol_shorthand::L;
34
35/* ************************************************************************* */
36TEST( simulated3D, Values )
37{
38 Values actual;
39 actual.insert(j: L(j: 1),val: Point3(1,1,1));
40 actual.insert(j: X(j: 2),val: Point3(2,2,2));
41 EXPECT(assert_equal(actual,actual,1e-9));
42}
43
44/* ************************************************************************* */
45TEST( simulated3D, Dprior )
46{
47 Point3 x(1,-9, 7);
48 Matrix numerical = numericalDerivative11<Point3, Point3>(h: std::bind(f&: simulated3D::prior, args: std::placeholders::_1, args: nullptr),x);
49 Matrix computed;
50 simulated3D::prior(x,H: computed);
51 EXPECT(assert_equal(numerical,computed,1e-9));
52}
53
54/* ************************************************************************* */
55TEST( simulated3D, DOdo )
56{
57 Point3 x1(1, -9, 7), x2(-5, 6, 7);
58 Matrix H1, H2;
59 simulated3D::odo(x1, x2, H1, H2);
60 Matrix A1 = numericalDerivative21<Point3, Point3, Point3>(
61 h: std::bind(f&: simulated3D::odo, args: std::placeholders::_1, args: std::placeholders::_2,
62 args: nullptr, args: nullptr),
63 x1, x2);
64 EXPECT(assert_equal(A1, H1, 1e-9));
65 Matrix A2 = numericalDerivative22<Point3, Point3, Point3>(
66 h: std::bind(f&: simulated3D::odo, args: std::placeholders::_1, args: std::placeholders::_2,
67 args: nullptr, args: nullptr),
68 x1, x2);
69 EXPECT(assert_equal(A2, H2, 1e-9));
70}
71
72
73/* ************************************************************************* */
74int main() { TestResult tr; return TestRegistry::runAllTests(result&: tr);}
75/* ************************************************************************* */
76