20 #ifndef __UUV_GAZEBO_HYDRO_MODEL_HH__ 21 #define __UUV_GAZEBO_HYDRO_MODEL_HH__ 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> 29 #include <eigen3/Eigen/Core> 30 #include <eigen3/Eigen/Geometry> 48 public:
virtual std::string
GetType() = 0;
52 double time,
const ignition::math::Vector3d &_flowVelWorld) = 0;
55 public:
virtual void Print(std::string _paramName,
56 std::string _message = std::string()) = 0;
59 public:
virtual bool GetParam(std::string _tag,
60 std::vector<double>& _output) = 0;
63 public:
virtual bool GetParam(std::string _tag,
67 public:
virtual bool SetParam(std::string _tag,
double _input) = 0;
78 protected: ignition::math::Vector3d
ToNED(ignition::math::Vector3d _vec);
81 protected: ignition::math::Vector3d
FromNED(ignition::math::Vector3d _vec);
97 protected: std::vector<std::string>
params;
100 protected:
double Re;
118 physics::LinkPtr _link);
124 public:
bool RegisterCreator(
const std::string& _identifier,
131 private: std::map<std::string, HydrodynamicModelCreator>
creators_;
135 #define REGISTER_HYDRODYNAMICMODEL(type) static const bool registeredWithFactory 138 #define REGISTER_HYDRODYNAMICMODEL_CREATOR(type, creator) \ 139 const bool type::registeredWithFactory = \ 140 HydrodynamicModelFactory::GetInstance().RegisterCreator( \ 141 type::IDENTIFIER, creator); 157 physics::LinkPtr _link);
160 public:
virtual std::string
GetType() {
return IDENTIFIER; }
163 public:
virtual void Print(std::string _paramName,
164 std::string _message = std::string());
167 public:
virtual bool GetParam(std::string _tag,
168 std::vector<double>& _output);
171 public:
virtual bool GetParam(std::string _tag,
double& _output);
174 public:
virtual bool SetParam(std::string _tag,
double _input);
182 protected:
HMFossen(sdf::ElementPtr _sdf, physics::LinkPtr _link);
186 const ignition::math::Vector3d &_flowVelWorld);
189 protected:
void ComputeAddedCoriolisMatrix(
const Eigen::Vector6d& _vel,
256 physics::LinkPtr _link);
259 public:
virtual std::string
GetType() {
return IDENTIFIER; }
262 public:
virtual void Print(std::string _paramName,
263 std::string _message = std::string());
271 protected:
HMSphere(sdf::ElementPtr _sdf, physics::LinkPtr _link);
277 protected:
double Cd;
290 physics::LinkPtr _link);
293 public:
virtual std::string
GetType() {
return IDENTIFIER; }
296 public:
virtual void Print(std::string _paramName,
297 std::string _message = std::string());
305 protected:
HMCylinder(sdf::ElementPtr _sdf, physics::LinkPtr _link);
334 physics::LinkPtr _link);
337 public:
virtual std::string
GetType() {
return IDENTIFIER; }
340 public:
virtual void Print(std::string _paramName,
341 std::string _message = std::string());
349 protected:
HMSpheroid(sdf::ElementPtr _sdf, physics::LinkPtr _link);
365 physics::LinkPtr _link);
368 public:
virtual std::string
GetType() {
return IDENTIFIER; }
371 public:
virtual void Print(std::string _paramName,
372 std::string _message = std::string());
381 protected:
HMBox(sdf::ElementPtr _sdf, physics::LinkPtr _link);
384 protected:
double Cd;
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'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.
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'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.
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.
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.