measurement_model.h
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2011, Johannes Meyer and Martin Nowara, 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_MODEL_H
30 #define HECTOR_POSE_ESTIMATION_MEASUREMENT_MODEL_H
31 
35 
36 namespace hector_pose_estimation {
37 
38 class MeasurementModel : public Model {
39 public:
40  virtual ~MeasurementModel() {}
41 
42  virtual bool init(PoseEstimation& estimator, Measurement &measurement, State& state) { return true; }
43  virtual int getDimension() const = 0;
44 
45  virtual SystemStatus getStatusFlags() { return SystemStatus(0); }
46  virtual bool active(const State& state) { return !(state.getSystemStatus() & STATUS_ALIGNMENT); }
47 
48  virtual bool prepareUpdate(State& state, const MeasurementUpdate& update) { return true; }
49  virtual void afterUpdate(State& state) {}
50 };
51 
52 template <class Derived, int _Dimension> class MeasurementModel_;
53 
54 namespace traits {
55 
56  template <class Derived, int _Dimension = Derived::MeasurementDimension>
58  enum { MeasurementDimension = _Dimension };
64 
65  enum { InputDimension = traits::Input<Derived>::Dimension };
69  };
70 
71  #define MEASUREMENT_MODEL_TRAIT(Derived, _Dimension) \
72  typedef typename traits::MeasurementModel<Derived, _Dimension> trait; \
73  \
74  enum { MeasurementDimension = _Dimension }; \
75  typedef typename trait::MeasurementVector MeasurementVector; \
76  typedef typename trait::NoiseVariance NoiseVariance; \
77  typedef typename trait::MeasurementMatrix MeasurementMatrix; \
78  typedef typename trait::GainMatrix GainMatrix; \
79  typedef typename trait::UpdateVector UpdateVector; \
80  \
81  enum { InputDimension = trait::InputDimension }; \
82  typedef typename trait::InputType InputType; \
83  typedef typename trait::InputVector InputVector; \
84  typedef typename trait::InputMatrix InputMatrix; \
85 
86 } // namespace traits
87 
88 template <class Derived, int _Dimension>
89 class MeasurementModel_ : public MeasurementModel {
90 public:
91  MEASUREMENT_MODEL_TRAIT(Derived, _Dimension)
92  virtual ~MeasurementModel_() {}
93 
94  virtual int getDimension() const { return trait::MeasurementDimension; }
95 
96  Derived *derived() { return static_cast<Derived *>(this); }
97  const Derived *derived() const { return static_cast<const Derived *>(this); }
98 
99  virtual void getExpectedValue(MeasurementVector& y_pred, const State& state);
100  virtual void getStateJacobian(MeasurementMatrix& C, const State& state, bool init = true);
101  virtual void getInputJacobian(InputMatrix& D, const State& state, bool init = true);
102  virtual void getMeasurementNoise(NoiseVariance& R, const State& state, bool init = true);
103 
104  virtual void limitError(MeasurementVector& error) {}
105 
106  virtual const MeasurementVector* getFixedMeasurementVector() const { return 0; }
107 };
108 
109 template <class Derived, int _Dimension>
110 void MeasurementModel_<Derived, _Dimension>::getExpectedValue(MeasurementVector& y_pred, const State& state)
111 {
112  y_pred.setZero();
113 }
114 
115 template <class Derived, int _Dimension>
116 void MeasurementModel_<Derived, _Dimension>::getStateJacobian(MeasurementMatrix& C, const State& state, bool init)
117 {
118  if (init) C.setZero();
119 }
120 
121 template <class Derived, int _Dimension>
123 {
124  if (init) D.setZero();
125 }
126 
127 template <class Derived, int _Dimension>
129 {
130  if (init) R.setZero();
131 }
132 
133 } // namespace hector_pose_estimation
134 
135 #endif // HECTOR_POSE_ESTIMATION_MEASUREMENT_MODEL_H
ColumnVector_< MeasurementDimension >::type MeasurementVector
traits::Input< Derived >::Vector InputVector
virtual void afterUpdate(State &state)
Matrix_< MeasurementDimension, InputDimension >::type InputMatrix
virtual void getInputJacobian(InputMatrix &D, const State &state, bool init=true)
virtual void limitError(MeasurementVector &error)
Matrix_< RowsCols, RowsCols >::type type
Definition: matrix.h:84
ColumnVector_< State::Covariance::RowsAtCompileTime >::type UpdateVector
Matrix_< State::Covariance::RowsAtCompileTime, MeasurementDimension >::type GainMatrix
Matrix_< MeasurementDimension, Dynamic >::type MeasurementMatrix
virtual bool prepareUpdate(State &state, const MeasurementUpdate &update)
#define MEASUREMENT_MODEL_TRAIT(Derived, _Dimension)
virtual bool active(const State &state)
Eigen::Matrix< ScalarType, Rows, Cols,(Rows==1 &&Cols!=1?Eigen::RowMajor:Eigen::ColMajor),(Rows!=Dynamic?Rows:MaxMatrixRowsCols),(Cols!=Dynamic?Cols:MaxMatrixRowsCols) > type
Definition: matrix.h:77
unsigned int SystemStatus
Definition: types.h:70
virtual SystemStatus getSystemStatus() const
Definition: state.h:100
virtual const MeasurementVector * getFixedMeasurementVector() const
virtual void getStateJacobian(MeasurementMatrix &C, const State &state, bool init=true)
virtual void getExpectedValue(MeasurementVector &y_pred, const State &state)
virtual void getMeasurementNoise(NoiseVariance &R, const State &state, bool init=true)
virtual bool init(PoseEstimation &estimator, Measurement &measurement, State &state)
Eigen::Matrix< ScalarType, Rows, 1, Eigen::ColMajor,(Rows!=Dynamic?Rows:MaxVectorSize), 1 > type
Definition: matrix.h:56
SymmetricMatrix_< MeasurementDimension >::type NoiseVariance


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