test_HybridNonlinearFactorGraph.py
Go to the documentation of this file.
1 """
2 GTSAM Copyright 2010-2019, Georgia Tech Research Corporation,
3 Atlanta, Georgia 30332-0415
4 All Rights Reserved
5 
6 See LICENSE for the license information
7 
8 Unit tests for Hybrid Nonlinear Factor Graphs.
9 Author: Fan Jiang
10 """
11 # pylint: disable=invalid-name, no-name-in-module, no-member
12 
13 from __future__ import print_function
14 
15 import unittest
16 
17 import numpy as np
18 from gtsam.symbol_shorthand import C, X
19 from gtsam.utils.test_case import GtsamTestCase
20 from gtsam import BetweenFactorPoint3, noiseModel, PriorFactorPoint3, Point3
21 
22 import gtsam
23 
24 
26  """Unit tests for HybridGaussianFactorGraph."""
29  dk = gtsam.DiscreteKeys()
30  dk.push_back((10, 2))
31  nlfg.push_back(BetweenFactorPoint3(1, 2, Point3(
32  1, 2, 3), noiseModel.Diagonal.Variances([1, 1, 1])))
33  nlfg.push_back(
34  PriorFactorPoint3(2, Point3(1, 2, 3),
35  noiseModel.Diagonal.Variances([0.5, 0.5, 0.5])))
36  nlfg.push_back(
37  gtsam.MixtureFactor([1], dk, [
38  PriorFactorPoint3(1, Point3(0, 0, 0),
39  noiseModel.Unit.Create(3)),
40  PriorFactorPoint3(1, Point3(1, 2, 1),
41  noiseModel.Unit.Create(3))
42  ]))
43  nlfg.push_back(gtsam.DecisionTreeFactor((10, 2), "1 3"))
44  values = gtsam.Values()
45  values.insert_point3(1, Point3(0, 0, 0))
46  values.insert_point3(2, Point3(2, 3, 1))
47  hfg = nlfg.linearize(values)
48  hbn = hfg.eliminateSequential()
49  hbv = hbn.optimize()
50  self.assertEqual(hbv.atDiscrete(10), 0)
51 
52 
53 if __name__ == "__main__":
54  unittest.main()
Vector3 Point3
Definition: Point3.h:38
Implementation of a discrete conditional mixture factor.
Definition: MixtureFactor.h:47
PriorFactor< Point3 > PriorFactorPoint3
BetweenFactor< Point3 > BetweenFactorPoint3
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:41


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:37:45