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 }
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Testable.h
Concept check for values that can be used in unit tests.
TestHarness.h
gtsam::noiseModel::Robust::Create
static shared_ptr Create(const RobustModel::shared_ptr &robust, const NoiseModel::shared_ptr noise)
Definition: NoiseModel.cpp:704
gtsam::PriorFactor
Definition: nonlinear/PriorFactor.h:30
TestableAssertions.h
Provides additional testing facilities for common data structures.
PriorFactor.h
numericalDerivative.h
Some functions to compute numerical derivatives.
main
int main()
Definition: testRobust.cpp:49
BetweenFactor.h
gtsam::noiseModel::Unit::Create
static shared_ptr Create(size_t dim)
Definition: NoiseModel.h:610
EXPECT_DOUBLES_EQUAL
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
Definition: Test.h:161
TestResult
Definition: TestResult.h:26
gtsam
traits
Definition: chartTesting.h:28
gtsam::TEST
TEST(SmartFactorBase, Pinhole)
Definition: testSmartFactorBase.cpp:38
leaf::values
leaf::MyValues values
gtsam::Values
Definition: Values.h:65
gtsam::Values::insert
void insert(Key j, const Value &val)
Definition: Values.cpp:155
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::noiseModel::mEstimator::GemanMcClure::Create
static shared_ptr Create(double k, const ReweightScheme reweight=Block)
Definition: LossFunctions.cpp:343
gtsam::BetweenFactor
Definition: BetweenFactor.h:40


gtsam
Author(s):
autogenerated on Thu Jun 13 2024 03:10:11