buoyancy_gazebo_plugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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 
18 #ifndef USV_GAZEBO_PLUGINS_BUOYANCY_GAZEBO_PLUGIN_HH_
19 #define USV_GAZEBO_PLUGINS_BUOYANCY_GAZEBO_PLUGIN_HH_
20 
21 #include <map>
22 #include <string>
23 #include <vector>
24 
25 #include <gazebo/common/common.hh>
26 #include <gazebo/common/Event.hh>
27 #include <gazebo/common/Plugin.hh>
28 #include <gazebo/physics/physics.hh>
29 #include <ignition/math/Pose3.hh>
30 #include <ignition/math/Vector3.hh>
32 
36 
37 namespace gazebo
38 {
39  namespace buoyancy
40  {
43  {
45  public: BuoyancyObject();
46 
48  public: BuoyancyObject(BuoyancyObject&& obj) noexcept; // NOLINT
49 
51  public: BuoyancyObject(BuoyancyObject& obj) = delete;
52 
56  public: void Load(const physics::ModelPtr model,
57  const sdf::ElementPtr elem);
58 
60  public: std::string Disp();
61 
63  public: int linkId;
64 
66  public: std::string linkName;
67 
69  public: ignition::math::Pose3d pose;
70 
72  public:double mass;
73 
76  };
77  } // end of buoyancy namespace
78 
114  class BuoyancyPlugin : public ModelPlugin
115  {
117  public: BuoyancyPlugin();
118 
119  // Documentation inherited.
120  public: virtual void Load(physics::ModelPtr _model,
121  sdf::ElementPtr _sdf);
122 
123  // Documentation inherited.
124  public: virtual void Init();
125 
127  protected: virtual void OnUpdate();
128 
130  protected: event::ConnectionPtr updateConnection;
131 
134  protected: double fluidDensity;
135 
137  protected: double fluidLevel;
138 
140  protected: double linearDrag;
141 
143  protected: double angularDrag;
144 
146  protected: std::vector<buoyancy::BuoyancyObject> buoyancyObjects;
147 
149  protected: std::map<int, gazebo::physics::LinkPtr> linkMap;
150 
152  protected: physics::ModelPtr model;
153 
156  protected: physics::WorldPtr world;
157 
159  protected: std::string waveModelName;
160 
162  protected: std::map<gazebo::physics::LinkPtr, double> linkHeights;
163 
165  protected: std::map<gazebo::physics::LinkPtr, double> linkHeightDots;
166 
168  protected: double lastSimTime;
169 
171  protected: std::shared_ptr<const asv::WaveParameters> waveParams;
172  };
173 }
174 
175 #endif
ignition::math::Pose3d pose
Pose of buoyancy relative to link.
double fluidLevel
The height of the fluid/air interface [m]. Defaults to 0.
This plugin simulates buoyancy of an object in fluid. <wave_model>: Name of the wave model object (op...
void Load(const physics::ModelPtr model, const sdf::ElementPtr elem)
Load buoyancy object from SDF.
std::vector< buoyancy::BuoyancyObject > buoyancyObjects
List of buoyancy objects for model.
::buoyancy::ShapeVolumePtr shape
Buoyancy object&#39;s shape properties.
std::unique_ptr< ShapeVolume > ShapeVolumePtr
Definition: shape_volume.hh:70
std::map< gazebo::physics::LinkPtr, double > linkHeightDots
Map of water velocity at each link.
std::map< gazebo::physics::LinkPtr, double > linkHeights
Map of water height at each link from previous timestep.
std::string Disp()
Display string for buoyancy object.
std::shared_ptr< const asv::WaveParameters > waveParams
The wave parameters.
std::map< int, gazebo::physics::LinkPtr > linkMap
Map of <link ID, link pointer>
double lastSimTime
Previous update time.
double angularDrag
Angular drag coefficient. Defaults to 0.
double mass
Object mass (from inertial elem)
std::string linkName
Associated link name.
std::string waveModelName
The name of the wave model.
event::ConnectionPtr updateConnection
Connection to World Update events.
double fluidDensity
The density of the fluid in which the object is submerged in kg/m^3. Defaults to 1000, the fluid density of water at 15 Celsius.
double linearDrag
Linear drag coefficient. Defaults to 0.
physics::ModelPtr model
Pointer to base model.
A class for storing buoyancy object properties.
physics::WorldPtr world
Pointer to the Gazebo world Retrieved when the model is loaded.


usv_gazebo_plugins
Author(s): Brian Bingham , Carlos Aguero
autogenerated on Thu May 7 2020 03:54:47