testRobust.cpp
Go to the documentation of this file.
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 
21 #include <gtsam/base/Testable.h>
26 
27 using namespace gtsam;
28 
29 TEST(RobustNoise, loss) {
30  // Keys.
31  gtsam::Key x1_key = 1;
32  gtsam::Key x2_key = 2;
33 
36 
37  auto factor = PriorFactor<double>(x1_key, 0.0, noise);
38  auto between_factor = BetweenFactor<double>(x1_key, x2_key, 0.0, noise);
39 
40  Values values;
41  values.insert(x1_key, 10.0);
42  values.insert(x2_key, 0.0);
43 
44  EXPECT_DOUBLES_EQUAL(0.49505, factor.error(values), 1e-5);
45  EXPECT_DOUBLES_EQUAL(0.49505, between_factor.error(values), 1e-5);
46  EXPECT_DOUBLES_EQUAL(0.49505, gm->loss(10.0), 1e-5);
47 }
48 
49 int main() {
50  TestResult tr;
51 
52  return TestRegistry::runAllTests(tr);
53 }
static shared_ptr Create(double k, const ReweightScheme reweight=Block)
Provides additional testing facilities for common data structures.
Concept check for values that can be used in unit tests.
static int runAllTests(TestResult &result)
leaf::MyValues values
Some functions to compute numerical derivatives.
static shared_ptr Create(const RobustModel::shared_ptr &robust, const NoiseModel::shared_ptr noise)
Definition: NoiseModel.cpp:704
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
Definition: Test.h:161
static shared_ptr Create(size_t dim)
Definition: NoiseModel.h:610
int main()
Definition: testRobust.cpp:49
Array< double, 1, 3 > e(1./3., 0.5, 2.)
traits
Definition: chartTesting.h:28
double error(const Values &c) const override
TEST(SmartFactorBase, Pinhole)
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:39:17