Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
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
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
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);
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);
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
00150
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 }
00233
00234 #endif // HECTOR_POSE_ESTIMATION_H