ethzasl-msf - Modular Sensor Fusion
Time delay compensated single and multi sensor fusion framework based on an EKF
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
msf_sensormanager.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2013 Simon Lynen, ASL, ETH Zurich, Switzerland
3  * You can contact the author at <slynen at ethz dot ch>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef SENSORMANAGER_H
18 #define SENSORMANAGER_H
19 
20 #include <Eigen/Dense>
21 #include <string.h>
22 #include <msf_core/msf_types.hpp>
24 #include <msf_core/msf_macros.h>
25 
26 namespace msf_core {
27 
28 template<typename EKFState_T>
29 class SensorHandler;
30 
31 template<typename EKFState_T>
32 class MSF_Core;
33 
40 template<typename EKFState_T>
41 class MSF_SensorManager : public StateVisitor<EKFState_T> {
42  private:
43  int sensorID_;
44  protected:
45  typedef std::vector<shared_ptr<SensorHandler<EKFState_T> > > Handlers;
47 
55 
56  public:
57  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
58 
59  shared_ptr<MSF_Core<EKFState_T> > msf_core_;
60 
62 
63  bool data_playback() {
64  return data_playback_;
65  }
66 
67  virtual ~MSF_SensorManager() {
68 
69  }
70  ;
71  /***
72  * Add a new sensor handler to the list of handlers owned by this manager
73  * a sensor handler is in turn owning the sensor (camera/vicon etc.).
74  */
75  void addHandler(shared_ptr<SensorHandler<EKFState_T> > handler) {
76  handler->setSensorID(sensorID_++);
77  handlers.push_back(handler);
78  }
79 
80  /***
81  * Init function for the EKF.
82  */
83  virtual void init(double scale) const = 0;
84 
85  /***
86  * This method will be called for the user to set the initial state.
87  */
88  virtual void initState(EKFState_T& state) const = 0;
89 
90  /***
91  * This method will be called for the user to set the Q block entries for
92  * Auxiliary states only changes to blocks in Q belonging to the auxiliary
93  * states are allowed / evaluated.
94  */
95  virtual void calculateQAuxiliaryStates(EKFState_T& UNUSEDPARAM(state),
96  double UNUSEDPARAM(dt)) const = 0;
97 
98  /***
99  * This method will be called for the user to set the initial P matrix.
100  */
101  virtual void setP(
102  Eigen::Matrix<double, EKFState_T::nErrorStatesAtCompileTime,
103  EKFState_T::nErrorStatesAtCompileTime>& P) const = 0;
104 
105  /***
106  * This method will be called for the user to have the possibility to augment
107  * the correction vector.
108  */
109  virtual void augmentCorrectionVector(
110  Eigen::Matrix<double, EKFState_T::nErrorStatesAtCompileTime, 1>&
111  UNUSEDPARAM(correction)) const = 0;
112 
113  /***
114  * This method will be called for the user to check the correction after it
115  * has been applied to the state delaystate is the state on which the correction
116  * has been applied buffstate is the state before the correction was applied.
117  */
118  virtual void sanityCheckCorrection(
119  EKFState_T& UNUSEDPARAM(delaystate),
120  const EKFState_T& UNUSEDPARAM(buffstate),
121  Eigen::Matrix<double, EKFState_T::nErrorStatesAtCompileTime, 1>&
122  UNUSEDPARAM(correction)) const = 0;
123 
124  /***
125  * Provide a getter for these parameters, this is implemented for a given
126  * middleware or param file parser.
127  */
128  virtual bool getParam_fixed_bias() const = 0;
129  virtual double getParam_noise_acc() const = 0;
130  virtual double getParam_noise_accbias() const = 0;
131  virtual double getParam_noise_gyr() const = 0;
132  virtual double getParam_noise_gyrbias() const = 0;
133  virtual double getParam_fuzzythres() const = 0;
134 
139  virtual void publishStateInitial(
140  const shared_ptr<EKFState_T>& state) const = 0;
141  virtual void publishStateAfterPropagation(
142  const shared_ptr<EKFState_T>& state) const = 0;
143  virtual void publishStateAfterUpdate(
144  const shared_ptr<EKFState_T>& state) const = 0;
145 
146 };
147 } // msf_core
148 
150 
151 #endif // SENSORMANAGER_H