global_reference.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_GLOBAL_REFERENCE_H
00030 #define HECTOR_POSE_ESTIMATION_GLOBAL_REFERENCE_H
00031 
00032 #include <hector_pose_estimation/types.h>
00033 #include <hector_pose_estimation/parameters.h>
00034 
00035 #include <geographic_msgs/GeoPose.h>
00036 #include <geometry_msgs/TransformStamped.h>
00037 
00038 #include <limits>
00039 #include <boost/function.hpp>
00040 
00041 namespace hector_pose_estimation {
00042 
00043   class PoseEstimation;
00044 
00045   class GlobalReference {
00046   public:
00047     struct Position {
00048       Position() : latitude(std::numeric_limits<double>::quiet_NaN()), longitude(std::numeric_limits<double>::quiet_NaN()), altitude(std::numeric_limits<double>::quiet_NaN()) {}
00049       double latitude;
00050       double longitude;
00051       double altitude;
00052     };
00053 
00054     struct Heading {
00055       Heading() : value(std::numeric_limits<double>::quiet_NaN()), cos(1.0), sin(0.0) {}
00056       Heading(double heading);
00057       double value;
00058       double cos;
00059       double sin;
00060       operator double() const { return value; }
00061       Quaternion quaternion() const;
00062     };
00063 
00064     struct Radius {
00065       Radius() : north(std::numeric_limits<double>::quiet_NaN()), east(std::numeric_limits<double>::quiet_NaN()) {}
00066       Radius(double latitude);
00067       double north;
00068       double east;
00069     };
00070 
00071     const Position& position() const { return position_; }
00072     const Heading& heading() const { return heading_; }
00073     const Radius& radius() const { return radius_; }
00074 
00075     void getGeoPose(geographic_msgs::GeoPose& geopose) const;
00076     bool getWorldToNavTransform(geometry_msgs::TransformStamped& transform, const std::string &world_frame, const std::string &nav_frame, const ros::Time& stamp = ros::Time()) const;
00077 
00078     GlobalReference& setPosition(double latitude, double longitude, bool intermediate = false);
00079     GlobalReference& setHeading(double heading, bool intermediate = false);
00080     GlobalReference& setAltitude(double altitude, bool intermediate = false);
00081 
00082     GlobalReference& setCurrentPosition(const State& state, double latitude, double longitude);
00083     GlobalReference& setCurrentHeading(const State& state, double heading);
00084     GlobalReference& setCurrentAltitude(const State& state, double altitude);
00085 
00086     bool hasPosition() const { return !std::isnan(position_.latitude) && !std::isnan(position_.longitude); }
00087     bool hasHeading() const  { return !std::isnan(heading_.value); }
00088     bool hasAltitude() const { return !std::isnan(position_.altitude); }
00089 
00090     void fromWGS84(double latitude, double longitude, double &x, double &y);
00091     void toWGS84(double x, double y, double &latitude, double &longitude);
00092     void fromNorthEast(double north, double east, double &x, double &y);
00093     void toNorthEast(double x, double y, double &north, double &east);
00094     void fromAltitude(double altitude, double &z);
00095     void toAltitude(double z, double &altitude);
00096 
00097     ParameterList& parameters();
00098 
00099     static const GlobalReferencePtr &Instance();
00100 
00101     void reset();
00102     void updated(bool intermediate = false);
00103 
00104     typedef boost::function<void()> UpdateCallback;
00105     void addUpdateCallback(const UpdateCallback &);
00106 
00107   private:
00108     GlobalReference();
00109 
00110     Position position_;
00111     Heading heading_;
00112     Radius radius_;
00113 
00114     ParameterList parameters_;
00115     double reference_latitude_;
00116     double reference_longitude_;
00117     double reference_altitude_;
00118     double reference_heading_;
00119 
00120     std::list<UpdateCallback> update_callbacks_;
00121   };
00122 
00123 } // namespace hector_pose_estimation
00124 
00125 #endif // HECTOR_POSE_ESTIMATION_GLOBAL_REFERENCE_H


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