Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fluid added mass #384

Merged
merged 10 commits into from
Nov 28, 2022
Merged

Support fluid added mass #384

merged 10 commits into from
Nov 28, 2022

Conversation

chapulina
Copy link
Contributor

@chapulina chapulina commented Jul 14, 2022

🎉 New feature

Summary

Uses the APIs added as part of the Fluid Added Mass Proposal.

Ideally the added mass functionality would be part of an optional feature. I have to look a bit deeper to figure out how to take that out of the link construction.

Test it

I'm working on tests and a gz-sim PR

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

Signed-off-by: Louise Poubel <louise@openrobotics.org>
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Jul 14, 2022
@chapulina chapulina added the MBARI buoy Sponsored by MBARI buoy sim project: https://github.com/osrf/buoy_sim label Jul 14, 2022
@chapulina chapulina added the needs upstream release Blocked by a release of an upstream library label Jul 14, 2022
@chapulina chapulina self-assigned this Jul 25, 2022
@chapulina chapulina removed the needs upstream release Blocked by a release of an upstream library label Jul 28, 2022
Signed-off-by: Louise Poubel <louise@openrobotics.org>
Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally the added mass functionality would be part of an optional feature. I have to look a bit deeper to figure out how to take that out of the link construction.

this is beyond the scope of this PR; we don't currently have granularity in our SDF construction features. I'll see if we have an issue about this yet

