FrobeniusFactor.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010-2019, 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 
20 
21 using namespace std;
22 
23 namespace gtsam {
24 
25 //******************************************************************************
27 ConvertNoiseModel(const SharedNoiseModel &model, size_t d, bool defaultToUnit) {
28  double sigma = 1.0;
29 
30  if (model != nullptr) {
31  const auto &robust = std::dynamic_pointer_cast<noiseModel::Robust>(model);
32  Vector sigmas;
33  if (robust) {
34  sigmas = robust->noise()->sigmas();
35  } else {
36  sigmas = model->sigmas();
37  }
38 
39  size_t n = sigmas.size();
40  if (n == 1) {
41  sigma = sigmas(0); // Rot2
42  goto exit;
43  }
44  else if (n == 3 || n == 6) {
45  sigma = sigmas(2); // Pose2, Rot3, or Pose3
46  if (sigmas(0) != sigma || sigmas(1) != sigma) {
47  if (!defaultToUnit) {
48  throw std::runtime_error("Can only convert isotropic rotation noise");
49  }
50  }
51  goto exit;
52  }
53  if (!defaultToUnit) {
54  throw std::runtime_error("Can only convert Pose2/Pose3 noise models");
55  }
56  }
57  exit:
58  auto isoModel = noiseModel::Isotropic::Sigma(d, sigma);
59  const auto &robust = std::dynamic_pointer_cast<noiseModel::Robust>(model);
60  if (robust) {
61  return noiseModel::Robust::Create(
62  noiseModel::mEstimator::Huber::Create(1.345), isoModel);
63  } else {
64  return std::move(isoModel);
65  }
66 }
67 
68 //******************************************************************************
69 
70 } // namespace gtsam
d
static const double d[K][N]
Definition: igam.h:11
test_constructor::sigmas
Vector1 sigmas
Definition: testHybridNonlinearFactor.cpp:52
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:38
sampling::sigma
static const double sigma
Definition: testGaussianBayesNet.cpp:170
n
int n
Definition: BiCGSTAB_simple.cpp:1
gtsam::SharedNoiseModel
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:762
model
noiseModel::Diagonal::shared_ptr model
Definition: doc/Code/Pose2SLAMExample.cpp:7
gtsam::ConvertNoiseModel
SharedNoiseModel ConvertNoiseModel(const SharedNoiseModel &model, size_t d, bool defaultToUnit)
Definition: FrobeniusFactor.cpp:27
gtsam
traits
Definition: SFMdata.h:40
std
Definition: BFloat16.h:88
FrobeniusFactor.h
Various factors that minimize some Frobenius norm.


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:18