robot_localization_estimator.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, TNO IVS Helmond.
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
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided
14  * with the distribution.
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef ROBOT_LOCALIZATION_ROBOT_LOCALIZATION_ESTIMATOR_H
34 #define ROBOT_LOCALIZATION_ROBOT_LOCALIZATION_ESTIMATOR_H
35 
36 #include <iostream>
37 #include <vector>
38 #include <boost/circular_buffer.hpp>
39 #include <Eigen/Dense>
40 
44 
45 namespace RobotLocalization
46 {
47 
48 struct Twist
49 {
50  Eigen::Vector3d linear;
51  Eigen::Vector3d angular;
52 };
53 
59 {
61  time_stamp(0.0),
62  state(STATE_SIZE),
63  covariance(STATE_SIZE, STATE_SIZE)
64  {
65  state.setZero();
66  covariance.setZero();
67  }
68 
70  double time_stamp;
71 
73  Eigen::VectorXd state;
74 
76  Eigen::MatrixXd covariance;
77 
78  friend std::ostream& operator<<(std::ostream &os, const EstimatorState& state)
79  {
80  return os << "state:\n - time_stamp: " << state.time_stamp <<
81  "\n - state: \n" << state.state <<
82  " - covariance: \n" << state.covariance;
83  }
84 };
85 
86 namespace EstimatorResults
87 {
89 {
96 };
97 } // namespace EstimatorResults
99 
100 namespace FilterTypes
101 {
103 {
104  EKF = 0,
107 };
108 } // namespace FilterTypes
110 
117 {
118 public:
124  explicit RobotLocalizationEstimator(unsigned int buffer_capacity,
125  FilterType filter_type,
126  const Eigen::MatrixXd& process_noise_covariance,
127  const std::vector<double>& filter_args = std::vector<double>());
128 
131  virtual ~RobotLocalizationEstimator();
132 
137  void setState(const EstimatorState& state);
138 
148  EstimatorResult getState(const double time, EstimatorState &state) const;
149 
152  void clearBuffer();
153 
158  void setBufferCapacity(const int capacity);
159 
167  unsigned int getBufferCapacity() const;
168 
175  unsigned int getSize() const;
176 
177 private:
178  friend std::ostream& operator<<(std::ostream &os, const RobotLocalizationEstimator& rle)
179  {
180  for ( boost::circular_buffer<EstimatorState>::const_iterator it = rle.state_buffer_.begin();
181  it != rle.state_buffer_.end(); ++it )
182  {
183  os << *it << "\n";
184  }
185  return os;
186  }
187 
194  void extrapolate(const EstimatorState& boundary_state,
195  const double requested_time,
196  EstimatorState& state_at_req_time) const;
197 
205  void interpolate(const EstimatorState& given_state_1, const EstimatorState& given_state_2,
206  const double requested_time, EstimatorState& state_at_req_time) const;
207 
212  boost::circular_buffer<EstimatorState> state_buffer_;
213 
218 };
219 
220 } // namespace RobotLocalization
221 
222 #endif // ROBOT_LOCALIZATION_ROBOT_LOCALIZATION_ESTIMATOR_H
const int STATE_SIZE
Global constants that define our state vector size and offsets to groups of values within that state...
Definition: filter_common.h:75
friend std::ostream & operator<<(std::ostream &os, const RobotLocalizationEstimator &rle)
EstimatorResults::EstimatorResult EstimatorResult
friend std::ostream & operator<<(std::ostream &os, const EstimatorState &state)
double time_stamp
Time at which this state is/was achieved.
boost::circular_buffer< EstimatorState > state_buffer_
The buffer holding the system states that have come in. Interpolation and extrapolation is done start...
Eigen::VectorXd state
System state at time = time_stamp.
Eigen::MatrixXd covariance
System state covariance at time = time_stamp.
FilterBase * filter_
A pointer to the filter instance that is used for extrapolation.
Robot Localization Estimator State.
FilterTypes::FilterType FilterType


robot_localization
Author(s): Tom Moore
autogenerated on Wed Feb 3 2021 03:34:02