pose_estimation.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_H
30 #define HECTOR_POSE_ESTIMATION_H
31 
37 
38 #include <boost/shared_ptr.hpp>
39 #include <vector>
40 
44 
45 #include <tf/transform_datatypes.h>
46 #include <geometry_msgs/PoseStamped.h>
47 #include <geometry_msgs/PointStamped.h>
48 #include <geometry_msgs/QuaternionStamped.h>
49 #include <geometry_msgs/Vector3Stamped.h>
50 #include <nav_msgs/Odometry.h>
51 #include <sensor_msgs/NavSatFix.h>
52 #include <geographic_msgs/GeoPoint.h>
53 #include <geographic_msgs/GeoPose.h>
54 
55 namespace hector_pose_estimation {
56 
57 class Filter;
58 class GlobalReference;
59 
61 {
62 public:
63  PoseEstimation(const SystemPtr& system = SystemPtr(), const StatePtr& state = StatePtr());
64  template <typename ConcreteSystemModel> PoseEstimation(ConcreteSystemModel *system_model, State *state = 0);
65  virtual ~PoseEstimation();
66 
67  static PoseEstimation *Instance();
68 
69  bool init();
70  void cleanup();
71  void reset();
72 
73  void update(ros::Time timestamp);
74  void update(double dt);
75 
76  const SystemPtr& addSystem(const SystemPtr& system, const std::string& name = "system");
77  const SystemPtr& addSystem(System *system) { return addSystem(SystemPtr(system)); }
78  template <typename ConcreteSystemModel> const SystemPtr& addSystem(ConcreteSystemModel *model, const std::string& name = "system");
79 // SystemPtr getSystem(std::size_t index = 0) const { return systems_.get(index); }
80  SystemPtr getSystem(const std::string& name) const { return systems_.get(name); }
81  template <typename SystemType> boost::shared_ptr<SystemType> getSystem_(const std::string& name) const;
82 
83  const MeasurementPtr& addMeasurement(const MeasurementPtr& measurement, const std::string& name = std::string());
84  const MeasurementPtr& addMeasurement(Measurement *measurement) { return addMeasurement(MeasurementPtr(measurement)); }
85  template <class ConcreteMeasurementModel> const MeasurementPtr& addMeasurement(ConcreteMeasurementModel *model, const std::string& name);
86 // MeasurementPtr getMeasurement(std::size_t index) const { return measurements_.get(index); }
87  MeasurementPtr getMeasurement(const std::string &name) const { return measurements_.get(name); }
88  template <typename MeasurementType> boost::shared_ptr<MeasurementType> getMeasurement_(const std::string& name) const;
89 
90  template <class InputType> boost::shared_ptr<InputType> getInputType(const std::string& name) const { return inputs_.getType<InputType>(name); }
91 
92  template <class InputType> boost::shared_ptr<InputType> addInput(const std::string& name = std::string());
93  InputPtr addInput(const InputPtr& input, const std::string& name = std::string());
94  InputPtr addInput(Input *input, const std::string& name = std::string()) { return addInput(InputPtr(input), name); }
95  InputPtr setInput(const Input& input, std::string name = std::string());
96 // InputPtr getInput(std::size_t index) const { return inputs_.get(index); }
97  InputPtr getInput(const std::string& name) const { return inputs_.get(name); }
98 
99  virtual const State& state() const { return *state_; }
100  virtual State& state() { return *state_; }
101 
102  virtual const State::Vector& getStateVector();
103  virtual const State::Covariance& getCovariance();
104 
105  virtual SystemStatus getSystemStatus() const;
106  virtual SystemStatus getMeasurementStatus() const;
107  virtual bool inSystemStatus(SystemStatus test_status) const;
108  virtual bool setSystemStatus(SystemStatus new_status);
109  virtual bool setMeasurementStatus(SystemStatus new_status);
110  virtual bool updateSystemStatus(SystemStatus set, SystemStatus clear);
111  virtual bool updateMeasurementStatus(SystemStatus set, SystemStatus clear);
112 
113  virtual const GlobalReferencePtr &globalReference();
114 
115  virtual const ros::Time& getTimestamp() const;
116  virtual void setTimestamp(const ros::Time& timestamp);
117 
118  virtual void getHeader(std_msgs::Header& header);
119  virtual void getState(nav_msgs::Odometry& state, bool with_covariances = true);
120  virtual void getPose(tf::Pose& pose);
121  virtual void getPose(tf::Stamped<tf::Pose>& pose);
122  virtual void getPose(geometry_msgs::Pose& pose);
123  virtual void getPose(geometry_msgs::PoseStamped& pose);
124  virtual void getPosition(tf::Point& point);
125  virtual void getPosition(tf::Stamped<tf::Point>& point);
126  virtual void getPosition(geometry_msgs::Point& pose);
127  virtual void getPosition(geometry_msgs::PointStamped& pose);
128  virtual void getGlobal(double& latitude, double& longitude, double& altitude);
129  virtual void getGlobalPosition(double& latitude, double& longitude, double& altitude); // deprecated
130  virtual void getGlobal(geographic_msgs::GeoPoint& global);
131  virtual void getGlobal(sensor_msgs::NavSatFix& global);
132  virtual void getGlobalPosition(sensor_msgs::NavSatFix& global);
133  virtual void getGlobal(geographic_msgs::GeoPoint& position, geometry_msgs::Quaternion& quaternion); // deprecated
134  virtual void getGlobal(geographic_msgs::GeoPose& global);
135  virtual void getOrientation(tf::Quaternion& quaternion);
136  virtual void getOrientation(tf::Stamped<tf::Quaternion>& quaternion);
137  virtual void getOrientation(geometry_msgs::Quaternion& pose);
138  virtual void getOrientation(geometry_msgs::QuaternionStamped& pose);
139  virtual void getOrientation(double &yaw, double &pitch, double &roll);
140  virtual void getImuWithBiases(geometry_msgs::Vector3& linear_acceleration, geometry_msgs::Vector3& angular_velocity);
141  virtual void getVelocity(tf::Vector3& vector);
142  virtual void getVelocity(tf::Stamped<tf::Vector3>& vector);
143  virtual void getVelocity(geometry_msgs::Vector3& vector);
144  virtual void getVelocity(geometry_msgs::Vector3Stamped& vector);
145  virtual void getRate(tf::Vector3& vector);
146  virtual void getRate(tf::Stamped<tf::Vector3>& vector);
147  virtual void getRate(geometry_msgs::Vector3& vector);
148  virtual void getRate(geometry_msgs::Vector3Stamped& vector);
149  // virtual void getBias(tf::Vector3& angular_velocity, tf::Vector3& linear_acceleration);
150  // virtual void getBias(tf::Stamped<tf::Vector3>& angular_velocity, tf::Stamped<tf::Vector3>& linear_acceleration);
151  virtual void getBias(geometry_msgs::Vector3& angular_velocity, geometry_msgs::Vector3& linear_acceleration);
152  virtual void getBias(geometry_msgs::Vector3Stamped& angular_velocity, geometry_msgs::Vector3Stamped& linear_acceleration);
153  virtual void getTransforms(std::vector<tf::StampedTransform>& transforms);
154  virtual void updateWorldToOtherTransform(tf::StampedTransform& world_to_other_transform);
155  virtual bool getWorldToNavTransform(geometry_msgs::TransformStamped& transform);
156 
157  virtual ParameterList& parameters() { return parameters_; }
158  virtual const ParameterList& parameters() const { return parameters_; }
159 
161  virtual boost::shared_ptr<const Filter> filter() const { return filter_; }
162 
163  virtual void updated();
164 
165 protected:
169 
170 private:
173 
175 
177  std::string world_frame_;
178  std::string nav_frame_;
179  std::string base_frame_;
180  std::string stabilized_frame_;
181  std::string footprint_frame_;
182  std::string position_frame_;
183 
186 
187  double gravity_;
188 
192 };
193 
194 template <typename ConcreteSystemModel>
195 PoseEstimation::PoseEstimation(ConcreteSystemModel *system_model, State *state) {
196  *this = PoseEstimation(System::create(system_model), StatePtr(state));
197 }
198 
199 template <typename ConcreteSystemModel>
200 const SystemPtr& PoseEstimation::addSystem(ConcreteSystemModel *model, const std::string& name)
201 {
202  return addSystem(System::create(model, name));
203 }
204 
205 template <typename SystemType>
207 {
208  return boost::static_pointer_cast<SystemType>(getSystem(name));
209 }
210 
211 template <class ConcreteMeasurementModel>
212 const MeasurementPtr& PoseEstimation::addMeasurement(ConcreteMeasurementModel *model, const std::string& name) {
213  return addMeasurement(Measurement::create(model, name));
214 }
215 
216 template <typename MeasurementType>
218 {
219  return boost::static_pointer_cast<MeasurementType>(getMeasurement(name));
220 }
221 
222 template <class InputType>
224  boost::shared_ptr<InputType> input = getInputType<InputType>(name);
225  if (input) return input;
226 
227  input.reset(new InputType());
228  if (!addInput(boost::static_pointer_cast<Input>(input), name)) input.reset();
229  return input;
230 }
231 
232 } // namespace hector_pose_estimation
233 
234 #endif // HECTOR_POSE_ESTIMATION_H
static boost::shared_ptr< Measurement_< ConcreteModel > > create(ConcreteModel *model, const std::string &name)
Definition: measurement.h:187
virtual bool setSystemStatus(SystemStatus new_status)
const SystemPtr & addSystem(const SystemPtr &system, const std::string &name="system")
boost::shared_ptr< System > SystemPtr
Definition: types.h:81
virtual void getRate(tf::Vector3 &vector)
boost::shared_ptr< ZeroRate > zerorate_update_
boost::shared_ptr< SystemType > getSystem_(const std::string &name) const
virtual const GlobalReferencePtr & globalReference()
virtual bool updateMeasurementStatus(SystemStatus set, SystemStatus clear)
virtual ParameterList & parameters()
virtual const State & state() const
SymmetricMatrix Covariance
Definition: state.h:45
InputPtr getInput(const std::string &name) const
virtual void getPose(tf::Pose &pose)
PoseEstimation(const SystemPtr &system=SystemPtr(), const StatePtr &state=StatePtr())
virtual void updateWorldToOtherTransform(tf::StampedTransform &world_to_other_transform)
MeasurementPtr getMeasurement(const std::string &name) const
boost::shared_ptr< Measurement > MeasurementPtr
Definition: types.h:89
static boost::shared_ptr< System_< ConcreteModel > > create(ConcreteModel *model, const std::string &name="system")
Definition: system.h:133
const SystemPtr & addSystem(System *system)
const MeasurementPtr & addMeasurement(Measurement *measurement)
InputPtr setInput(const Input &input, std::string name=std::string())
Ptr get(const key_type &key) const
Definition: collection.h:75
SystemPtr getSystem(const std::string &name) const
boost::shared_ptr< MeasurementType > getMeasurement_(const std::string &name) const
Eigen::Quaternion< ScalarType > Quaternion
Definition: matrix.h:49
virtual boost::shared_ptr< const Filter > filter() const
virtual void getImuWithBiases(geometry_msgs::Vector3 &linear_acceleration, geometry_msgs::Vector3 &angular_velocity)
virtual void getTransforms(std::vector< tf::StampedTransform > &transforms)
virtual const ros::Time & getTimestamp() const
boost::shared_ptr< Gravity > gravity_update_
virtual void getHeader(std_msgs::Header &header)
virtual void getPosition(tf::Point &point)
virtual SystemStatus getMeasurementStatus() const
boost::shared_ptr< Derived > getType(const key_type &key) const
Definition: collection.h:86
const MeasurementPtr & addMeasurement(const MeasurementPtr &measurement, const std::string &name=std::string())
unsigned int SystemStatus
Definition: types.h:70
boost::shared_ptr< InputType > getInputType(const std::string &name) const
virtual boost::shared_ptr< Filter > filter()
virtual void getState(nav_msgs::Odometry &state, bool with_covariances=true)
boost::shared_ptr< InputType > addInput(const std::string &name=std::string())
boost::shared_ptr< Rate > rate_update_
virtual bool getWorldToNavTransform(geometry_msgs::TransformStamped &transform)
virtual void getGlobalPosition(double &latitude, double &longitude, double &altitude)
InputPtr addInput(Input *input, const std::string &name=std::string())
virtual bool inSystemStatus(SystemStatus test_status) const
virtual void setTimestamp(const ros::Time &timestamp)
virtual const ParameterList & parameters() const
virtual void getVelocity(tf::Vector3 &vector)
virtual const State::Covariance & getCovariance()
virtual const State::Vector & getStateVector()
virtual SystemStatus getSystemStatus() const
virtual bool setMeasurementStatus(SystemStatus new_status)
virtual bool updateSystemStatus(SystemStatus set, SystemStatus clear)
virtual void getBias(geometry_msgs::Vector3 &angular_velocity, geometry_msgs::Vector3 &linear_acceleration)
boost::shared_ptr< Input > InputPtr
Definition: types.h:94
boost::shared_ptr< State > StatePtr
Definition: types.h:102
virtual void getGlobal(double &latitude, double &longitude, double &altitude)
virtual void getOrientation(tf::Quaternion &quaternion)


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