FitBasis.h
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 
19 /*
20  * Concept needed for LS. Parameters = Coefficients | Values
21  * - Parameters, Jacobian
22  * - PredictFactor(double x)(Parameters p, OptionalJacobian<1,N> H)
23  */
24 
25 #pragma once
26 
27 #include <gtsam/basis/Basis.h>
32 
33 namespace gtsam {
34 
36 using Sequence = std::map<double, double>;
38 using Sample = std::pair<double, double>;
39 
51 template <class Basis>
52 class FitBasis {
53  public:
54  using Parameters = typename Basis::Parameters;
55 
56  private:
58 
59  public:
62  const SharedNoiseModel& model,
63  size_t N) {
65  for (const Sample sample : sequence) {
66  graph.emplace_shared<EvaluationFactor<Basis>>(0, sample.second, model, N,
67  sample.first);
68  }
69  return graph;
70  }
71 
74  const Sequence& sequence, const SharedNoiseModel& model, size_t N) {
76  Values values;
77  values.insert<Parameters>(0, Parameters::Zero(N));
79  return gfg;
80  }
81 
89  FitBasis(const Sequence& sequence, const SharedNoiseModel& model, size_t N) {
91  VectorValues solution = gfg->optimize();
92  parameters_ = solution.at(0);
93  }
94 
96  Parameters parameters() const { return parameters_; }
97 };
98 
99 } // namespace gtsam
GaussianFactorGraph.h
Linear Factor Graph where all factors are Gaussians.
gtsam::GaussianFactorGraph::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactorGraph.h:82
gtsam::FitBasis::LinearGraph
static GaussianFactorGraph::shared_ptr LinearGraph(const Sequence &sequence, const SharedNoiseModel &model, size_t N)
Create linear FG from Sequence.
Definition: FitBasis.h:73
gtsam::FitBasis::Parameters
typename Basis::Parameters Parameters
Definition: FitBasis.h:54
gtsam::VectorValues::at
Vector & at(Key j)
Definition: VectorValues.h:142
gtsam::FitBasis::parameters_
Parameters parameters_
Definition: FitBasis.h:57
gtsam::EvaluationFactor
Factor for enforcing the scalar value of the polynomial BASIS representation at x is the same as the ...
Definition: BasisFactors.h:39
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:245
gtsam::FitBasis
Definition: FitBasis.h:52
sequence
Definition: pytypes.h:2146
gtsam::VectorValues
Definition: VectorValues.h:74
gtsam::Sequence
std::map< double, double > Sequence
Our sequence representation is a map of {x: y} values where y = f(x)
Definition: FitBasis.h:36
gtsam::NonlinearFactorGraph
Definition: NonlinearFactorGraph.h:55
gtsam::Sample
std::pair< double, double > Sample
A sample is a key-value pair from a sequence.
Definition: FitBasis.h:38
Basis.h
Compute an interpolating basis.
BasisFactors.h
Factor definitions for various Basis functors.
VectorValues.h
Factor Graph Values.
gtsam::SharedNoiseModel
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:762
model
noiseModel::Diagonal::shared_ptr model
Definition: doc/Code/Pose2SLAMExample.cpp:7
gtsam
traits
Definition: SFMdata.h:40
NonlinearFactorGraph.h
Factor Graph consisting of non-linear factors.
gtsam::Values
Definition: Values.h:65
gtsam::FitBasis::FitBasis
FitBasis(const Sequence &sequence, const SharedNoiseModel &model, size_t N)
Construct a new FitBasis object.
Definition: FitBasis.h:89
N
#define N
Definition: igam.h:9
gtsam::FitBasis::NonlinearGraph
static NonlinearFactorGraph NonlinearGraph(const Sequence &sequence, const SharedNoiseModel &model, size_t N)
Create nonlinear FG from Sequence.
Definition: FitBasis.h:61
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
gtsam::FitBasis::parameters
Parameters parameters() const
Return Fourier coefficients.
Definition: FitBasis.h:96


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