Atmosphere.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GAZEBO_PHYSICS_ATMOSPHERE_HH_
18 #define GAZEBO_PHYSICS_ATMOSPHERE_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include "gazebo/msgs/msgs.hh"
24 
25 #include "gazebo/util/system.hh"
26 
27 namespace gazebo
28 {
29  namespace physics
30  {
31  class World;
32 
35 
37  class AtmospherePrivate;
38 
42  class GZ_PHYSICS_VISIBLE Atmosphere
43  {
46  public: explicit Atmosphere(physics::World &_world);
47 
49  public: virtual ~Atmosphere();
50 
53  public: virtual void Load(sdf::ElementPtr _sdf);
54 
56  public: virtual void Reset();
57 
60  public: virtual std::string Type() const = 0;
61 
64  public: sdf::ElementPtr SDF() const;
65 
68  protected: virtual void OnRequest(ConstRequestPtr &_msg);
69 
72  protected: virtual void OnAtmosphereMsg(ConstAtmospherePtr &_msg);
73 
76  public: virtual void SetTemperature(const double _t);
77 
80  public: virtual void SetPressure(const double _pressure);
81 
86  public: virtual double Temperature(const double _altitude = 0.0) const;
87 
91  public: virtual double Pressure(const double _altitude = 0.0) const;
92 
96  public: virtual double MassDensity(const double _altitude = 0.0) const;
97 
102  public: virtual void SetTemperatureGradient(const double _gradient) = 0;
103 
107  public: double TemperatureGradient() const;
108 
112  protected: void UpdateMassDensity();
113 
116  protected: physics::World &World() const;
117 
120  protected: void Publish(const msgs::Response &_msg) const;
121 
123  public: static const double MOLAR_MASS;
124 
126  public: static const double IDEAL_GAS_CONSTANT_R;
127 
130  private: std::unique_ptr<AtmospherePrivate> dataPtr;
131  };
133  }
134 }
135 #endif
virtual ~Atmosphere()
Destructor.
Forward declarations for the common classes.
Definition: Animation.hh:27
virtual void OnAtmosphereMsg(ConstAtmospherePtr &_msg)
Virtual callback for gztopic "~/atmosphere".
static const double IDEAL_GAS_CONSTANT_R
Universal ideal gas constant in J/(mol.K)
Definition: Atmosphere.hh:126
virtual void SetTemperature(const double _t)
Set the sea level temperature.
virtual void Reset()
Reset the atmosphere model.
void UpdateMassDensity()
Update the mass density of the air at sea level using the ideal gas law.
static const double MOLAR_MASS
Molar mass of the air in kg/mol.
Definition: Atmosphere.hh:123
physics::World & World() const
Return the world.
Atmosphere(physics::World &_world)
Default constructor.
virtual std::string Type() const =0
Return the atmosphere model type (such as "adiabatic").
This models a base atmosphere class to serve as a common interface to any derived atmosphere models.
Definition: Atmosphere.hh:43
The world provides access to all other object within a simulated environment.
Definition: World.hh:76
virtual double Temperature(const double _altitude=0.0) const
Get the actual modeled temperature in kelvins at a given altitude.
virtual void Load(sdf::ElementPtr _sdf)
Load the atmosphere model.
sdf::ElementPtr SDF() const
Get a pointer to the SDF element for this atmosphere model.
virtual double MassDensity(const double _altitude=0.0) const
Get the density in kg/m^3 at a given altitude.
void Publish(const msgs::Response &_msg) const
Publish response to a request.
double TemperatureGradient() const
Get the sea level temperature gradient with respect to increasing altitude.
virtual void SetPressure(const double _pressure)
Set the sea level pressure.
virtual void OnRequest(ConstRequestPtr &_msg)
Virtual callback for gztopic "~/request".
virtual void SetTemperatureGradient(const double _gradient)=0
Set the temperature gradient dT/dZ with respect to increasing altitude around sea level.
virtual double Pressure(const double _altitude=0.0) const
Get the pressure at a specified altitude in pascals.