// TODO(chapulina) Put in another feature
if (sdfInertia.FluidAddedMass().has_value())
{
// TODO check off-diagonal blocks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would comment here about how the order of variables differs between SDFormat / Gazebo and Dartsim / Featherstone, which is why the submatrices need to be shuffled.

@chapulina chapulina added the enhancement New feature or request label Jul 29, 2022
@chapulina chapulina changed the base branch from main to gz-physics6 August 6, 2022 01:50
@chapulina
Copy link
Contributor Author

We're past feature freeze ❄️ . The plan is to not merge this PR into gz-physics6 until after the stable release (i.e. October).

@srmainwaring
Copy link
Contributor

srmainwaring commented Sep 26, 2022

@scpeters I've been experimenting with this and think there may be a problem with the way the fluid added mass influences the gravity force in dart and this affects hydrostatic calculations.

If a body is placed at its equilibrium position (say a sphere with mass = 1/2 volume x water density with centre of buoyancy = centre of mass = centre of geometry placed with it's origin at the free surface), then the net force (hydrostatic + gravity) should be zero and the body should not accelerate.

What happens however is that the hydrostatic force is calculated in a plugin with the body mass, whereas the gravity force appears to be calculated in dart using the spatial tensor (which has been modified with the fluid added mass, so the total adjusted mass is > body mass). The forces are no longer balanced and the object accelerates downwards.

I'm still going through the details to understand how dart implements this, but the problem seems to be that gravity is added globally for the world in the physics engine, whereas the remainder of the forces are added externally via plugins.

One solution may be to have an option to switch gravity off in the core physics engine and add it back in via a system plugin that adds the gravity force for each link using the mass matrix mass?

Edit

Updated with example figures.

The figures below illustrate the issue. They both show two runs of a drop test for a large ellipsoid buoy with hydrostatic restoring forces and a hydrodynamic radiation damping + added mass (on/off). The upper plot in each case is the buoy pose z-component with and without added mass. In figure 1 where dart calculates gravity the equilibrium pose with added mass is lower than the result when added mass is disabled. In figure 2 the world gravity is disabled and the gravity force is calculated in the plugin using the body mass. Here both lines have the same equilibrium pose and the effect of added mass is visible through the lowered frequency and increased amplitude.

Figure 1. Radiation damping and added mass 5m drop test. Dart gravity enabled.

c1_ellipsoid_f5244_fhs_frd-heave-response_dart-grav-on

Figure 2. Radiation damping and added mass 5m drop test. Dart gravity disabled (gravity calculated in plugin)

c1_ellipsoid_f5244_fhs_frd-heave-response_dart-grav-off

Btw. this is using a fully populated added mass matrix from a BEM calculation which I'm passing via a custom plugin rather than via the inertial SDF element:

<added_mass>
  52732.7109003133 -0.0461102712478722  5.88390664387022 0.296417351644741 246367.266847758, -1.69953653780694
  -0.0678279438415122 52944.8240664938 -1.47610970294622 -246974.480351485 -0.376605346811632 34.7833617031108
  5.56653991122738 0.0361713254775427 197297.142256690 0.802697521049529 -87.4935912381782 -0.0504125898702509
  0.410840691063419 -247341.339091709 5.02714890072835 1214533.79620113 2.83888902153701 -166.779120688123
  246734.857503928 -0.346433003966073 -87.1795788996776 2.60143644204397 1215195.98272167 -2.36242713115735
  -1.30857894347732 34.6478012553392 0.0173325214982212 -165.977540011457 -1.09781377470450 108.258384753611
</added_mass>

Dart complains about the spatial tensor being asymmetric and having non-zero elements, but then carries on anyway 🙂

@JoanAguilar
Copy link
Contributor

Hi @srmainwaring, thanks for your comment. We suspected that the current added mass implementation might have an effect on how DART computes the gravity force, your tests seem to confirm that. We concur that disabling gravity in DART and applying it via a plugin might be a good solution to the problem.

@srmainwaring
Copy link
Contributor

srmainwaring commented Sep 26, 2022

Here's a suggestion for calculating the missing term in the spatial tensor when the mass block no longer comprises a 3x3 diagonal matrix with identical elements:

Edited - simplified calc

import numpy as np

fAddedMass = np.array([
52732.7109003133, -0.0461102712478722, 5.88390664387022, 0.296417351644741, 246367.266847758, -1.69953653780694,
-0.0678279438415122, 52944.8240664938, -1.47610970294622, -246974.480351485, -0.376605346811632, 34.7833617031108,
5.56653991122738, 0.0361713254775427, 197297.142256690, 0.802697521049529, -87.4935912381782, -0.0504125898702509,
0.410840691063419, -247341.339091709, 5.02714890072835, 1214533.79620113, 2.83888902153701, -166.779120688123,
246734.857503928, -0.346433003966073, -87.1795788996776, 2.60143644204397, 1215195.98272167, -2.36242713115735,
-1.30857894347732, 34.6478012553392, 0.0173325214982212, -165.977540011457, -1.09781377470450, 108.258384753611
]).reshape(6, 6)

# decomposition of the fluid added mass matrix
M    = fAddedMass[0:3, 0:3]          # mass block
I    = fAddedMass[3:6, 3:6]          # moi block
CM   = fAddedMass[3:6, 0:3]          # CoM-terms

# solve for C
C = np.matmul(CM, np.linalg.inv(M)) 
CMCT = np.matmul(C, np.matmul(M, C.transpose()))

# contributions to the spatial tensor
TL   = I + CMCT   
BL   = CM.transpose()
TR   = CM  
BR   = M

# assemble spatial tensor
S    = np.zeros([6, 6])
S[0:3, 0:3] = TL
S[3:6, 0:3] = BL
S[0:3, 3:6] = TR
S[3:6, 3:6] = BR

with np.printoptions(precision=0, suppress=True):
    print(f"fAddedMass:\n{fAddedMass}")
    print(f"C:\n{C}")
    print(f"M:\n{M}")
    print(f"I:\n{I}")
    print(f"CMCT:\n{CMCT}")
    print(f"S:\n{S}")

fAddedMass:
[[  52733.      -0.       6.       0.  246367.      -2.]
 [     -0.   52945.      -1. -246974.      -0.      35.]
 [      6.       0.  197297.       1.     -87.      -0.]
 [      0. -247341.       5. 1214534.       3.    -167.]
 [ 246735.      -0.     -87.       3. 1215196.      -2.]
 [     -1.      35.       0.    -166.      -1.     108.]]
C:
[[ 0. -5. -0.]
 [ 5. -0. -0.]
 [-0.  0.  0.]]
M:
[[ 52733.     -0.      6.]
 [    -0.  52945.     -1.]
 [     6.      0. 197297.]]
I:
[[1214534.       3.    -167.]
 [      3. 1215196.      -2.]
 [   -166.      -1.     108.]]
CMCT:
[[1155500.       3.    -162.]
 [      2. 1154465.      -6.]
 [   -162.      -6.       0.]]
S:
[[2370034.       5.    -329.       0. -247341.       5.]
 [      5. 2369661.      -8.  246735.      -0.     -87.]
 [   -328.      -7.     108.      -1.      35.       0.]
 [      0.  246735.      -1.   52733.      -0.       6.]
 [-247341.      -0.      35.      -0.   52945.      -1.]
 [      5.     -87.       0.       6.       0.  197297.]]

I've used the add mass tensor from the example above - if the calculation is correct then the additional term mMass*C*C.transpose() is the same order as I.

srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Oct 9, 2022
Ellipsoid Buoy: add model for an ellipsoid buoy

- Add test model for hydrodynamics models.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- add contributions to moments from hydrostatic equilibrium term (centre of buoyancy).

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- update comments and disable debug output

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update models for testing linear wave-body interaction model

- set wave amplitudes to zero and compare the two hydrostatic models

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Clean up.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: document the hydrostatics calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use waterplane origin as reference point for displacements

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add force control parameters to ellipsoid example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body:

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: update added mass example

- Clean and symmetrise matrix

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add code to symmetrise added mass (disabled)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add flags for additional debug info

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: cleanup

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: update example model and add notes

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: use waves test model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add world for ellipsoid test case

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Oct 9, 2022
* Wave Body: Add linear potential wave-body model

Ellipsoid Buoy: add model for an ellipsoid buoy

- Add test model for hydrodynamics models.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- add contributions to moments from hydrostatic equilibrium term (centre of buoyancy).

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- update comments and disable debug output

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update models for testing linear wave-body interaction model

- set wave amplitudes to zero and compare the two hydrostatic models

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Clean up.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: document the hydrostatics calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use waterplane origin as reference point for displacements

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add force control parameters to ellipsoid example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body:

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: update added mass example

- Clean and symmetrise matrix

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add code to symmetrise added mass (disabled)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add flags for additional debug info

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: cleanup

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: update example model and add notes

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: use waves test model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add world for ellipsoid test case

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* ROS: add a project to publish gazebo messages to ros2

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: update README

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
@JoanAguilar
Copy link
Contributor

Revisiting this PR, the major thing that seems to be missing for this to merge is unit tests.

Beyond that, there are a couple of side discussions we probably want to keep track of:

  1. I think we cleared out with @srmainwaring (in a separate discussion) that the implementation in this PR is correct, and that the specification of the added mass matrix in an SDF file is always done in the link frame; it is probably for our own benefit to document this somewhere.

  2. Per @srmainwaring comment, the addition of added mass results in incorrect gravitational effects. @srmainwaring already proposed a solution in the previously mentioned comment:

One solution may be to have an option to switch gravity off in the core physics engine and add it back in via a system plugin that adds the gravity force for each link using the mass matrix mass?

@mjcarroll mjcarroll marked this pull request as ready for review November 21, 2022 21:40
…gen.

Signed-off-by: Joan Aguilar Mayans <joan@openrobotics.org>
@codecov
Copy link

codecov bot commented Nov 23, 2022

Codecov Report

Merging #384 (e4dcbc0) into gz-physics6 (48acd7a) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@               Coverage Diff               @@
##           gz-physics6     #384      +/-   ##
===============================================
+ Coverage        75.73%   75.79%   +0.05%     
===============================================
  Files              140      140              
  Lines             7039     7056      +17     
===============================================
+ Hits              5331     5348      +17     
  Misses            1708     1708              
Impacted Files Coverage Δ
dartsim/src/SDFFeatures.cc 64.07% <100.00%> (+1.33%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Nov 25, 2022
* Wave Body: Add linear potential wave-body model

Ellipsoid Buoy: add model for an ellipsoid buoy

- Add test model for hydrodynamics models.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- add contributions to moments from hydrostatic equilibrium term (centre of buoyancy).

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- update comments and disable debug output

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update models for testing linear wave-body interaction model

- set wave amplitudes to zero and compare the two hydrostatic models

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Clean up.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: document the hydrostatics calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use waterplane origin as reference point for displacements

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add force control parameters to ellipsoid example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body:

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: update added mass example

- Clean and symmetrise matrix

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add code to symmetrise added mass (disabled)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add flags for additional debug info

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: cleanup

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: update example model and add notes

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: use waves test model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add world for ellipsoid test case

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* ROS: add a project to publish gazebo messages to ros2

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: update README

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
@mjcarroll mjcarroll merged commit bab13ef into gz-physics6 Nov 28, 2022
@mjcarroll mjcarroll deleted the chapulina/6/added_mass branch November 28, 2022 15:23
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Nov 30, 2022
* Wave Body: Add linear potential wave-body model

Ellipsoid Buoy: add model for an ellipsoid buoy

- Add test model for hydrodynamics models.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- add contributions to moments from hydrostatic equilibrium term (centre of buoyancy).

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- update comments and disable debug output

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update models for testing linear wave-body interaction model

- set wave amplitudes to zero and compare the two hydrostatic models

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Clean up.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: document the hydrostatics calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use waterplane origin as reference point for displacements

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add force control parameters to ellipsoid example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body:

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: update added mass example

- Clean and symmetrise matrix

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add code to symmetrise added mass (disabled)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add flags for additional debug info

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: cleanup

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: update example model and add notes

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: use waves test model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add world for ellipsoid test case

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* ROS: add a project to publish gazebo messages to ros2

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: update README

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Dec 5, 2022
* Wave Body: Add linear potential wave-body model

Ellipsoid Buoy: add model for an ellipsoid buoy

- Add test model for hydrodynamics models.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- add contributions to moments from hydrostatic equilibrium term (centre of buoyancy).

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- update comments and disable debug output

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update models for testing linear wave-body interaction model

- set wave amplitudes to zero and compare the two hydrostatic models

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Clean up.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: document the hydrostatics calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use waterplane origin as reference point for displacements

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add force control parameters to ellipsoid example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body:

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: update added mass example

- Clean and symmetrise matrix

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add code to symmetrise added mass (disabled)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add flags for additional debug info

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: cleanup

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: update example model and add notes

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: use waves test model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add world for ellipsoid test case

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* ROS: add a project to publish gazebo messages to ros2

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: update README

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Dec 6, 2022
* Wave Body: Add linear potential wave-body model

Ellipsoid Buoy: add model for an ellipsoid buoy

- Add test model for hydrodynamics models.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- add contributions to moments from hydrostatic equilibrium term (centre of buoyancy).

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- update comments and disable debug output

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update models for testing linear wave-body interaction model

- set wave amplitudes to zero and compare the two hydrostatic models

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Clean up.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: document the hydrostatics calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use waterplane origin as reference point for displacements

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add force control parameters to ellipsoid example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body:

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: update added mass example

- Clean and symmetrise matrix

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add code to symmetrise added mass (disabled)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add flags for additional debug info

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: cleanup

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: update example model and add notes

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: use waves test model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add world for ellipsoid test case

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* ROS: add a project to publish gazebo messages to ros2

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: update README

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Dec 8, 2022
Linear potential wave-body model demo (#70)

* Wave Body: Add linear potential wave-body model

Ellipsoid Buoy: add model for an ellipsoid buoy

- Add test model for hydrodynamics models.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- add contributions to moments from hydrostatic equilibrium term (centre of buoyancy).

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- update comments and disable debug output

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update models for testing linear wave-body interaction model

- set wave amplitudes to zero and compare the two hydrostatic models

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Clean up.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: document the hydrostatics calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use waterplane origin as reference point for displacements

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add force control parameters to ellipsoid example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body:

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: update added mass example

- Clean and symmetrise matrix

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add code to symmetrise added mass (disabled)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add flags for additional debug info

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: cleanup

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: update example model and add notes

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: use waves test model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add world for ellipsoid test case

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* ROS: add a project to publish gazebo messages to ros2

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: update README

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Update example regular wave models (#73)

* Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add checks when reading the hdf5 file (#74)

* Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body MBARI: add collision mesh and change default BEM file (#77)

* Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Merge (#80) into demo/linear-wave-body  (#81)

* Waves: enable wave direction in the sinusoid wave model (#80)

* Waves: enable wave direction in the sinusoid wave model

- Allow wave direction to be set for regular waves.
- Add test for a wave direction not parallel to the x-axis

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: rename monochromatic_waves model

- Rename to regular waves.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: update regular wave model descriptions

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Merge branch 'master' into demo/linear-wave-body (#83)

* Waves: enable wave direction in the sinusoid wave model (#80)

* Waves: enable wave direction in the sinusoid wave model

- Allow wave direction to be set for regular waves.
- Add test for a wave direction not parallel to the x-axis

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: rename monochromatic_waves model

- Rename to regular waves.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves simulation optimisation - part 1 (#82)

* Waves: add classes for spreading functions

- Add classes for directional spreading functions.
- Add vectorised calculations using Eigen.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: update classes for spreading functions

- Update classes for directional spreading functions - use Eigen::MatrixXd rather than VectorXd.
- Update tests including broadcasting to arrays.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: add classes for omni-directional spectrum functions

- Add classes for omni-directional wave spectra.
- Add test case for vectorised spectrum calculation using Eigen.
- Add regression test and check limits (k = 0, u19 = 0)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: update classes for omni-directional spectrum functions

- Implement ECVK omni-directional spectra.
- Add test case for vectorised spectrum calculation using Eigen.
- Add regression test and check limits (k = 0, u10 = 0)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: add regression tests for spectra.

- Add regression test against spectrum calculation used in  FFT2.
- Make spectrum functions in FFT2 static.
- Add ECKV spectrum tests.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: fix spreading function test.

- Fix segfault caused by missing arg.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove unused wave simulation classes

- Remove FFTW and OpenCL simulation classes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: reset test values after physical constant updates.

- Update buoyancy regression values after fluid density and gravity value update.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: fix failing static test in gz_waves_bridge

- Disable flake8 and fix docstring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: replace std::vector with Eigen in WaveSimulation

- Migration from std::vector to Eigen::VectorXf. Not efficient as involved heap allocation each update.
- Replace std::vector for interface calls in OceanTile.
- Remove unused code from WaveSpectrum.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: fixes post cherry-pick

- Revert interface change in WaveSimulation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: replace std::vector with Eigen in WaveSimulation

- Remove interface using std::vector<double> from WaveSimulation classes.
- Update waves plugin classes to use new interfaces.
- Update test

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: replace std::vector with Eigen in WaveSimulation

- Remove internal interface using std::vector<double> from WaveSimulation classes.
- Update tests

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: replace std::vector with Eigen in FFT WaveSimulation

- Remove internal interface using std::vector<double> from WaveSimulation classes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: correct typos in derivative calculations for sinusoid and
trochoid waves

- Ensure Eigen vector workspace is initialised in WavesVisual.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: visual lighting workaround

- Tangent space calculation not correct - environment mapping looks incorrect unless dhdx <---> dhdx?

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: update sinusoid wave interface

- Allow x and y to be set independently in wave grid.
- Streamline class declarations.
- Update tests.
- Add vectorise option for sinusoid waves.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove unused functions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: add tests for vectorised sinusoid wave sim

- Cross check vectorised code against non-vectorised version.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove unused include from WaveSimulationSinusoid

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: refactor WaveSimulation method names.

- Rename ComputeHeights to ComputeElevation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: refactor update indentation formatting.

- Add vectorisation method to FFT wave simulation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: refactor update member variable names in FFT wave simulation

- Standardise caps convention for naming member variables (using underscores).
- Update interface to allow different nx and ny for grid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: temp workaround for wave derivatives used in lighting tangent space

- Workaround mixed conventions for matrix-ij vs matrix-xy storage in tangent space calcs.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves simulation optimisation - part 2 (#84)

* Waves: update FFT wave simulation tests for non-square grids (nx != ny)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: apply google coding standards

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: apply google coding standards

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: apply google coding standards

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: apply google coding standards

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: apply google coding standards

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: apply google coding standards

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: update FFT test namesWaves

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: preparation for vectorising FFT wave simulation update

- Add placeholders for vectorised versions of functions
- Replace hardcoded gravity constants with params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: preparation for vectorising FFT wave simulation update

- Add cross-check tests for vectorised versions of base and current amplitude calculations.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: progress vectorising FFT wave simulation update

- Change capitalisation of Cos2sSpreadingFunction.
- Update comments in WaveSpectrum.
- WaveSimulationFFT
 	- Consolidate initialisation code.
	- Update variable names (nyquist)
	- Delay allocation of storage for Eigen member variables.
	- Update tests to use nearest for cross checks on vectorised version.
	- Remove use of auto for Eigen references (use Eigen::Ref instead)
	- Factor out wavenumber initialisation.
	- Partial vectorisation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: vectorise base amplitude calc for FFT wave simulation

- Leave initialisation of IID random normals un-vectorised for testing against original versions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: add unit test for Eigen and FFTW

- Add test skeleton.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: add unit test for Eigen and FFTW

- Add examples using different storage choices.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: add unit test for Eigen and FFTW

- Add examples for row vs column major storage.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: add Eigen alignment macro

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: use Eigen types for FFTW storage - reduce copies

- Use Eigen types instead of fftw_complex* for FFT workspace.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove unused code from FFWT wave simulation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: use row-major Eigen matrix storage for FFT wave simulation

- Intermediate step moving from Eigen::VectorXcd to Eigen::MatrixXcdRowMajor.
- FFTW requires row-major ordering, Eigen is column major by default.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: use row-major Eigen matrix storage for FFT wave simulation

- Change to matrix indexing in FFT wave storage (from a single column).

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: update output mapping from row to col major storage in FFT wave simulation

- Replace loops with vector calls using reshaped to flatten.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Set up CI using GitHub Actions (#85)

- CI: remove travis integration
- Add codeowners and gazebo ci.yml
- Minimal version - checkout only.
- Change checkout actions/checkout@v3
- Add CI workflows for ubuntu and macos
- Rename and split macOS into separate workflow.
- Install Gazebo Garden.
- Test caching
- Add brew install script.
- Add build script.
- Update macos-ci
- Add test step.
- Add GitHub Actions status badge, remove travis badges.
- Update ci install scripts
- Update the brew installation script to force relinking on all dependencies of the installed packages.
- Fix relink step.
- Update ubunti-ci workflow.
- Add install, build and test steps.
- Rename macos scripts.
- Update ubunti-ci workflow.
- Install additional build dependencies.
- Update ubunti-ci workflow.
- Fix colcon build command line.
- Move macOS to colcon build.
- Update workflow for ubuntu 20.04
- Ensure cgal etc are linked as well as deps.
- Split Ubuntu jobs to separate workflow
- Update macos workflow - add build tools
- Fix EigenFFTW breaking on Ubuntu.
- Update macos workflow - reenable build and test
- Fix timer in CGAL test and disable triangulation tests failing on Ubuntu.
- Fix errors in WaveSimulationFFT2 tests and set tolerances for variance comparisons.
- Check colcon install on macOS workflow
- Disable trochoid wave test
- Investigate why colcon not found in macOS CI workflow
- Add workflow to check build tools are installed.
- Use pip3
- Use full path to colcon
- Add pip install checks
- Update path to Python scripts
- Update path to Python scripts
- Pip install colcon and vcstool with --user flag

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves simulation optimisation - part 3 (#87)

* Waves: optimise current amplitude calculation for FFT wave simulation

- Investigate optimisation options for the current amplitude calculation.
- vectorised assignment to fft worlspace is not faster than a single loop.
- pre-calculate the fourier amplitude coefficients (reduce index lookup) - marginal gain?

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: label indices in ocean tile to distinguish between vertex indices and wave indices

- Vertex array index: v_idx_cm: v - vertex, cm - column major
- Wave array index: w_idx_cm: v - vertex, cm - column major
- Wave array index: w_idx_rm: v - vertex, rm - row major

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* CI: only run macOS workflow on PR

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: rename FFT wave simulation class

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: duplicate FFT wave simulation class to factor out reference version

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: duplicate FFT wave simulation class to factor out reference version

- Complete split of reference implementation into separate class.
- Remove unused code from the separated FFT wave simulation classes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove commented code

- Remove code referring to reference versions of the spectrum calculations.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: add performance checks for spectrum and FFT amplitude calculations

- Initial performance tests. Contain debugging and timing info.
- Eigen component-wise array versions are not performant...

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: replace slow array versions of spectrum calcs.

- Eigen component-wise array versions are not performant - replace with calls using std::transform on unary / binary versions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: refactor wave simulation and spectrum test names

- Functions are not truly vectorised - use Eigen array type to label tests instead.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: satisfy Eigen check that range iterators in STL algorithms are from the same expression.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves simulation optimisation - part 4 (#88)

* Waves: restructure wave spectrum performance test for instrumenting

- Move initialisation into test fixture

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove c-wise amplitude update

- Remove inefficient component wise amplitude update and associated data.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove c-wise cos / sin update in current amplitude calc

- Remove inefficient component wise amplitude update.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: restructure FFT wave amplitude performance test for instrumenting

- Move initialisation into test fixture.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: update FFT wave simulation

- Consolidate storage (shape depends whether loop is flattened or not).
-  Make test fixture class names consistent.
- Remove array allocation in current amplitude update

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: use previously calculated wave numbers

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove two loops from FFT base amplitude calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove component-wise array amplitude calculations

- Abandon using c-wise amplitude calculations as the loop based update has better performance.
- Remove unnecessary storage from the FFT class to reduce memory footprint.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: remove WaveSimulationFFTRef from public interface

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: add performance checks for elevation and displacement calculations

- Add performance check for main update loop - elevations, displacements and derivatives.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves simulation optimisation - part 5 (#89)

* Waves: update FFTW check

- Modify check to transform hermitian amplitudes back to real values.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: create FFTW plans before initialising arrays

- FFTW may overwrite data in arrays while planning. Allocate, plan, initialise.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: use complex to real version of FFTW

- Change outputs to real arrays.
- Change size of input complex arrays to nx * ny/2+1
- Output in Compute* functions is now real.
- Add example in the Eigen FFTW test using a c2r plan.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: use complex to real version of FFTW

- Flattened index must be calculated as loops do not cover full range.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: use complex to real version of FFTW

- Disable hermitian tests for optimised FFT wave sim (arrays truncated using symmetry)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: temp disable tests broken because of switch to real DFT

The following tests require further review - restructuring
- ParsevalsIdentityTimeZero
- ParsevalsIdentityTimeNonZero
- Displacement

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: additional Hermitian tests

- Add placeholder tests to check derivative and displacement amplitudes are Hermitian.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Waves: fix Hermitian symmetry for derivatives (#90)

- Correct Nyquist term in derivative amplitudes (must be zero).
- Enable tests to check derivative and displacement amplitudes are Hermitian.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* CI: clean build warnings (#91)

* CI: enable all warnings and enforce as errors

- Clean build of all warnings.
- Disable unused variables from tests (primarily present for printing info).
- Comment unused parameters in function sigs.
- Fix int type comparison warnings in loops.
- Fix initialisation order errors in constructors.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* CI: enable all warnings and enforce as errors

- Remove GZ_ASSERT raising a warning on Ubuntu

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* CI: enable all warnings and enforce as errors

- Renaming shadowing variables.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Wave Body: update ci workflow

- Add build flag for HighFive dependency

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: post rebase fixes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Dec 8, 2022
* Wave Body: Add linear potential wave-body model

Ellipsoid Buoy: add model for an ellipsoid buoy

- Add test model for hydrodynamics models.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- add contributions to moments from hydrostatic equilibrium term (centre of buoyancy).

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update linear wave-body interaction model

- update comments and disable debug output

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: update models for testing linear wave-body interaction model

- set wave amplitudes to zero and compare the two hydrostatic models

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use loaded hydro data in calculations

- Clean up.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: document the hydrostatics calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: use waterplane origin as reference point for displacements

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: add force control parameters to ellipsoid example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave-Body:

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: update added mass example

- Clean and symmetrise matrix

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add code to symmetrise added mass (disabled)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: add flags for additional debug info

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Fluid added mass: cleanup

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: update example model and add notes

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: use waves test model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: add world for ellipsoid test case

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

* ROS: add a project to publish gazebo messages to ros2

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: update README

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Dec 8, 2022
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Dec 9, 2022
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Dec 9, 2022
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Dec 9, 2022
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Jan 15, 2023
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Jan 18, 2023
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
mjcarroll added a commit that referenced this pull request Jan 19, 2023
When fluid added mass (#384) is used, dartsim will apply gravitational force to the total virtual mass of each link. Since this mass is only to model the inertial aspects of the dynamics, this is incorrect behavior.

In this PR, I disable dart's application of gravity to links that have added mass defined in their sdf file. Instead, gravity is applied as an external force right before the world update by multiplying the link mass by the gravity vector (F = ma!)

Signed-off-by: Michael Carroll <michael@openrobotics.org>
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Jan 20, 2023
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Jan 20, 2023
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Jan 21, 2023
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Jan 21, 2023
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Jan 24, 2023
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Jan 26, 2023
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
srmainwaring added a commit to srmainwaring/asv_wave_sim that referenced this pull request Jan 26, 2023
This is squashed history of the linear potential wave-body model.

1. Linear potential wave-body model demo (#70)

1.1. Wave Body: Add linear potential wave-body model

- Add model for an ellipsoid buoy
- Add test model for hydrodynamics models.

1.2. Wave-Body: add plugin for testing linear wave-body interaction models

- Initial version of plugin with hydrostatic restoring forces.

1.3. Wave-Body: update linear wave-body interaction model

- Add contributions to moments from hydrostatic equilibrium term (centre
of buoyancy).

1.4. Wave-Body: update linear wave-body interaction model

- Update comments and disable debug output

1.5. Wave-Body: update models for testing linear wave-body interaction model

- Set wave amplitudes to zero and compare the two hydrostatic models

1.6. Wave-Body: add hydro data file and load into plugin

- Add BEM hydro data .hdf5 file for ellipsoid (generated by capytaine / bemio)
- Add dependency on Eigen. HDF5 and HighFive to read data file (HighFive should be cloned into to workspace)

1.7. Wave-Body: use loaded hydro data in calculations

- Store loaded hydro data in a struct and replace hardcoded data.

1.8. Wave-Body: use loaded hydro data in calculations

- Clean up.

1.9. Wave-Body: load remaining hydro data

- Complete loading of all hydro data (except for state space model data)
- Load routines can be factored out and consolidated (2nd pass)

1.10. Wave-Body: split update into contributions by force type

- Split out hydrostatic force calculation.

1.11. Wave-Body: add parameter for hydro data file

- Add parameter <hydrodata> for specifying HDF5 file.
- Move model specific config under model folder.

1.12. Wave-Body: document the hydrostatics calculation

1.13. Wave-Body: use waterplane origin as reference point for displacements

1.14. Wave-Body: add radiation damping test case

- Update variable labelling for pose and vectors
- Add radiation damping test case example (hardcoded)

1.15. Wave-Body: add parameters to control which forces are calculated

- Add flags to control which force contributions are included
- Format hdf5 file reader
- Make hydrostatics forces switchable

1.16. Wave-Body: add force control parameters to ellipsoid example

1.17. Wave-Body: initial version of radiation added mass force

- Reorganise code to enable switching forces on / off
- Outline added mass calculation

1.18. Wave-Body: updated version of radiation added mass force

- Investigate a couple of methods - both approaches to capture acceleration in the force contribution are unstable.
- Alternative methods is to use the SetFluidAddedMass method of the inertial.
- This can be set on the component attached to the link entity in the plugin config, and this appears to propagate to the physics engine.

1.19. Wave-Body: replace hardcoded added mass override with parameters

- Allow the added mass and radiation damping to be set in parameters
- Remove added mass calculation from update and set inertial in config
- Add example parameters to demo world

1.20. Wave-Body: replace hardcoded radiation damping override with parameters

- Allow the radiation damping to be set in parameters

1.21. Wave-Body: add gravity calculation

- Add aliases for Vector6d and Matrix6d
- Add gravity calculation to use instead of global physics engine gravity
- Required when enabling added mass
- Update added mass calculation to use gazebosim/gz-physics#384

1.22. Fluid added mass: update added mass example

- Clean and symmetrise matrix

1.23. Fluid added mass: add code to symmetrise added mass (disabled)

1.24. Fluid added mass: add flags for additional debug info

1.25. Fluid added mass: cleanup

1.26. Wave Excitation: add parameters for constant coefficient overrides

- Add parameters for storing wave excitation force coefficients
- Add template specialisation to read Eigen::Vector6d
- Add example data to sdf model
- Remove stale code for added mass adjustments from class declaration

1.27. Wave Excitation: implement excitation force for regular waves

- Add overrides for wave period, height and phase
- Update documentation describing added mass calculation
- Implement constant coefficient excitation calculation for regular waves
- Update wave model to used trochoids with steepness = 0 (direction not implemented for sinusoids)
- Rename elements for wave excitation force components

1.28. Wave Excitation: correct buoyancy moment calculation

- Correct the buoyancy moment calculation for larger displacements.
- Add missing parameter read for the flag to enable / disable the excitation force

1.29. Wave Excitation: implement excitation Froude-Krylov and scattering force components

- Add example coefficients for excitation Froude-Krylove and scattering components.
- Read parameters in Config.
- Implement force calculations for new components.
- Initialise vectors and matrices to zero.

1.30. Wave Excitation: rename variables using Kane/monogram notation

- Rename pose, vectors using Kane/monogram notation described in the Drake docs.
- Fix gravity calculation.
- Factor out common link state updates.

1.31. Wave Body: update example model and add notes

1.32. Wave Body: add force publishers

- Publish force and torque if enabled
- Add parameters to enable force publishing
- Update launch script to enable ROS bridge for forces

1.33. Wave Body: configure buoy example to use all forces

- Set initial position to origin for linear potential model example
- Update document with references

1.34. Wave Body: refactor flags and publishers

- Group flags into structs to reduce clutter.
- Move debug flags into their own SDF element.

1.35. Wave Body: refactor hydro coefficient overrides

- Group coefficients into structs to reduce clutter.
- Reorganise hydro coefficient elements in SDF.
- Move waves and sim environment params into separate structs.
- Add override for hydrostatic linear restoring.

1.36. Wave Body: add geometry overrides

- Add section for geometry overrides.
- Rename the initial pose the body waterplane.

1.37. Wave Body Tests: add wave models for test cases

- Add regular wave models with different periods and amplitudes.

1.38. Wave Body: fix geometry overrides

- Fix issue with parsing SDF and ensure SDF example valid.

1.39. Wave Body: use waves test model

1.40. Wave Body: revert waves.sdf to original

- Move ellipsoid test to new world file.

1.41. Wave Body: add world for ellipsoid test case

1.42. Wave Body Tests: add spheroid test case

- Add spheroid for added mass Test1a

1.42. Wave Body Tests: update spheroid test case

- Add ROS launch file for tests.
- Update BEM coeffs from WEC-Sim example

1.43. Wave Body: improve overrides - 1

- Rename hydro coefficient class.
- Handle override for hydrostatic restoring.

1.44. Wave Body: improve overrides - 2

- Move HDF5 reader to separate function.

1.45. Wave Excitation: fix error in torque calculation

- Fix indexing error in torque lookup.
- Shorten spatial force names.

1.46. Wave Body Hydrostatics: update treatment of CoB offset from CoM

- Use the initial offset of the CoB from CoM in updates - tricky as CoB is dynamic but linear model appears to rely on this being at initial position.

1.47 Wave Body: improve overrides - 3

- Refactor duplicated code in array read functions.

1.48. Wave Body: improve overrides - 4

- Refactor SDF element names.
- Change <hydrodata> to <hdf5_file> as the element is a file name.
- Move <waves> up a level.
- Change <environment> to <simulation_parameters>
- Shorten <force_publishers> to <publishers>

1.49. Wave Body: improve overrides - 5

- Add notes on model and WEC-Sim data structures and modelling.

1.50. Wave Body: improve overrides - 6

- Name refactoring - preparation for introducing new structs for data that will be used in updates.

1.51. Wave Body: improve overrides - 7

- Add improved handling of overrides.
- Remove all override decision making from update loops.
- Add separate data structure to contain the hydro force coefficients used in the update loop.
- Document the load and override policy.

1.52. ROS: add a project to publish gazebo messages to ros2

1.53. ROS: add node to publish body response labelled using maritime conventions

- Add body_response_publisher
- Update launch file

1.54. ROS: update README

1.55. ROS: correct topic name for excitation force

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

2. Wave Body: improve overrides - 8 (#71)

- Remove hardcoded frequency index used to lookup hydro coeffs from hdf5 data.
- Coefficients from hdf5 are linearly interpolated and scaled given the frequency in the simulation params.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

3. Wave Body: use model:// URI to specify BEM file location (#72)

- Use model://<model_path_to_config> URI syntax to locate BEM data files.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

4. Wave Body: Update example regular wave models (#73)

4.1  Wave Body: rename regular wave example models to refer to wave height rather than amplitude

- Use wave height in linear wave-body model SDF and in the names of the example regular wave models.

4.2  Wave Body: add extra regular wave models to cover spectrum

- Add low and high frequency examples.

4.3. Wave Body: reset wave model used by examples

- Set examples to use regular_waves_6s_2m model - this matches the override hydro coefficients.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

5. Wave Body: add checks when reading the hdf5 file (#74)

5.1. Wave Body: add checks when reading the hdf5 file

- Check that datasets are present before loading.
- Check that data is not empty before attempting to display.

5.2. Wave Body: update comments to clarify scaled means non-dimensioned

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

6. Wave Body: add publisher for added mass force (#75)

- Add publisher for estimated added mass force.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

7. Wave Body MBARI: add MBARI buoy example for testing (#76)

- Add test model for the MBARI WEC buoy (float only)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

8. Wave Body MBARI: add collision mesh and change default BEM file (#77)

8.1. Wave Body MBARI: add collision mesh for buoy

- Add simplified collision meshes for the buoy at different levels of refinement.
- Use the mesh with 316 faces in the model.
- Add BEM file generated using Capytaine and the 5548 face mesh.

8.2. Wave Body MBARI: change default the BEM data file

- The excitation data in the hdf5 file generated from WAMIT data has the wrong sign, use Capytaine / bemio generated file in the meanwhile.
- Simplify ramp function.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

9. Wave Body MBARI: fix ramp function missing bracket (#78)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

10. Wave Body: don't use auto with Eigen (#79)

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>

11. Wave Body: update cmake dependencies

- Use FetchContent to retrieve dependency HighFive.
- Fix typo in documentation.
- Remove cpp style header for mlinterp

11.1 Wave Body: update ci workflow

- Add build flag for HighFive dependency

11.2. Wave Body: update waves bridge tests

- Remove breaking tests inherited from ROS project template.

11.3.Wave Body: post rebase fixes.

11.4. Wave-Body: fix config of regular_waves_3s_1m

11.5. Wave-Body: revert changes to regular_waves model

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🌱 garden Ignition Garden MBARI buoy Sponsored by MBARI buoy sim project: https://github.com/osrf/buoy_sim
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants