Skip to content

Commit

Permalink
Maritime tutorials 💧 - Part 2 of 4 (#2258)
Browse files Browse the repository at this point in the history
* Buoyancy and hydrodynamics tutorials.

Signed-off-by: Carlos Agüero <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: crvogt <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
  • Loading branch information
4 people committed Dec 22, 2023
1 parent 66ae42c commit ae0070f
Show file tree
Hide file tree
Showing 4 changed files with 623 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tutorials.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ Gazebo @GZ_DESIGNATION_CAP@ library and how to use the library effectively.

## Maritime

* \subpage theory_buoyancy "Buoyancy: " Describe the theory of operation of the
buoyancy plugin.
* \subpage theory_hydrodynamics "Hydrodynamics:" Describe the theory of
operation of the hydrodynamics plugin.
* \subpage create_vehicle "Create a maritime vehicle:" How to design a maritime
model.
* \subpage adding_visuals "Adding visuals:" How to import 3D meshes into Gazebo
Expand Down
355 changes: 355 additions & 0 deletions tutorials/files/theory_hydrodynamics/buoyant_cylinder.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,355 @@
<?xml version="1.0" ?>
<sdf version="1.7">
<world name="buoyant_cylinder">

<scene>
<ambient>0.0 1.0 1.0</ambient>
<background>0.0 0.7 0.8</background>

<grid>false</grid>
</scene>

<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
<pose>0 0 10 0 0 0</pose>
<diffuse>1 1 1 1</diffuse>
<specular>0.5 0.5 0.5 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.1 -0.9</direction>
</light>

<plugin
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>

<plugin
filename="gz-sim-buoyancy-system"
name="gz::sim::systems::Buoyancy">
<graded_buoyancy>
<default_density>1025</default_density>
<density_change>
<above_depth>0</above_depth>
<density>1.125</density>
</density_change>
</graded_buoyancy>
</plugin>

<plugin
filename="gz-sim-user-commands-system"
name="gz::sim::systems::UserCommands">
</plugin>

<plugin
filename="gz-sim-scene-broadcaster-system"
name="gz::sim::systems::SceneBroadcaster">
</plugin>

<plugin
filename="gz-sim-sensors-system"
name="gz::sim::systems::Sensors">
</plugin>

<gui fullscreen="0">
<!-- 3D scene -->
<plugin filename="MinimalScene" name="3D View">
<gz-gui>
<title>3D View</title>
<property type="bool" key="showTitleBar">false</property>
<property type="string" key="state">docked</property>
</gz-gui>
<engine>ogre2</engine>
<scene>scene</scene>
<ambient_light>0.4 0.4 0.4</ambient_light>
<background_color>0.8 0.8 0.8</background_color>
<!-- looking at robot -->
<camera_pose>0 6 6 0 0.5 -1.57</camera_pose>
<!-- looking at all science data for 2003080103_mb_l3_las.csv -->
<!--camera_pose>-50000 -30000 250000 0 1.1 1.58</camera_pose-->
<camera_clip>
<!-- ortho view needs low near clip -->
<!-- but a very low near clip messes orbit's far clip ?! -->
<near>0.1</near>
<!-- See 3000 km away -->
<far>3000000</far>
</camera_clip>
</plugin>
<!-- Plugins that add functionality to the scene -->
<plugin filename="EntityContextMenuPlugin" name="Entity context menu">
<gz-gui>
<property key="state" type="string">floating</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<plugin filename="GzSceneManager" name="Scene Manager">
<gz-gui>
<anchors target="3D View">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<plugin filename="InteractiveViewControl" name="Interactive view control">
<gz-gui>
<anchors target="3D View">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<plugin filename="CameraTracking" name="Camera Tracking">
<gz-gui>
<anchors target="3D View">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<plugin filename="MarkerManager" name="Marker manager">
<gz-gui>
<anchors target="3D View">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
<warn_on_action_failure>false</warn_on_action_failure>
</plugin>
<plugin filename="SelectEntities" name="Select Entities">
<gz-gui>
<anchors target="Select entities">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<plugin filename="VisualizationCapabilities" name="Visualization Capabilities">
<gz-gui>
<anchors target="Select entities">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<plugin filename="Spawn" name="Spawn Entities">
<gz-gui>
<anchors target="Select entities">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<!-- World control -->
<plugin filename="WorldControl" name="World control">
<gz-gui>
<title>World control</title>
<property type="bool" key="showTitleBar">false</property>
<property type="bool" key="resizable">false</property>
<property type="double" key="height">72</property>
<property type="double" key="width">121</property>
<property type="double" key="z">1</property>
<property type="string" key="state">floating</property>
<anchors target="3D View">
<line own="left" target="left"/>
<line own="bottom" target="bottom"/>
</anchors>
</gz-gui>
<play_pause>true</play_pause>
<step>true</step>
<start_paused>true</start_paused>
</plugin>
<!-- World statistics -->
<plugin filename="WorldStats" name="World stats">
<gz-gui>
<title>World stats</title>
<property type="bool" key="showTitleBar">false</property>
<property type="bool" key="resizable">false</property>
<property type="double" key="height">110</property>
<property type="double" key="width">290</property>
<property type="double" key="z">1</property>
<property type="string" key="state">floating</property>
<anchors target="3D View">
<line own="right" target="right"/>
<line own="bottom" target="bottom"/>
</anchors>
</gz-gui>
<sim_time>true</sim_time>
<real_time>true</real_time>
<real_time_factor>true</real_time_factor>
<iterations>true</iterations>
</plugin>
<plugin filename="ComponentInspector" name="Component Inspector">
<gz-gui>
<title>Inspector</title>
<property type="string" key="state">docked_collapsed</property>
</gz-gui>
</plugin>
<plugin filename="GridConfig" name="Grid config">
<gz-gui>
<property type="string" key="state">docked_collapsed</property>
</gz-gui>
<insert>
<!-- 300 km x 300 km -->
<cell_count>6</cell_count>
<vertical_cell_count>0</vertical_cell_count>
<!-- 50 km -->
<cell_length>50000</cell_length>
<pose>0 100000 0 0 0 0.32</pose>
<color>0 1 0 1</color>
</insert>
<insert>
<!-- 0.1 km x 0.1 km -->
<cell_count>100</cell_count>
<vertical_cell_count>0</vertical_cell_count>
<!-- 1 m -->
<cell_length>1</cell_length>
<pose>0 0 0 0 0 0</pose>
<color>0.5 0.5 0.5 1</color>
</insert>
</plugin>
</gui>

<!-- This invisible plane helps with orbiting the camera, especially at large scales -->
<model name="horizontal_plane">
<static>true</static>
<link name="link">
<visual name="visual">
<geometry>
<plane>
<normal>0 0 1</normal>
<!-- 300 km x 300 km -->
<size>300000 300000</size>
</plane>
</geometry>
<transparency>1.0</transparency>
</visual>
</link>
</model>


<!-- User options - Modify these parameters according to your needs -->

<!-- Physics parameters -->
<physics name="1ms" type="dart">
<max_step_size>0.02</max_step_size>
<real_time_factor>1</real_time_factor>
</physics>

<!-- Model to load -->
<model name="my_turtle">
<link name='base_link'>

<inertial>
<pose>0 0 0 0 0 0</pose>
<mass>10</mass>
<inertia>
<ixx>0.35032999999999995</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.35032999999999995</iyy>
<iyz>0</iyz>
<izz>0.61250000000000006</izz>
</inertia>
</inertial>

<collision name='collision'>
<geometry>
<box>
<size>1 1 0.009948450858321252</size>
</box>
</geometry>
</collision>

<visual name='visual'>
<pose>0.08 0 0.05 0 0 0</pose>
<geometry>
<cylinder>
<radius>0.35</radius>
<length>0.23</length>
</cylinder>
</geometry>
</visual>
</link>

<!-- Uncomment to generate a trajectory -->
<plugin filename="gz-sim-trajectory-follower-system"
name="gz::sim::systems::TrajectoryFollower">
<link_name>base_link</link_name>
<force>0.2</force>
<torque>0.01</torque>
<range_tolerance>0.1</range_tolerance>
<waypoints>
<waypoint>1 0</waypoint>
</waypoints>
</plugin>

<!-- Uncomment to add hydrodynamics -->
<plugin
filename="gz-sim-hydrodynamics-system"
name="gz::sim::systems::Hydrodynamics">
<link_name>base_link</link_name>
<xDotU>-0.04876161</xDotU>
<yDotV>-1.26324739</yDotV>
<zDotW>-1.26324739</zDotW>
<kDotP>0</kDotP>
<mDotQ>-0.3346</mDotQ>
<nDotR>-0.3346</nDotR>
<xUabsU>-0.62282</xUabsU>
<xU>-5</xU>
<yVabsV>-60.127</yVabsV>
<yV>-5</yV>
<zWabsW>-6.0127</zWabsW>
<zW>-100</zW>
<kPabsP>-0.001916</kPabsP>
<kP>-1</kP>
<mQabsQ>-6.32698957</mQabsQ>
<mQ>-1</mQ>
<nRabsR>-6.32698957</nRabsR>
<nR>-1</nR>
</plugin>

</model>

</world>
</sdf>
Loading

0 comments on commit ae0070f

Please sign in to comment.