23 std::cout << __PRETTY_FUNCTION__ << std::endl;
29 physics::ModelPtr _model)
31 std::cout << __PRETTY_FUNCTION__ << std::endl;
32 if (!_sdf->HasElement(
"type"))
34 std::cerr <<
"umbilical_model does not have an type element" 39 std::string identifier = _sdf->Get<std::string>(
"type");
41 if (creators_.find(identifier) == creators_.end())
43 std::cerr <<
"Cannot create UmbilicalModel with unknown identifier: " 44 << identifier << std::endl;
48 return creators_[identifier](_sdf, _model);
62 if (creators_.find(_identifier) != creators_.end())
64 std::cerr <<
"Warning: Registering UmbilicalModel with identifier: " 65 << _identifier <<
" twice" << std::endl;
67 creators_[_identifier] = _creator;
69 std::cout <<
"Registered UmbilicalModel type " 70 << _identifier << std::endl;
79 physics::ModelPtr _model)
81 GZ_ASSERT(_sdf->HasElement(
"connector_link"),
82 "Could not find connector_link.");
83 std::string connectorLinkName = _sdf->Get<std::string>(
"connector_link");
84 this->
connector = _model->GetLink(connectorLinkName);
85 GZ_ASSERT(this->connector,
"connector_link is invalid");
87 GZ_ASSERT(_sdf->HasElement(
"diameter"),
"Could not find diameter.");
88 this->diameter = _sdf->Get<
double>(
"diameter");
90 GZ_ASSERT(_sdf->HasElement(
"water_density"),
"Could not find water_density.");
91 this->rho = _sdf->Get<
double>(
"water_density");
96 physics::ModelPtr _model)
98 std::cout << __PRETTY_FUNCTION__ << std::endl;
104 const ignition::math::Vector3d& _flow)
106 ignition::math::Pose3d pose;
107 #if GAZEBO_MAJOR_VERSION >= 8 110 pose = this->
connector->GetWorldPose().Ign();
113 double h = -pose.Pos().Z();
116 "z coordinate should be negative");
118 ignition::math::Vector3d uvR;
120 #if GAZEBO_MAJOR_VERSION >= 8 121 uvR = _flow - this->
connector->WorldLinearVel();
123 uvR = _flow - this->
connector->GetWorldLinearVel().Ign();
126 double uR2 = uvR.X() * std::abs(uvR.X());
127 double vR2 = uvR.Y() * std::abs(uvR.Y());
128 double factor = 0.25 * 1.2 * this->rho;
130 ignition::math::Vector3d fWorld(uR2, vR2, 0.);
131 this->
connector->AddForce(fWorld * factor);
Factory singleton class that creates an UmbilicalModel from sdf.
static const std::string IDENTIFIER
The unique identifier of this UmbilicalModel.
static UmbilicalModelFactory & GetInstance()
Return the singleton instance of this factory.
physics::LinkPtr connector
Moving connector link of this umbilical.
static UmbilicalModel * create(sdf::ElementPtr _sdf, physics::ModelPtr _model)
Create UmbilicalModel according to its description.
Various umbilical models.
UmbilicalModel * CreateUmbilicalModel(sdf::ElementPtr _sdf, physics::ModelPtr _model)
Create a ConversionFunction object according to its sdf Description.
virtual void Init()
Initialize model.
virtual void OnUpdate(const common::UpdateInfo &_info, const ignition::math::Vector3d &_flow)
Update Umbilical (and apply forces)
#define REGISTER_UMBILICALMODEL_CREATOR(type, creator)
Use the following macro before a ThrusterDynamics's definition:
bool RegisterCreator(const std::string &_identifier, UmbilicalModelCreator _creator)
Register an UmbilicalModel class with its creator.
UmbilicalModel *(* UmbilicalModelCreator)(sdf::ElementPtr, physics::ModelPtr)
Function pointer to create a certain conversion function.