Flatland
gps.h
1 #include <flatland_plugins/update_timer.h>
2 #include <flatland_server/model_plugin.h>
3 #include <flatland_server/timekeeper.h>
4 #include <flatland_server/types.h>
5 #include <ros/ros.h>
6 #include <sensor_msgs/NavSatFix.h>
7 #include <tf/transform_broadcaster.h>
8 #include <Eigen/Dense>
9 
10 #ifndef FLATLAND_PLUGINS_GPS_H
11 #define FLATLAND_PLUGINS_GPS_H
12 
13 using namespace flatland_server;
14 
15 namespace flatland_plugins {
16 
20 class Gps : public ModelPlugin {
21  public:
22  std::string topic_;
23  std::string frame_id_;
26  double ref_lat_rad_;
27  double ref_lon_rad_;
29  double ref_ecef_x_;
31  double ref_ecef_y_;
33  double ref_ecef_z_;
35  double update_rate_;
38 
39  static double WGS84_A;
40  static double WGS84_E2;
41 
42  ros::Publisher fix_publisher_;
43  tf::TransformBroadcaster tf_broadcaster_;
44  geometry_msgs::TransformStamped gps_tf_;
45  sensor_msgs::NavSatFix gps_fix_;
47 
48  Eigen::Matrix3f m_body_to_gps_;
49 
54  void OnInitialize(const YAML::Node &config) override;
55 
60  void BeforePhysicsStep(const Timekeeper &timekeeper) override;
61 
66  void ParseParameters(const YAML::Node &config);
67 
72  void ComputeReferenceEcef();
73 
78  void UpdateFix();
79 };
80 }
81 
82 #endif // FLATLAND_PLUGINS_GPS_H
std::string frame_id_
GPS frame ID.
Definition: gps.h:23
std::string topic_
topic name to publish the GPS fix
Definition: gps.h:22
double ref_lat_rad_
Definition: gps.h:26
Definition: dummy_model_plugin.h:59
Definition: gps.h:20
Pose origin_
GPS sensor frame w.r.t the body.
Definition: gps.h:25
UpdateTimer update_timer_
for controlling update rate
Definition: gps.h:46
tf::TransformBroadcaster tf_broadcaster_
broadcast GPS frame
Definition: gps.h:43
Definition: body.h:55
Body * body_
body the simulated GPS antenna attaches to
Definition: gps.h:24
Eigen::Matrix3f m_body_to_gps_
tf from body to GPS
Definition: gps.h:48
Definition: types.h:84
static double WGS84_E2
Square of Earth&#39;s first eccentricity.
Definition: gps.h:40
sensor_msgs::NavSatFix gps_fix_
message for publishing output
Definition: gps.h:45
geometry_msgs::TransformStamped gps_tf_
tf from body to GPS frame
Definition: gps.h:44
static double WGS84_A
Earth&#39;s major axis length.
Definition: gps.h:39
ros::Publisher fix_publisher_
GPS fix topic publisher.
Definition: gps.h:42
Definition: timekeeper.h:55
Definition: model_plugin.h:64
Definition: body.h:61
Definition: update_timer.h:55
bool broadcast_tf_
whether to broadcast laser origin w.r.t body
Definition: gps.h:37