pose_estimation.h
Go to the documentation of this file.
00001 //=================================================================================================
00002 // Copyright (c) 2011, Johannes Meyer and Martin Nowara, TU Darmstadt
00003 // All rights reserved.
00004 
00005 // Redistribution and use in source and binary forms, with or without
00006 // modification, are permitted provided that the following conditions are met:
00007 //     * Redistributions of source code must retain the above copyright
00008 //       notice, this list of conditions and the following disclaimer.
00009 //     * Redistributions in binary form must reproduce the above copyright
00010 //       notice, this list of conditions and the following disclaimer in the
00011 //       documentation and/or other materials provided with the distribution.
00012 //     * Neither the name of the Flight Systems and Automatic Control group,
00013 //       TU Darmstadt, nor the names of its contributors may be used to
00014 //       endorse or promote products derived from this software without
00015 //       specific prior written permission.
00016 
00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00018 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //=================================================================================================
00028 
00029 #ifndef HECTOR_POSE_ESTIMATION_H
00030 #define HECTOR_POSE_ESTIMATION_H
00031 
00032 #include <hector_pose_estimation/types.h>
00033 #include <hector_pose_estimation/state.h>
00034 #include <hector_pose_estimation/system.h>
00035 #include <hector_pose_estimation/measurement.h>
00036 #include <hector_pose_estimation/parameters.h>
00037 
00038 #include <boost/shared_ptr.hpp>
00039 #include <vector>
00040 
00041 #include <hector_pose_estimation/measurements/rate.h>
00042 #include <hector_pose_estimation/measurements/gravity.h>
00043 #include <hector_pose_estimation/measurements/zerorate.h>
00044 
00045 #include <tf/transform_datatypes.h>
00046 #include <geometry_msgs/PoseStamped.h>
00047 #include <geometry_msgs/PointStamped.h>
00048 #include <geometry_msgs/QuaternionStamped.h>
00049 #include <geometry_msgs/Vector3Stamped.h>
00050 #include <nav_msgs/Odometry.h>
00051 #include <sensor_msgs/NavSatFix.h>
00052 #include <geographic_msgs/GeoPoint.h>
00053 #include <geographic_msgs/GeoPose.h>
00054 
00055 namespace hector_pose_estimation {
00056 
00057 class Filter;
00058 class GlobalReference;
00059 
00060 class PoseEstimation
00061 {
00062 public:
00063   PoseEstimation(const SystemPtr& system = SystemPtr(), const StatePtr& state = StatePtr());
00064   template <typename ConcreteSystemModel> PoseEstimation(ConcreteSystemModel *system_model, State *state = 0);
00065   virtual ~PoseEstimation();
00066 
00067   static PoseEstimation *Instance();
00068 
00069   bool init();
00070   void cleanup();
00071   void reset();
00072 
00073   void update(ros::Time timestamp);
00074   void update(double dt);
00075 
00076   const SystemPtr& addSystem(const SystemPtr& system, const std::string& name = "system");
00077   const SystemPtr& addSystem(System *system) { return addSystem(SystemPtr(system)); }
00078   template <typename ConcreteSystemModel> const SystemPtr& addSystem(ConcreteSystemModel *model, const std::string& name = "system");
00079 //  SystemPtr getSystem(std::size_t index = 0) const { return systems_.get(index); }
00080   SystemPtr getSystem(const std::string& name) const { return systems_.get(name); }
00081   template <typename SystemType> boost::shared_ptr<SystemType> getSystem_(const std::string& name) const;
00082 
00083   const MeasurementPtr& addMeasurement(const MeasurementPtr& measurement, const std::string& name = std::string());
00084   const MeasurementPtr& addMeasurement(Measurement *measurement) { return addMeasurement(MeasurementPtr(measurement)); }
00085   template <class ConcreteMeasurementModel> const MeasurementPtr& addMeasurement(ConcreteMeasurementModel *model, const std::string& name);
00086 //  MeasurementPtr getMeasurement(std::size_t index) const { return measurements_.get(index); }
00087   MeasurementPtr getMeasurement(const std::string &name) const { return measurements_.get(name); }
00088   template <typename MeasurementType> boost::shared_ptr<MeasurementType> getMeasurement_(const std::string& name) const;
00089 
00090   template <class InputType> boost::shared_ptr<InputType> getInputType(const std::string& name) const { return inputs_.getType<InputType>(name); }
00091 
00092   template <class InputType> boost::shared_ptr<InputType> addInput(const std::string& name = std::string());
00093   InputPtr addInput(const InputPtr& input, const std::string& name = std::string());
00094   InputPtr addInput(Input *input, const std::string& name = std::string()) { return addInput(InputPtr(input), name); }
00095   InputPtr setInput(const Input& input, std::string name = std::string());
00096 //  InputPtr getInput(std::size_t index) const { return inputs_.get(index); }
00097   InputPtr getInput(const std::string& name) const { return inputs_.get(name); }
00098 
00099   virtual const State& state() const { return *state_; }
00100   virtual State& state() { return *state_; }
00101 
00102   virtual const State::Vector& getStateVector();
00103   virtual const State::Covariance& getCovariance();
00104 
00105   virtual SystemStatus getSystemStatus() const;
00106   virtual SystemStatus getMeasurementStatus() const;
00107   virtual bool inSystemStatus(SystemStatus test_status) const;
00108   virtual bool setSystemStatus(SystemStatus new_status);
00109   virtual bool setMeasurementStatus(SystemStatus new_status);
00110   virtual bool updateSystemStatus(SystemStatus set, SystemStatus clear);
00111   virtual bool updateMeasurementStatus(SystemStatus set, SystemStatus clear);
00112 
00113   virtual const GlobalReferencePtr &globalReference();
00114 
00115   virtual const ros::Time& getTimestamp() const;
00116   virtual void setTimestamp(const ros::Time& timestamp);
00117 
00118   virtual void getHeader(std_msgs::Header& header);
00119   virtual void getState(nav_msgs::Odometry& state, bool with_covariances = true);
00120   virtual void getPose(tf::Pose& pose);
00121   virtual void getPose(tf::Stamped<tf::Pose>& pose);
00122   virtual void getPose(geometry_msgs::Pose& pose);
00123   virtual void getPose(geometry_msgs::PoseStamped& pose);
00124   virtual void getPosition(tf::Point& point);
00125   virtual void getPosition(tf::Stamped<tf::Point>& point);
00126   virtual void getPosition(geometry_msgs::Point& pose);
00127   virtual void getPosition(geometry_msgs::PointStamped& pose);
00128   virtual void getGlobal(double& latitude, double& longitude, double& altitude);
00129   virtual void getGlobalPosition(double& latitude, double& longitude, double& altitude); // deprecated
00130   virtual void getGlobal(geographic_msgs::GeoPoint& global);
00131   virtual void getGlobal(sensor_msgs::NavSatFix& global);
00132   virtual void getGlobalPosition(sensor_msgs::NavSatFix& global);
00133   virtual void getGlobal(geographic_msgs::GeoPoint& position, geometry_msgs::Quaternion& quaternion); // deprecated
00134   virtual void getGlobal(geographic_msgs::GeoPose& global);
00135   virtual void getOrientation(tf::Quaternion& quaternion);
00136   virtual void getOrientation(tf::Stamped<tf::Quaternion>& quaternion);
00137   virtual void getOrientation(geometry_msgs::Quaternion& pose);
00138   virtual void getOrientation(geometry_msgs::QuaternionStamped& pose);
00139   virtual void getOrientation(double &yaw, double &pitch, double &roll);
00140   virtual void getImuWithBiases(geometry_msgs::Vector3& linear_acceleration, geometry_msgs::Vector3& angular_velocity);
00141   virtual void getVelocity(tf::Vector3& vector);
00142   virtual void getVelocity(tf::Stamped<tf::Vector3>& vector);
00143   virtual void getVelocity(geometry_msgs::Vector3& vector);
00144   virtual void getVelocity(geometry_msgs::Vector3Stamped& vector);
00145   virtual void getRate(tf::Vector3& vector);
00146   virtual void getRate(tf::Stamped<tf::Vector3>& vector);
00147   virtual void getRate(geometry_msgs::Vector3& vector);
00148   virtual void getRate(geometry_msgs::Vector3Stamped& vector);
00149   // virtual void getBias(tf::Vector3& angular_velocity, tf::Vector3& linear_acceleration);
00150   // virtual void getBias(tf::Stamped<tf::Vector3>& angular_velocity, tf::Stamped<tf::Vector3>& linear_acceleration);
00151   virtual void getBias(geometry_msgs::Vector3& angular_velocity, geometry_msgs::Vector3& linear_acceleration);
00152   virtual void getBias(geometry_msgs::Vector3Stamped& angular_velocity, geometry_msgs::Vector3Stamped& linear_acceleration);
00153   virtual void getTransforms(std::vector<tf::StampedTransform>& transforms);
00154   virtual void updateWorldToOtherTransform(tf::StampedTransform& world_to_other_transform);
00155   virtual bool getWorldToNavTransform(geometry_msgs::TransformStamped& transform);
00156 
00157   virtual ParameterList& parameters() { return parameters_; }
00158   virtual const ParameterList& parameters() const { return parameters_; }
00159 
00160   virtual boost::shared_ptr<Filter> filter() { return filter_; }
00161   virtual boost::shared_ptr<const Filter> filter() const { return filter_; }
00162 
00163   virtual void updated();
00164 
00165 protected:
00166   Systems systems_;
00167   Measurements measurements_;
00168   Inputs inputs_;
00169 
00170 private:
00171   StatePtr state_;
00172   FilterPtr filter_;
00173 
00174   ParameterList parameters_;
00175 
00176   ros::Time timestamp_;
00177   std::string world_frame_;
00178   std::string nav_frame_;
00179   std::string base_frame_;
00180   std::string stabilized_frame_;
00181   std::string footprint_frame_;
00182   std::string position_frame_;
00183 
00184   ros::Time alignment_start_;
00185   double alignment_time_;
00186 
00187   double gravity_;
00188 
00189   boost::shared_ptr<Rate> rate_update_;
00190   boost::shared_ptr<Gravity> gravity_update_;
00191   boost::shared_ptr<ZeroRate> zerorate_update_;
00192 };
00193 
00194 template <typename ConcreteSystemModel>
00195 PoseEstimation::PoseEstimation(ConcreteSystemModel *system_model, State *state) {
00196   *this = PoseEstimation(System::create(system_model), StatePtr(state));
00197 }
00198 
00199 template <typename ConcreteSystemModel>
00200 const SystemPtr& PoseEstimation::addSystem(ConcreteSystemModel *model, const std::string& name)
00201 {
00202   return addSystem(System::create(model, name));
00203 }
00204 
00205 template <typename SystemType>
00206 boost::shared_ptr<SystemType> PoseEstimation::getSystem_(const std::string& name) const
00207 {
00208   return boost::static_pointer_cast<SystemType>(getSystem(name));
00209 }
00210 
00211 template <class ConcreteMeasurementModel>
00212 const MeasurementPtr& PoseEstimation::addMeasurement(ConcreteMeasurementModel *model, const std::string& name) {
00213   return addMeasurement(Measurement::create(model, name));
00214 }
00215 
00216 template <typename MeasurementType>
00217 boost::shared_ptr<MeasurementType> PoseEstimation::getMeasurement_(const std::string& name) const
00218 {
00219   return boost::static_pointer_cast<MeasurementType>(getMeasurement(name));
00220 }
00221 
00222 template <class InputType>
00223 boost::shared_ptr<InputType> PoseEstimation::addInput(const std::string& name) {
00224   boost::shared_ptr<InputType> input = getInputType<InputType>(name);
00225   if (input) return input;
00226 
00227   input.reset(new InputType());
00228   if (!addInput(boost::static_pointer_cast<Input>(input), name)) input.reset();
00229   return input;
00230 }
00231 
00232 } // namespace hector_pose_estimation
00233 
00234 #endif // HECTOR_POSE_ESTIMATION_H


hector_pose_estimation_core
Author(s): Johannes Meyer
autogenerated on Fri Aug 28 2015 10:59:54