gtsam
Loading...
Searching...
No Matches
BarometricFactor.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
18#pragma once
19
24
25namespace gtsam {
26
35class GTSAM_EXPORT BarometricFactor
36 : public NoiseModelFactorT<Vector1, Pose3, double> {
37 private:
39
40 double nT_;
41
42 public:
43
44 // Provide access to the Matrix& version of evaluateError:
46
48 typedef std::shared_ptr<BarometricFactor> shared_ptr;
49
52
54 BarometricFactor() : nT_(0) {}
55
56 ~BarometricFactor() override {}
57
65 BarometricFactor(Key key, Key baroKey, const double& baroIn,
66 const SharedNoiseModel& model)
67 : Base(model, key, baroKey), nT_(heightOut(baroIn)) {}
68
70 gtsam::NonlinearFactor::shared_ptr clone() const override {
71 return std::static_pointer_cast<gtsam::NonlinearFactor>(
72 gtsam::NonlinearFactor::shared_ptr(new This(*this)));
73 }
74
76 void print(
77 const std::string& s = "",
78 const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
79
81 bool equals(const NonlinearFactor& expected,
82 double tol = 1e-9) const override;
83
85 Vector1 evaluateError(const Pose3& p, const double& b,
87 OptionalMatrixType H2) const override;
88
89 inline const double& measurementIn() const { return nT_; }
90
91 inline double heightOut(double n) const {
92 // From https://www.grc.nasa.gov/www/k-12/airplane/atmosmet.html
93 return (std::pow(n / 101.29, 1. / 5.256) * 288.08 - 273.1 - 15.04) /
94 -0.00649;
95 }
96
97 inline double baroOut(const double& meters) const {
98 double temp = 15.04 - 0.00649 * meters;
99 return 101.29 * std::pow(((temp + 273.1) / 288.08), 5.256);
100 }
101
102 private:
103#if GTSAM_ENABLE_BOOST_SERIALIZATION
105 friend class boost::serialization::access;
106 template <class ARCHIVE>
107 void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
108 // NoiseModelFactor1 instead of NoiseModelFactorN for backward compatibility
109 ar& boost::serialization::make_nvp(
110 "NoiseModelFactor1",
111 boost::serialization::base_object<Base>(*this));
112 ar& BOOST_SERIALIZATION_NVP(nT_);
113 }
114#endif
115};
116
117} // namespace gtsam
3D Pose manifold SO(3) x R^3 and group SE(3)
Navigation state composing of attitude, position, and velocity.
Base class for noise model factors with N variables.
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
Matrix * OptionalMatrixType
This typedef will be used everywhere boost::optional<Matrix&> reference was used previously.
Definition NonlinearFactor.h:57
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:846
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
Template to create a binary predicate.
Definition Testable.h:112
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:42
Prior on height in a cartesian frame.
Definition BarometricFactor.h:36
BarometricFactor This
Typedef to this class.
Definition BarometricFactor.h:51
BarometricFactor(Key key, Key baroKey, const double &baroIn, const SharedNoiseModel &model)
Constructor from a measurement of pressure in KPa.
Definition BarometricFactor.h:65
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition BarometricFactor.h:70
std::shared_ptr< BarometricFactor > shared_ptr
shorthand for a smart pointer to a factor
Definition BarometricFactor.h:48
BarometricFactor()
default constructor - only use for serialization
Definition BarometricFactor.h:54
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
virtual Vector1 evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Key key() const
Definition NoiseModelFactorN.h:307
Nonlinear factor base class.
Definition NonlinearFactor.h:70