Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef GPS_CONVERSION_H_
00009 #define GPS_CONVERSION_H_
00010
00011 #include <ros/ros.h>
00012
00013 #include <message_filters/subscriber.h>
00014 #include <message_filters/synchronizer.h>
00015 #include <message_filters/sync_policies/approximate_time.h>
00016
00017 #include <sensor_msgs/NavSatFix.h>
00018 #include <geometry_msgs/PointStamped.h>
00019 #include <geometry_msgs/PoseWithCovarianceStamped.h>
00020 #include <nav_msgs/Odometry.h>
00021 #include <asctec_hl_comm/PositionWithCovarianceStamped.h>
00022 #include <asctec_hl_comm/mav_imu.h>
00023 #include <asctec_hl_comm/GpsCustom.h>
00024 #include <asctec_hl_comm/GpsCustomCartesian.h>
00025 #include <asctec_hl_comm/Wgs84ToEnu.h>
00026 #include <std_srvs/Empty.h>
00027 #include <Eigen/Eigen>
00028
00029 #include "geodesy_ned.hpp"
00030
00031 #include <memory>
00032
00033 namespace asctec_hl_gps{
00034
00035 class GpsConversion
00036 {
00037 public:
00038 GpsConversion();
00039
00040 private:
00041 typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::NavSatFix, asctec_hl_comm::mav_imu> GpsImuSyncPolicy;
00042
00043 static const double DEG2RAD;
00044 const Eigen::Quaterniond Q_90_DEG;
00045
00046 ros::NodeHandle nh_;
00047 ros::Publisher gps_pose_pub_;
00048 ros::Publisher gps_position_pub_;
00049 ros::Publisher gps_position_nocov_pub_;
00050 ros::Publisher gps_custom_pub_;
00051 ros::Publisher gps_filtered_pub_;
00052
00053 ros::ServiceServer zero_height_srv_;
00054 ros::ServiceServer gps_to_enu_srv_;
00055
00056 message_filters::Subscriber<sensor_msgs::NavSatFix> gps_sub_sync_;
00057 message_filters::Subscriber<asctec_hl_comm::mav_imu> imu_sub_sync_;
00058 message_filters::Synchronizer<GpsImuSyncPolicy> gps_imu_sync_;
00059
00060 ros::Subscriber gps_sub_;
00061 ros::Subscriber gps_custom_sub_;
00062 ros::Subscriber imu_sub_;
00063 ros::Subscriber filtered_odometry_sub_;
00064
00065 geometry_msgs::Point gps_position_;
00066
00067 bool have_reference_;
00068 double ref_latitude_;
00069 double ref_longitude_;
00070 double ref_altitude_;
00071 Eigen::Vector3d ecef_ref_point_;
00072 Eigen::Quaterniond ecef_ref_orientation_;
00073
00074 double height_offset_;
00075 bool set_height_zero_;
00076
00077 bool use_pressure_height_;
00078
00079 std::unique_ptr<geodesy_ned::Ned> ned_;
00080
00081 void syncCallback(const sensor_msgs::NavSatFixConstPtr & gps, const asctec_hl_comm::mav_imuConstPtr & imu);
00082 void gpsCallback(const sensor_msgs::NavSatFixConstPtr & gps);
00083 void gpsCustomCallback(const asctec_hl_comm::GpsCustomConstPtr & gps);
00084 void imuCallback(const asctec_hl_comm::mav_imuConstPtr & imu);
00085 void filteredOdometryCallback(const nav_msgs::Odometry & filtered_odometry);
00086
00087 void initReference(const double & latitude, const double & longitude, const double & altitude);
00088
00089 Eigen::Vector3d wgs84ToEcef(const double & latitude, const double & longitude, const double & altitude);
00090 Eigen::Vector3d ecefToEnu(const Eigen::Vector3d & ecef);
00091
00092 geometry_msgs::Point wgs84ToEnu(const double & latitude, const double & longitude, const double & altitude);
00093 geometry_msgs::Point wgs84ToNwu(const double & latitude, const double & longitude, const double & altitude);
00094
00095 bool zeroHeightCb(std_srvs::EmptyRequest & req, std_srvs::EmptyResponse & resp);
00096 bool wgs84ToEnuSrv(asctec_hl_comm::Wgs84ToEnuRequest & wgs84Pt,
00097 asctec_hl_comm::Wgs84ToEnuResponse & enuPt);
00098 };
00099
00100 }
00101
00102 #endif