HydrodynamicModel.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 
19 
20 #ifndef __UUV_GAZEBO_HYDRO_MODEL_HH__
21 #define __UUV_GAZEBO_HYDRO_MODEL_HH__
22 
23 #include <gazebo/gazebo.hh>
24 #include <gazebo/physics/Link.hh>
25 #include <gazebo/physics/Model.hh>
26 #include <gazebo/physics/Collision.hh>
27 #include <gazebo/physics/Shape.hh>
28 
29 #include <eigen3/Eigen/Core>
30 #include <eigen3/Eigen/Geometry>
31 
32 #include <string>
33 #include <vector>
34 #include <map>
35 
38 
39 
40 namespace gazebo
41 {
43 {
45  protected: HydrodynamicModel(sdf::ElementPtr _sdf, physics::LinkPtr _link);
46 
48  public: virtual std::string GetType() = 0;
49 
51  public: virtual void ApplyHydrodynamicForces(
52  double time, const ignition::math::Vector3d &_flowVelWorld) = 0;
53 
55  public: virtual void Print(std::string _paramName,
56  std::string _message = std::string()) = 0;
57 
59  public: virtual bool GetParam(std::string _tag,
60  std::vector<double>& _output) = 0;
61 
63  public: virtual bool GetParam(std::string _tag,
64  double& _output) = 0;
65 
67  public: virtual bool SetParam(std::string _tag, double _input) = 0;
68 
70  protected: void ComputeAcc(Eigen::Vector6d _velRel,
71  double _time,
72  double _alpha = 0.3);
73 
75  protected: bool CheckParams(sdf::ElementPtr _sdf);
76 
78  protected: ignition::math::Vector3d ToNED(ignition::math::Vector3d _vec);
79 
81  protected: ignition::math::Vector3d FromNED(ignition::math::Vector3d _vec);
82 
88 
91  protected: double lastTime;
92 
95 
97  protected: std::vector<std::string> params;
98 
100  protected: double Re;
101 
103  protected: double temperature;
104 };
105 
107 typedef boost::shared_ptr<HydrodynamicModel> HydrodynamicModelPtr;
108 
110 typedef HydrodynamicModel* (*HydrodynamicModelCreator)(sdf::ElementPtr, \
111  physics::LinkPtr);
112 
115 {
117  public: HydrodynamicModel* CreateHydrodynamicModel(sdf::ElementPtr _sdf,
118  physics::LinkPtr _link);
119 
121  public: static HydrodynamicModelFactory& GetInstance();
122 
124  public: bool RegisterCreator(const std::string& _identifier,
125  HydrodynamicModelCreator _creator);
126 
129 
131  private: std::map<std::string, HydrodynamicModelCreator> creators_;
132 };
133 
135 #define REGISTER_HYDRODYNAMICMODEL(type) static const bool registeredWithFactory
136 
138 #define REGISTER_HYDRODYNAMICMODEL_CREATOR(type, creator) \
139  const bool type::registeredWithFactory = \
140  HydrodynamicModelFactory::GetInstance().RegisterCreator( \
141  type::IDENTIFIER, creator);
142 
154 {
156  public: static HydrodynamicModel* create(sdf::ElementPtr _sdf,
157  physics::LinkPtr _link);
158 
160  public: virtual std::string GetType() { return IDENTIFIER; }
161 
163  public: virtual void Print(std::string _paramName,
164  std::string _message = std::string());
165 
167  public: virtual bool GetParam(std::string _tag,
168  std::vector<double>& _output);
169 
171  public: virtual bool GetParam(std::string _tag, double& _output);
172 
174  public: virtual bool SetParam(std::string _tag, double _input);
175 
178 
180  protected: static const std::string IDENTIFIER;
181 
182  protected: HMFossen(sdf::ElementPtr _sdf, physics::LinkPtr _link);
183 
185  public: virtual void ApplyHydrodynamicForces(double time,
186  const ignition::math::Vector3d &_flowVelWorld);
187 
189  protected: void ComputeAddedCoriolisMatrix(const Eigen::Vector6d& _vel,
190  const Eigen::Matrix6d& _Ma,
191  Eigen::Matrix6d &_Ca) const;
192 
194  protected: void ComputeDampingMatrix(const Eigen::Vector6d& _vel,
195  Eigen::Matrix6d &_D) const;
196 
198  protected: Eigen::Matrix6d GetAddedMass() const;
199 
201  protected: Eigen::Matrix6d Ma;
202 
204  protected: double scalingAddedMass;
205 
207  protected: double offsetAddedMass;
208 
210  protected: Eigen::Matrix6d Ca;
211 
213  protected: Eigen::Matrix6d D;
214 
216  protected: double scalingDamping;
217 
219  protected: double offsetLinearDamping;
220 
222  protected: double offsetLinForwardSpeedDamping;
223 
225  protected: double offsetNonLinDamping;
226 
228  protected: Eigen::Matrix6d DLin;
229 
238 
241 
243  protected: std::vector<double> linearDampCoef;
244 
246  protected: std::vector<double> quadDampCoef;
247 };
248 
252 class HMSphere : public HMFossen
253 {
255  public: static HydrodynamicModel* create(sdf::ElementPtr _sdf,
256  physics::LinkPtr _link);
257 
259  public: virtual std::string GetType() { return IDENTIFIER; }
260 
262  public: virtual void Print(std::string _paramName,
263  std::string _message = std::string());
264 
267 
269  protected: static const std::string IDENTIFIER;
270 
271  protected: HMSphere(sdf::ElementPtr _sdf, physics::LinkPtr _link);
272 
274  protected: double radius;
275 
277  protected: double Cd;
278 
280  protected: double areaSection;
281 };
282 
286 class HMCylinder : public HMFossen
287 {
289  public: static HydrodynamicModel* create(sdf::ElementPtr _sdf,
290  physics::LinkPtr _link);
291 
293  public: virtual std::string GetType() { return IDENTIFIER; }
294 
296  public: virtual void Print(std::string _paramName,
297  std::string _message = std::string());
298 
301 
303  protected: static const std::string IDENTIFIER;
304 
305  protected: HMCylinder(sdf::ElementPtr _sdf, physics::LinkPtr _link);
306 
308  protected: double length;
309 
311  protected: double radius;
312 
314  protected: std::string axis;
315 
317  protected: double dimRatio;
318 
320  protected: double cdCirc;
321 
323  protected: double cdLength;
324 };
325 
330 class HMSpheroid : public HMFossen
331 {
333  public: static HydrodynamicModel* create(sdf::ElementPtr _sdf,
334  physics::LinkPtr _link);
335 
337  public: virtual std::string GetType() { return IDENTIFIER; }
338 
340  public: virtual void Print(std::string _paramName,
341  std::string _message = std::string());
342 
345 
347  protected: static const std::string IDENTIFIER;
348 
349  protected: HMSpheroid(sdf::ElementPtr _sdf, physics::LinkPtr _link);
350 
352  protected: double length;
353 
355  protected: double radius;
356 };
357 
361 class HMBox : public HMFossen
362 {
364  public: static HydrodynamicModel* create(sdf::ElementPtr _sdf,
365  physics::LinkPtr _link);
366 
368  public: virtual std::string GetType() { return IDENTIFIER; }
369 
371  public: virtual void Print(std::string _paramName,
372  std::string _message = std::string());
373 
376 
378  protected: static const std::string IDENTIFIER;
379 
381  protected: HMBox(sdf::ElementPtr _sdf, physics::LinkPtr _link);
382 
384  protected: double Cd;
385 
387  protected: double length;
388 
390  protected: double width;
391 
393  protected: double height;
394 };
395 }
396 
397 #endif // __UUV_GAZEBO_HYDRO_MODEL_HH__
double height
Height of the box.
double Cd
Drag coefficient.
Eigen::Matrix6d DLin
Linear damping matrix.
Eigen::Matrix6d DLinForwardSpeed
Linear damping matrix proportional only to the forward speed (useful for modeling AUVs)...
double radius
Prolate spheroid&#39;s smaller radius.
double cdCirc
Approximated drag coefficient for the circular area.
void ComputeAcc(Eigen::Vector6d _velRel, double _time, double _alpha=0.3)
Filter acceleration (fix due to the update structure of Gazebo)
ignition::math::Vector3d FromNED(ignition::math::Vector3d _vec)
Convert vector to comply with the NED reference frame.
double width
Width of the box.
static const std::string IDENTIFIER
Unique identifier for this geometry.
HydrodynamicModelFactory()
Constructor is private since this is a singleton.
Class containing the methods and attributes for a hydrodynamic model for a spheroid in the fluid Refe...
double radius
Sphere radius.
double areaSection
Area of the cross section.
double offsetLinearDamping
Offset for the linear damping matrix.
Description of a buoyant object.
virtual void Print(std::string _paramName, std::string _message=std::string())=0
Prints parameters.
double length
Length of the cylinder.
virtual std::string GetType()
Return (derived) type of hydrodynamic model.
double offsetAddedMass
Offset for the added-mass matrix.
static const std::string IDENTIFIER
Unique identifier for this geometry.
std::map< std::string, HydrodynamicModelCreator > creators_
Map of each registered identifier to its corresponding creator.
double length
Length of the sphroid.
double offsetNonLinDamping
Offset for the linear damping matrix.
virtual std::string GetType()=0
Returns type of model.
virtual void ApplyHydrodynamicForces(double time, const ignition::math::Vector3d &_flowVelWorld)=0
Computation of the hydrodynamic forces.
double Re
Reynolds number (not used by all models)
Class containing the methods and attributes for a hydrodynamic model for a box in the fluid...
double lastTime
Last timestamp (in seconds) at which ApplyHydrodynamicForces was called.
Eigen::Matrix< double, 6, 1 > Vector6d
Definition of a 6 element Eigen vector.
Definition: Def.hh:46
Factory singleton class that creates a HydrodynamicModel from sdf.
virtual std::string GetType()
Return (derived) type of hydrodynamic model.
HydrodynamicModel(sdf::ElementPtr _sdf, physics::LinkPtr _link)
Protected constructor: Use the factory for object creation.
Class containing the methods and attributes for a hydrodynamic model for a sphere in the fluid...
Eigen::Vector6d filteredAcc
Filtered linear & angular acceleration vector in link frame. This is used to prevent the model to bec...
static const std::string IDENTIFIER
Unique identifier for this geometry.
ignition::math::Vector3d ToNED(ignition::math::Vector3d _vec)
Convert vector to comply with the NED reference frame.
Eigen::Vector6d lastVelRel
Last body-fixed relative velocity (nu_R in Fossen&#39;s equations)
static const std::string IDENTIFIER
Unique identifier for this geometry.
virtual std::string GetType()
Return (derived) type of hydrodynamic model.
double temperature
Temperature (not used by all models)
Eigen::Matrix6d Ca
Added-mass associated Coriolis matrix.
Class containting the methods and attributes for a Fossen robot-like hydrodynamic model...
Eigen::Matrix6d Ma
Added-mass matrix.
HydrodynamicModel *(* HydrodynamicModelCreator)(sdf::ElementPtr, physics::LinkPtr)
Function pointer to create a certain a model.
std::vector< double > quadDampCoef
Quadratic damping coefficients.
virtual bool SetParam(std::string _tag, double _input)=0
Set a scalar parameters.
virtual std::string GetType()
Return (derived) type of hydrodynamic model.
virtual std::string GetType()
Return (derived) type of hydrodynamic model.
Eigen::Matrix6d D
Damping matrix.
Eigen::Matrix< double, 6, 6 > Matrix6d
Definition of a 6x6 Eigen matrix.
Definition: Def.hh:43
std::string axis
Name of the unit rotation axis (just a tag for x, y or z)
bool CheckParams(sdf::ElementPtr _sdf)
Returns true if all parameters are available from the SDF element.
double scalingDamping
Scaling of the damping matrix.
Class describing the dynamics of a buoyant object, useful for simple representations of underwater st...
double Cd
Drag coefficient.
double cdLength
Approximated drag coefficient for the rectangular section.
Class containing the methods and attributes for a hydrodynamic model for a cylinder in the fluid...
Eigen::Matrix6d DNonLin
Nonlinear damping coefficients.
#define REGISTER_HYDRODYNAMICMODEL(type)
Use the following macro within a HydrodynamicModel declaration:
double dimRatio
Ratio between length and diameter.
double offsetLinForwardSpeedDamping
Offset for the linear damping matrix.
static const std::string IDENTIFIER
Unique identifier for this geometry.
General definitions.
boost::shared_ptr< HydrodynamicModel > HydrodynamicModelPtr
Pointer to model.
std::vector< std::string > params
List of parameters needed from the SDF element.
std::vector< double > linearDampCoef
Linear damping coefficients.
double radius
Sphere radius.
double scalingAddedMass
Scaling of the added-mass matrix.
double length
Length of the box.
virtual bool GetParam(std::string _tag, std::vector< double > &_output)=0
Return paramater in vector form for the given tag.


uuv_gazebo_plugins
Author(s): Musa Morena Marcusso Manhaes , Sebastian Scherer , Luiz Ricardo Douat
autogenerated on Mon Jul 1 2019 19:39:12