input.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_INPUT_H
30 #define HECTOR_POSE_ESTIMATION_INPUT_H
31 
33 
34 namespace hector_pose_estimation {
35 
36 class Input
37 {
38 public:
39  Input() {}
40  virtual ~Input() {}
41 
42  virtual int getDimension() const = 0;
43 
44  virtual const std::string& getName() const { return name_; }
45  virtual void setName(const std::string& name) { name_ = name; }
46 
47  virtual Input& operator=(const Input& other) = 0;
48 
49 private:
50  std::string name_;
51 };
52 
53 template <int _Dimension>
54 class Input_ : public Input {
55 public:
56  enum { Dimension = _Dimension };
60 
62 
63  Input_() { u_.setZero(); }
64  template <typename Derived> Input_(const Eigen::MatrixBase<Derived>& u) : u_(u) {}
65  template <typename Derived> Input_(const Eigen::MatrixBase<Derived>& u, const Variance& Q) : u_(u), variance_(new Variance(Q)) {}
66  Input_(double u) { *this = u; }
67  Input_(double u, const Variance& Q) : variance_(new Variance(Q)) { *this = u; }
68  Input_(const Input& other) { *this = other; }
69  virtual ~Input_() {}
70 
71  virtual int getDimension() const { return Dimension; }
72 
73  virtual Vector const &getVector() const { return u_; }
74  virtual Vector& u() { return u_; }
75 
76  virtual Variance &setVariance(const Variance &other) {
77  if (!variance_) variance_.reset(new Variance);
78  *variance_ = other;
79  return *variance_;
80  }
81 
82  virtual bool hasVariance() const { return (variance_.get() != 0); }
83  virtual Variance const &getVariance() { if (!variance_) variance_.reset(new Variance); return *variance_; }
84  virtual Variance const &getVariance() const { return *variance_; }
85  virtual Variance& variance() { if (!variance_) variance_.reset(new Variance); return *variance_; }
86 
87  virtual Input_<Dimension>& operator=(const Input& other) {
88  *this = static_cast<const Input_<Dimension>&>(other);
89  return *this;
90  }
91 
93  u_ = other.getVector();
94  if (other.variance_) setVariance(*other.variance_);
95  return *this;
96  }
97 
98  template <typename Derived> Vector &operator=(const Eigen::MatrixBase<Derived>& other) {
99  u_ = other;
100  return u_;
101  }
102 
103  virtual Vector &operator=(double u) { u_.setConstant(u); return u_; }
104 
105 protected:
106  Vector u_;
108 };
109 
110 namespace traits {
111  template <class Model> struct Input {
112  enum { Dimension = 0 };
116  };
117 }
118 
119 } // namespace hector_pose_estimation
120 
121 #endif // HECTOR_POSE_ESTIMATION_INPUT_H
virtual Variance const & getVariance()
Definition: input.h:83
virtual Variance const & getVariance() const
Definition: input.h:84
virtual bool hasVariance() const
Definition: input.h:82
SymmetricMatrix_< Dimension >::type Variance
Definition: input.h:59
virtual const std::string & getName() const
Definition: input.h:44
virtual Variance & variance()
Definition: input.h:85
virtual int getDimension() const
Definition: input.h:71
boost::shared_ptr< Variance > variance_
Definition: input.h:107
Matrix_< RowsCols, RowsCols >::type type
Definition: matrix.h:84
Vector & operator=(const Eigen::MatrixBase< Derived > &other)
Definition: input.h:98
virtual Vector const & getVector() const
Definition: input.h:73
virtual void setName(const std::string &name)
Definition: input.h:45
virtual Vector & operator=(double u)
Definition: input.h:103
Input_< Dimension > Type
Definition: input.h:57
boost::shared_ptr< Input_< _Dimension > > Ptr
Definition: input.h:61
Input_(const Eigen::MatrixBase< Derived > &u)
Definition: input.h:64
virtual Input & operator=(const Input &other)=0
virtual int getDimension() const =0
Input_(const Eigen::MatrixBase< Derived > &u, const Variance &Q)
Definition: input.h:65
virtual Vector & u()
Definition: input.h:74
virtual Variance & setVariance(const Variance &other)
Definition: input.h:76
ColumnVector_< Dimension >::type Vector
Definition: input.h:58
virtual Input_< Dimension > & operator=(const Input &other)
Definition: input.h:87
Input_(double u, const Variance &Q)
Definition: input.h:67
Input_(const Input &other)
Definition: input.h:68
Input_< Dimension > Type
Definition: input.h:113
virtual Input_< Dimension > & operator=(const Input_< Dimension > &other)
Definition: input.h:92
SymmetricMatrix_< 0 > Variance
Definition: input.h:115


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