gazebo_gps_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 Pavel Vechersky, ASL, ETH Zurich, Switzerland
3  * Copyright 2016 Geoffrey Hunter <gbmhunter@gmail.com>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef ROTORS_GAZEBO_PLUGINS_GPS_PLUGIN_H
19 #define ROTORS_GAZEBO_PLUGINS_GPS_PLUGIN_H
20 
21 // SYSTEM
22 #include <random>
23 
24 // 3RD PARTY
25 #include <gazebo/gazebo.hh>
26 #include <gazebo/physics/physics.hh>
27 #include <gazebo/sensors/sensors.hh>
28 
29 // USER
30 #include "NavSatFix.pb.h" // GPS message type generated by protobuf .proto file
31 #include "TwistStamped.pb.h" // GPS ground speed message
33 
34 namespace gazebo {
35 
36 // Default values
37 static constexpr double kDefaultHorPosStdDev = 3.0;
38 static constexpr double kDefaultVerPosStdDev = 6.0;
39 static constexpr double kDefaultHorVelStdDev = 0.1;
40 static constexpr double kDefaultVerVelStdDev = 0.1;
41 
42 class GazeboGpsPlugin : public SensorPlugin {
43  public:
44  typedef std::normal_distribution<> NormalDistribution;
45 
47  virtual ~GazeboGpsPlugin();
48 
49  protected:
50  void Load(sensors::SensorPtr _sensor, sdf::ElementPtr _sdf);
51 
53  void OnUpdate();
54 
55  private:
56 
57  std::string namespace_;
58 
62 
67  void CreatePubsAndSubs();
68 
69  gazebo::transport::NodePtr node_handle_;
70 
71  gazebo::transport::PublisherPtr gz_gps_pub_;
72 
73  gazebo::transport::PublisherPtr gz_ground_speed_pub_;
74 
76  std::string gps_topic_;
77 
79  std::string ground_speed_topic_;
80 
82  sensors::GpsSensorPtr parent_sensor_;
83 
85  physics::WorldPtr world_;
86 
88  physics::LinkPtr link_;
89 
91  event::ConnectionPtr updateConnection_;
92 
94  gz_sensor_msgs::NavSatFix gz_gps_message_;
95 
97  gz_geometry_msgs::TwistStamped gz_ground_speed_message_;
98 
100  NormalDistribution ground_speed_n_[3];
101 
103  std::random_device random_device_;
104 
105  std::mt19937 random_generator_;
106 };
107 
108 } // namespace gazebo
109 
110 #endif // ROTORS_GAZEBO_PLUGINS_GPS_PLUGIN_H
std::random_device random_device_
Random number generator.
gz_sensor_msgs::NavSatFix gz_gps_message_
GPS message to be published on sensor update.
gazebo::transport::PublisherPtr gz_ground_speed_pub_
sensors::GpsSensorPtr parent_sensor_
Pointer to the parent sensor.
NormalDistribution ground_speed_n_[3]
Normal distributions for ground speed noise in x, y, and z directions.
gazebo::transport::PublisherPtr gz_gps_pub_
event::ConnectionPtr updateConnection_
Pointer to the update event connection.
gz_geometry_msgs::TwistStamped gz_ground_speed_message_
Ground speed message to be published on sensor update.
std::string ground_speed_topic_
Name of topic for ground speed messages, read from SDF file.
std::string gps_topic_
Name of topic for GPS messages, read from SDF file.
std::normal_distribution NormalDistribution
physics::LinkPtr link_
Pointer to the sensor link.
static constexpr double kDefaultHorVelStdDev
static constexpr double kDefaultVerPosStdDev
static constexpr double kDefaultHorPosStdDev
void CreatePubsAndSubs()
Creates all required publishers and subscribers, incl. routing of messages to/from ROS if required...
physics::WorldPtr world_
Pointer to the world.
void Load(sensors::SensorPtr _sensor, sdf::ElementPtr _sdf)
bool pubs_and_subs_created_
Flag that is set to true once CreatePubsAndSubs() is called, used to prevent CreatePubsAndSubs() from...
gazebo::transport::NodePtr node_handle_
void OnUpdate()
Publishes both a NavSatFix and Gazebo message.
static constexpr double kDefaultVerVelStdDev


rotors_gazebo_plugins
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Mon Feb 28 2022 23:39:03