testHybridFactorGraph.cpp
Go to the documentation of this file.
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 
16 #include <CppUnitLite/Test.h>
19 #include <gtsam/base/utilities.h>
22 #include <gtsam/inference/Symbol.h>
25 
26 using namespace std;
27 using namespace gtsam;
32 
33 /* ****************************************************************************
34  * Test that any linearizedFactorGraph gaussian factors are appended to the
35  * existing gaussian factor graph in the hybrid factor graph.
36  */
37 TEST(HybridFactorGraph, Constructor) {
38  // Initialize the hybrid factor graph
40 }
41 
42 /* ************************************************************************* */
43 // Test if methods to get keys work as expected.
46 
47  // Add prior on x0
48  hfg.add(JacobianFactor(X(0), I_3x3, Z_3x1));
49 
50  // Add factor between x0 and x1
51  hfg.add(JacobianFactor(X(0), I_3x3, X(1), -I_3x3, Z_3x1));
52 
53  // Add a hybrid Gaussian factor ϕ(x1, c1)
54  DiscreteKey m1(M(1), 2);
55  std::vector<GaussianFactor::shared_ptr> components{
56  std::make_shared<JacobianFactor>(X(1), I_3x3, Z_3x1),
57  std::make_shared<JacobianFactor>(X(1), I_3x3, Vector3::Ones())};
59 
60  KeySet expected_continuous{X(0), X(1)};
61  EXPECT(
62  assert_container_equality(expected_continuous, hfg.continuousKeySet()));
63 
64  KeySet expected_discrete{M(1)};
65  EXPECT(assert_container_equality(expected_discrete, hfg.discreteKeySet()));
66 }
67 
68 /* ************************************************************************* */
69 int main() {
70  TestResult tr;
71  return TestRegistry::runAllTests(tr);
72 }
73 /* ************************************************************************* */
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
gtsam::HybridFactorGraph
Definition: HybridFactorGraph.h:38
EXPECT
#define EXPECT(condition)
Definition: Test.h:150
gtsam::Z_3x1
static const Eigen::MatrixBase< Vector3 >::ConstantReturnType Z_3x1
Definition: Vector.h:46
TestHarness.h
gtsam::HybridFactorGraph::continuousKeySet
const KeySet continuousKeySet() const
Get all the continuous keys in the factor graph.
Definition: HybridFactorGraph.cpp:53
gtsam::JacobianFactor
Definition: JacobianFactor.h:91
m1
Matrix3d m1
Definition: IOFormat.cpp:2
X
#define X
Definition: icosphere.cpp:20
gtsam::FastSet< Key >
utilities.h
TestableAssertions.h
Provides additional testing facilities for common data structures.
PriorFactor.h
gtsam::noiseModel::Isotropic
Definition: NoiseModel.h:541
TEST
TEST(HybridFactorGraph, Constructor)
Definition: testHybridFactorGraph.cpp:37
gtsam::HybridGaussianFactorGraph
Definition: HybridGaussianFactorGraph.h:106
L
MatrixXd L
Definition: LLT_example.cpp:6
Symbol.h
gtsam::HybridFactorGraph::discreteKeySet
KeySet discreteKeySet() const
Get all the discrete keys in the factor graph, as a set of Keys.
Definition: HybridFactorGraph.cpp:43
TestResult
Definition: TestResult.h:26
JacobianFactor.h
HybridFactorGraph.h
Factor graph with utilities for hybrid factors.
Test.h
HybridGaussianFactorGraph.h
Linearized Hybrid factor graph that uses type erasure.
gtsam
traits
Definition: SFMdata.h:40
main
int main()
Definition: testHybridFactorGraph.cpp:69
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38
std
Definition: BFloat16.h:88
gtsam::assert_container_equality
bool assert_container_equality(const std::map< size_t, V2 > &expected, const std::map< size_t, V2 > &actual)
Definition: TestableAssertions.h:237
gtsam::HybridGaussianFactor
Implementation of a discrete-conditioned hybrid factor. Implements a joint discrete-continuous factor...
Definition: HybridGaussianFactor.h:60
test_motion::components
std::vector< NoiseModelFactor::shared_ptr > components
Definition: testHybridNonlinearFactorGraph.cpp:120
gtsam::FactorGraph::add
IsDerived< DERIVEDFACTOR > add(std::shared_ptr< DERIVEDFACTOR > factor)
add is a synonym for push_back.
Definition: FactorGraph.h:171
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:07:38