gazebo_pressure_plugin.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 Pavel Vechersky, ASL, ETH Zurich, Switzerland
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef ROTORS_GAZEBO_PLUGINS_PRESSURE_PLUGIN_H
00018 #define ROTORS_GAZEBO_PLUGINS_PRESSURE_PLUGIN_H
00019 
00020 #include <random>
00021 
00022 #include <glog/logging.h>
00023 
00024 #include <gazebo/common/Plugin.hh>
00025 #include <gazebo/common/common.hh>
00026 #include <gazebo/gazebo.hh>
00027 #include <gazebo/physics/physics.hh>
00028 
00029 #include "FluidPressure.pb.h"
00030 
00031 #include "rotors_gazebo_plugins/common.h"
00032 
00033 namespace gazebo {
00034 // Constants
00035 static constexpr double kGasConstantNmPerKmolKelvin = 8314.32;
00036 static constexpr double kMeanMolecularAirWeightKgPerKmol = 28.9644;
00037 static constexpr double kGravityMagnitude = 9.80665;
00038 static constexpr double kEarthRadiusMeters = 6356766.0;
00039 static constexpr double kPressureOneAtmospherePascals = 101325.0;
00040 static constexpr double kSeaLevelTempKelvin = 288.15;
00041 static constexpr double kTempLapseKelvinPerMeter = 0.0065;
00042 static constexpr double kAirConstantDimensionless = kGravityMagnitude *
00043     kMeanMolecularAirWeightKgPerKmol /
00044         (kGasConstantNmPerKmolKelvin * -kTempLapseKelvinPerMeter);
00045 
00046 // Default values
00047 static const std::string kDefaultPressurePubTopic = "air_pressure";
00048 static constexpr double kDefaultRefAlt = 500.0; /* m, Zurich: h=+500m, WGS84) */
00049 static constexpr double kDefaultPressureVar = 0.0; /* Pa^2, pressure variance */
00050 
00051 class GazeboPressurePlugin : public ModelPlugin {
00052  public:
00054   GazeboPressurePlugin();
00055 
00057   virtual ~GazeboPressurePlugin();
00058 
00059   typedef std::normal_distribution<> NormalDistribution;
00060 
00061  protected:
00064   void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
00065 
00067   void OnUpdate(const common::UpdateInfo&);
00068 
00069  private:
00072   bool pubs_and_subs_created_;
00073 
00078   void CreatePubsAndSubs();
00079 
00081   gazebo::transport::NodePtr node_handle_;
00082 
00084   gazebo::transport::PublisherPtr pressure_pub_;
00085 
00087   std::string namespace_;
00088 
00090   std::string pressure_topic_;
00091 
00093   std::string frame_id_;
00094 
00096   physics::WorldPtr world_;
00097 
00099   physics::ModelPtr model_;
00100 
00102   physics::LinkPtr link_;
00103 
00105   event::ConnectionPtr updateConnection_;
00106 
00108   double ref_alt_;
00109 
00111   double pressure_var_;
00112 
00114   NormalDistribution pressure_n_[1];
00115 
00118   //            and then published onto a topic
00119   gz_sensor_msgs::FluidPressure pressure_message_;
00120 
00121   std::mt19937 random_generator_;
00122 };
00123 }
00124 
00125 #endif // ROTORS_GAZEBO_PLUGINS_PRESSURE_PLUGIN_H


rotors_gazebo_plugins
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Thu Apr 18 2019 02:43:43