measurement_update.h
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2011, Johannes Meyer, TU Darmstadt
3 // All rights reserved.
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of the Flight Systems and Automatic Control group,
13 // TU Darmstadt, nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without
15 // specific prior written permission.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //=================================================================================================
28 
29 #ifndef HECTOR_POSE_ESTIMATION_MEASUREMENT_UPDATE_H
30 #define HECTOR_POSE_ESTIMATION_MEASUREMENT_UPDATE_H
31 
32 #include <boost/type_traits/is_base_of.hpp>
33 
34 namespace hector_pose_estimation {
35 
37 {
38 public:
40  virtual ~MeasurementUpdate() {}
41 
42  virtual bool hasVariance() const { return false; }
43 };
44 
45 template <class MeasurementModel>
46 class Update_ : public MeasurementUpdate {
47 public:
48  enum { MeasurementDimension = MeasurementModel::MeasurementDimension };
50  typedef typename MeasurementModel::MeasurementVector Vector;
51  typedef typename MeasurementModel::NoiseVariance Variance;
52 
54  : has_variance_(false)
55  {
56  y_.setZero();
57  }
58  Update_(Vector const& y)
59  : has_variance_(false)
60  {
61  *this = y;
62  }
63  Update_(double y)
64  : has_variance_(false)
65  {
66  *this = y;
67  }
68  Update_(double x, double y, double z)
69  : has_variance_(false)
70  {
71  y_ = Vector(x, y, z);
72  }
73  template <typename OtherDerived> Update_(const Eigen::MatrixBase<OtherDerived>& other)
74  : y_(other)
75  , has_variance_(false)
76  {}
77  virtual ~Update_() {}
78 
79  virtual Vector &operator=(Vector const& y) { y_ = y; return y_; }
80  virtual Vector &operator=(double y) { y_(0) = y; return y_; }
81 
82  virtual Vector const &getVector() const { return y_; }
83 
84  virtual bool hasVariance() const { return has_variance_; }
85  virtual Variance const &getVariance() const { return R_; }
86  virtual void setVariance(Variance const& R) { R_ = R; has_variance_ = true; }
87 
88 protected:
89  Vector y_;
90  Variance R_;
92 };
93 
94 namespace traits {
95 
96  template <class ConcreteModel> struct Update { typedef Update_<ConcreteModel> type; };
97 
98  template <class ConcreteModel, class Enable = void>
100  public:
101  UpdateInspector(const typename Update<ConcreteModel>::type& update) : update_(update) {}
102  typename ConcreteModel::MeasurementVector const& getVector(const State&) { return *static_cast<typename ConcreteModel::MeasurementVector *>(0); }
103  typename ConcreteModel::NoiseVariance const& getVariance(const State&) { return *static_cast<typename ConcreteModel::NoiseVariance *>(0); }
104  private:
106  };
107 
108  template <class ConcreteModel>
109  class UpdateInspector<ConcreteModel, typename boost::enable_if<boost::is_base_of<Update_<ConcreteModel>, typename Update<ConcreteModel>::type> >::type >
110  {
111  public:
112  UpdateInspector(const typename Update<ConcreteModel>::type& update) : update_(update) {}
113  typename ConcreteModel::MeasurementVector const& getVector(const State&) { return update_.getVector(); }
114  typename ConcreteModel::NoiseVariance const& getVariance(const State&) { return update_.getVariance(); }
115  private:
117  };
118 
119 } // namespace traits
120 
121 } // namespace hector_pose_estimation
122 
123 #endif // HECTOR_POSE_ESTIMATION_MEASUREMENT_UPDATE_H
virtual Vector & operator=(Vector const &y)
Update_< MeasurementModel > Type
Update_(const Eigen::MatrixBase< OtherDerived > &other)
Update_(double x, double y, double z)
virtual bool hasVariance() const
virtual void setVariance(Variance const &R)
ConcreteModel::MeasurementVector const & getVector(const State &)
virtual Variance const & getVariance() const
MeasurementModel::MeasurementVector Vector
MeasurementModel::NoiseVariance Variance
UpdateInspector(const typename Update< ConcreteModel >::type &update)
virtual Vector & operator=(double y)
const Update< ConcreteModel >::type & update_
virtual Vector const & getVector() const
ConcreteModel::NoiseVariance const & getVariance(const State &)


hector_pose_estimation_core
Author(s): Johannes Meyer
autogenerated on Thu Feb 18 2021 03:29:30