LiftDragModel.hh
Go to the documentation of this file.
1 // Copyright (c) 2016 The UUV Simulator Authors.
2 // All rights reserved.
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 
18 
19 #ifndef __UUV_GAZEBO_PLUGINS_LIFT_DRAG_MODEL_HH__
20 #define __UUV_GAZEBO_PLUGINS_LIFT_DRAG_MODEL_HH__
21 
22 #include <map>
23 #include <string>
24 
25 #include <gazebo/gazebo.hh>
26 
27 #include <sdf/sdf.hh>
28 
29 namespace gazebo
30 {
32 class LiftDrag
33 {
35  protected: LiftDrag() : prevTime(-10.), state(0.) {}
36 
38  public: static bool CheckForElement(sdf::ElementPtr _sdf,
39  const std::string& element);
40 
42  public: virtual ~LiftDrag() {}
43 
45  public: virtual std::string GetType() = 0;
46 
48  public: virtual ignition::math::Vector3d compute(
49  const ignition::math::Vector3d &_velL) = 0;
50 
52  public: virtual bool GetParam(std::string _tag,
53  double& _output) = 0;
54 
56  public: virtual std::map<std::string, double> GetListParams() = 0;
57 
59  protected: double prevTime;
60 
62  protected: double state;
63 };
64 
66 typedef LiftDrag* (*LiftDragCreator)(sdf::ElementPtr);
67 
70 {
72  public: LiftDrag* CreateLiftDrag(sdf::ElementPtr _sdf);
73 
75  public: static LiftDragFactory& GetInstance();
76 
78  public: bool RegisterCreator(const std::string& _identifier,
79  LiftDragCreator _creator);
80 
82  private: LiftDragFactory() {}
83 
85  private: std::map<std::string, LiftDragCreator> creators_;
86 };
87 
89 #define REGISTER_LIFTDRAG(type) static const bool registeredWithFactory
90 
92 #define REGISTER_LIFTDRAG_CREATOR(type, creator) \
93  const bool type::registeredWithFactory = \
94  LiftDragFactory::GetInstance().RegisterCreator( \
95  type::IDENTIFIER, creator);
96 
97 
101 {
103  public: static LiftDrag* create(sdf::ElementPtr _sdf);
104 
106  public: virtual std::string GetType() { return IDENTIFIER; }
107 
109  public: virtual ignition::math::Vector3d compute(const ignition::math::Vector3d &velL);
110 
113 
115  public: virtual bool GetParam(std::string _tag, double& _output);
116 
118  public: virtual std::map<std::string, double> GetListParams();
119 
121  private: static const std::string IDENTIFIER;
122 
124  protected: double liftConstant;
125 
127  protected: double dragConstant;
128 
130  private: LiftDragQuadratic(double _liftConstant, double _dragConstant)
131  : LiftDrag(), liftConstant(_liftConstant), dragConstant(_dragConstant) {}
132 };
133 
139 {
141  public: static LiftDrag* create(sdf::ElementPtr _sdf);
142 
144  public: virtual std::string GetType() { return IDENTIFIER; }
145 
147  public: virtual ignition::math::Vector3d compute(const ignition::math::Vector3d &_velL);
148 
151 
153  private: static const std::string IDENTIFIER;
154 
156  public: virtual bool GetParam(std::string _tag, double& _output);
157 
159  public: virtual std::map<std::string, double> GetListParams();
160 
162  protected: double area;
163 
165  protected: double fluidDensity;
166 
168  protected: double a0;
169 
171  protected: double alphaStall;
172 
174  protected: double cla;
175 
177  protected: double claStall;
178 
180  protected: double cda;
181 
183  protected: double cdaStall;
184 
186  private: LiftDragTwoLines(double _area, double _fluidDensity, double _a0,
187  double _alphaStall, double _cla, double _claStall,
188  double _cda, double _cdaStall)
189  : LiftDrag(), area(_area), fluidDensity(_fluidDensity),
190  a0(_a0), alphaStall(_alphaStall),
191  cla(_cla), claStall(_claStall),
192  cda(_cda), cdaStall(_cdaStall) {}
193 };
194 }
195 
196 #endif
double cdaStall
Drag coefficient with stall.
virtual ~LiftDrag()
Destructor.
double prevTime
Time of last state update.
double fluidDensity
Fluid density.
double liftConstant
Lift constant.
double a0
Original zero angle of attack location.
virtual std::string GetType()
Return (derived) type of dynamic system.
LiftDragTwoLines(double _area, double _fluidDensity, double _a0, double _alphaStall, double _cla, double _claStall, double _cda, double _cdaStall)
Constructor.
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
Lift&drag model that models lift/drag coeffs using two lines. This is based on Gazebo&#39;s LiftDragPlugin bu...
Abstract base class for Lift&Drag models.
double area
Airfoil area.
double alphaStall
Stall angle.
virtual std::map< std::string, double > GetListParams()=0
Return list of all parameters.
virtual bool GetParam(std::string _tag, double &_output)=0
Return paramater in vector form for the given tag.
virtual std::string GetType()
Return (derived) type of dynamic system.
virtual std::string GetType()=0
Return (derived) type of lift&drag model.
LiftDragQuadratic(double _liftConstant, double _dragConstant)
Constructor.
double cda
Drag coefficient without stall.
LiftDrag *(* LiftDragCreator)(sdf::ElementPtr)
Function pointer to create a certain LiftDrag object.
LiftDrag()
Protected constructor: Use the factory for object creation.
double dragConstant
Drag constant.
std::map< std::string, LiftDragCreator > creators_
Map of each registered identifier to its corresponding creator.
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
double state
Latest state.
Basic quadratic (Hugin) lift&drag model, page 18 from [1]. [1] Engelhardtsen, Øystein. "3D AUV Collision Avoidance." (2007).
Factory singleton class that creates a LiftDrag from sdf.
#define REGISTER_LIFTDRAG(type)
Use the following macro within a LiftDrag declaration:
double claStall
Lift coefficient with stall.
static bool CheckForElement(sdf::ElementPtr _sdf, const std::string &element)
Check for element. Complain and return 0 if it is missing.
double cla
Lift coefficient without stall.
virtual ignition::math::Vector3d compute(const ignition::math::Vector3d &_velL)=0
Compute the lift and drag force.
LiftDragFactory()
Constructor is private since this is a singleton.


uuv_gazebo_plugins
Author(s): Musa Morena Marcusso Manhaes , Sebastian Scherer , Luiz Ricardo Douat
autogenerated on Thu Jun 18 2020 03:28:24